Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle macos SDK in the justfile include_args #184

Merged
merged 3 commits into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ indent_size = 8
[Makefile]
indent_style = tab
indent_size = 8

[justfile]
indent_style = tab
indent_size = 4
33 changes: 21 additions & 12 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ just_repo := "https://github.com/casey/just.git"
just_branch := "master"
just_sha := "f5bdffda344daca6c791303e4bb2006ee5a0b144" # 1.35.0

include_args := "-Isrc/ -I" + ts_path + "/lib/include -Inode_modules/nan"
include_args := "-Isrc/ -I" + ts_path + "/lib/include -Inode_modules/nan" + if os() == "macos" {
" -I" + `xcrun --sdk macosx --show-sdk-path` + "/usr/include/"
} else {
""
}
general_cflags := "-Wall -Werror --pedantic -Wno-format-pedantic"

fuzzer_flags := env("FUZZER_FLAGS", "-fsanitize=fuzzer,address,undefined")
Expand Down Expand Up @@ -50,27 +54,31 @@ no_just_parsing := '''
default:
just --list

# Install needed packages and make sure tools are setup
setup *npm-args:
_check_installed +dep:
#!/bin/sh
set -eau

check_installed () {
check_installed() {
printf "checking $1... "
if "$1" --version 2> /dev/null ; then
local dep=0
command -v "$1" 1>/dev/null || dep=$?
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this allows checking dependencies that do not have a --version flag


if [[ "${dep}" == 0 ]]; then
echo "tool $1 found!"
else
echo
echo "tool $1 NOT found. This may be needed for some functionality"
fi
echo
}

check_installed npm
check_installed cargo
check_installed clang
check_installed clang-tidy
check_installed clang-format
for d in {{dep}}; do
check_installed $d
done

# Install needed packages and make sure tools are setup
setup *npm-args:
#!/bin/sh
set -eau
just _check_installed npm cargo clang clang-tidy clang-format kk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tgross35 I'm surprised this kk passed CI, I wonder if the check was skipped?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check-installed doesn't actually require it be installed, just warn when it isn't. Maybe this should change on CI.

I actually had to adjust this in #186 and removed it there - it was always saying not found, bash syntax with a sh shebang :) I should have read the output better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should have tested it myself, should not have pushed the commit


if which npm > /dev/null; then
npm install --include=dev {{ npm-args }}
Expand All @@ -89,6 +97,7 @@ _lint-min: _clone-repo-tree-sitter configure-compile-database
# Run the linter for JS, C, Cargo, and Python. Requires clang-tidy, clippy, and ruff.
lint: _lint-min
cargo clippy
@just _check_installed ruff
ruff check .

_out-dirs:
Expand Down
Loading