Skip to content

Commit

Permalink
fix(darwin): remove debug symbols (<lang>.so.dSYM) (#29)
Browse files Browse the repository at this point in the history
* ci(darwin): add check for unwanted dSYM

* fix(darwin): try to delete dSYM debug symbol files
  • Loading branch information
mrcjkb authored Jul 11, 2024
1 parent 1bd1dfc commit f57b899
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
10 changes: 10 additions & 0 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,16 @@
buildInputs = [
final.tree-sitter
];
fixupPhase = ''
if [ ! -f $out/lib/lua/5.1/parser/norg.so ]; then
echo "Build did not create parser/norg.so in the expected location"
exit 1
fi
if [ -f $out/lib/lua/5.1/parser/norg.so.dSYM ]; then
echo "Unwanted darwin debug symbols!"
exit 1
fi
'';
}) {})
.overrideAttrs (oa: {
nativeBuildInputs =
Expand Down
12 changes: 10 additions & 2 deletions src/luarocks/build/treesitter-parser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,18 +143,26 @@ function treesitter_parser.run(rockspec, no_install)
local parser_dir = dir.path(lib_dir, "parser")
local ok, err
if build_parser then
local parser_lib = rockspec.build.lang .. "." .. cfg.lib_extension
if fs.is_tool_available("tree-sitter", "tree-sitter CLI") then
-- Try tree-sitter build first
fs.make_dir(parser_dir)
local parser_lib = dir.path(parser_dir, rockspec.build.lang .. "." .. cfg.lib_extension)
ok = execute("tree-sitter", "build", "-o", parser_lib, ".") and fs.exists(parser_lib)
local parser_lib_path = dir.path(parser_dir, parser_lib)
ok = execute("tree-sitter", "build", "-o", parser_lib_path, ".") and fs.exists(parser_lib_path)
end
if not ok and has_sources then
-- Fall back to builtin build
ok, err = builtin.run(rockspec, no_install)
elseif not ok then
err = "'tree-sitter build' failed. Note: tree-sitter 0.22.2 or later is required to build this parser."
end
pcall(function()
local dsym_file = dir.absolute_name(dir.path(parser_dir, parser_lib .. ".dSYM"))
if fs.exists(dsym_file) then
-- Try to remove macos debug symbols if they exist
fs.delete(dsym_file)
end
end)
else
ok = true
end
Expand Down

0 comments on commit f57b899

Please sign in to comment.