Skip to content

Commit

Permalink
locheck: add support for linux. (#56)
Browse files Browse the repository at this point in the history
* locheck: add support for linux.

* Makefile: fix build path.
  • Loading branch information
AnessZurba committed May 3, 2024
1 parent 327454d commit 258bcb5
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 5 deletions.
11 changes: 10 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 7 additions & 2 deletions Sources/LocheckCommand/main.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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")
}
Expand Down
10 changes: 8 additions & 2 deletions Sources/LocheckLogic/ProblemReporter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 258bcb5

Please sign in to comment.