diff --git a/Makefile b/Makefile index 0536e0b..0ed134c 100644 --- a/Makefile +++ b/Makefile @@ -2,9 +2,18 @@ EXECUTABLE_NAME = locheck REPO = https://github.com/Asana/locheck VERSION = 0.9.11 +UNAME_S := $(shell uname -s) + +ifeq ($(UNAME_S), Darwin) + BUILD_PATH_PREFIX := .build/apple/Products/Release +endif +ifeq ($(UNAME_S), Linux) + BUILD_PATH_PREFIX := .build/release +endif + PREFIX = /usr/local INSTALL_PATH = $(PREFIX)/bin/$(EXECUTABLE_NAME) -BUILD_PATH = .build/apple/Products/Release/$(EXECUTABLE_NAME) +BUILD_PATH = $(BUILD_PATH_PREFIX)/$(EXECUTABLE_NAME) CURRENT_PATH = $(PWD) RELEASE_TAR = $(REPO)/archive/$(VERSION).tar.gz GIT_STATUS := $(shell git status -s) diff --git a/Sources/LocheckCommand/main.swift b/Sources/LocheckCommand/main.swift index 478cf8c..f0e2190 100644 --- a/Sources/LocheckCommand/main.swift +++ b/Sources/LocheckCommand/main.swift @@ -6,11 +6,16 @@ // import ArgumentParser -import Darwin import Files import Foundation import LocheckLogic +#if os(Linux) || os(FreeBSD) + import func Glibc.exit +#else + import func Darwin.exit +#endif + let version = "0.9.11" struct Locheck: ParsableCommand { @@ -42,7 +47,7 @@ private func withProblemReporter( block(problemReporter) if problemReporter.hasError || (treatWarningsAsErrors && problemReporter.hasWarning) { print("Errors found") - Darwin.exit(1) + exit(1) } print("Finished validating") } diff --git a/Sources/LocheckLogic/ProblemReporter.swift b/Sources/LocheckLogic/ProblemReporter.swift index e1de2f5..b36d70b 100644 --- a/Sources/LocheckLogic/ProblemReporter.swift +++ b/Sources/LocheckLogic/ProblemReporter.swift @@ -5,10 +5,16 @@ // Created by Steve Landey on 8/18/21. // -import func Darwin.fputs -import var Darwin.stderr import Foundation +#if os(Linux) || os(FreeBSD) + import func Glibc.fputs + import var Glibc.stderr +#else + import func Darwin.fputs + import var Darwin.stderr +#endif + private struct StderrOutputStream: TextOutputStream { mutating func write(_ string: String) { fputs(string, stderr)