Skip to content

Commit

Permalink
fix!: separate build into C and C++ compilation per file
Browse files Browse the repository at this point in the history
  • Loading branch information
mrcjkb committed Aug 14, 2024
1 parent e242eaf commit 7802c9f
Show file tree
Hide file tree
Showing 5 changed files with 355 additions and 97 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ jobs:
with:
ref: ${{ github.ref }}

# - name: Install C/C++ Compiler
# uses: rlalik/setup-cpp-compiler@master
# with:
# compiler: clang-latest
- name: Install C/C++ Compiler
uses: rlalik/setup-cpp-compiler@master
with:
compiler: clang-latest

- name: Install MSVC Compiler Toolchain
uses: ilammy/msvc-dev-cmd@v1
Expand All @@ -39,15 +39,15 @@ jobs:

- name: Install build dependencies
run: |
luarocks --local --lua-version=5.1 make ./luarocks-build-treesitter-parser-scm-1.rockspec
luarocks --local --lua-version=5.1 make ./luarocks-build-treesitter-parser-cpp-scm-1.rockspec
- name: Install tree-sitter parser
run: |
luarocks --local --lua-version=5.1 install tree-sitter-haskell --dev
- name: Pack and create manifest
run: |
luarocks pack tree-sitter-haskell
luarocks pack tree-sitter-norg
luarocks-admin make-manifest --lua-version=5.1 .
dir
type manifest-5.1
18 changes: 1 addition & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,27 +57,11 @@ build = {
lang = "LANG",

---@type string[] parser source files.
sources = { "src/parser.c", "src/scanner.c" },
sources = { "src/parser.c", "src/scanner.cc" },

---@type boolean? (optional) Won't build the parser if `false`.
parser = true,

-- For C++ sources, this build backend automatically sets "-lstdc++"
-- You can override the default by passing in a list of flags.
-- libflags = ...
platforms = {
macosx = {
---@type strin[]? (optional) Ignored if `sources` is unset or empty
libflags = {
"-bundle",
"-undefined",
"dynamic_lookup",
"-all_load",
"-std=c++11",
},
},
},

---@type boolean? (optional) Must the sources be generated using the tree-sitter CLI?
generate = true,

Expand Down
11 changes: 0 additions & 11 deletions fixtures/tree-sitter-norg-scm-1.rockspec
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,4 @@ build = {
type = "treesitter-parser-cpp",
lang = "norg",
sources = { "src/parser.c", "src/scanner.cc" },
platforms = {
macosx = {
libflags = {
"-bundle",
"-undefined",
"dynamic_lookup",
"-all_load",
"-std=c++11",
},
},
},
}
82 changes: 31 additions & 51 deletions nix/overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,63 +16,43 @@
];
}) {};

tree-sitter-norg =
(luaself.callPackage ({
buildLuarocksPackage,
fetchFromGitHub,
luaOlder,
luarocks-build-treesitter-parser-cpp,
}:
buildLuarocksPackage {
pname = "tree-sitter-norg";
version = "scm-1";
knownRockspec = "${self}/fixtures/tree-sitter-norg-scm-1.rockspec";
src = fetchFromGitHub {
owner = "nvim-neorg";
repo = "tree-sitter-norg";
rev = "014073fe8016d1ac440c51d22c77e3765d8f6855";
hash = "sha256-0wL3Pby7e4nbeVHCRfWwxZfEcAF9/s8e6Njva+lj+Rc=";
};
propagatedBuildInputs = [
luarocks-build-treesitter-parser-cpp
];
disabled = luaOlder "5.1";
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 =
oa.nativeBuildInputs
++ (with final;
lib.optionals stdenv.isDarwin [
clang
]);
tree-sitter-norg = luaself.callPackage ({
buildLuarocksPackage,
fetchFromGitHub,
luaOlder,
luarocks-build-treesitter-parser-cpp,
}:
buildLuarocksPackage {
pname = "tree-sitter-norg";
version = "scm-1";
knownRockspec = "${self}/fixtures/tree-sitter-norg-scm-1.rockspec";
src = fetchFromGitHub {
owner = "nvim-neorg";
repo = "tree-sitter-norg";
rev = "014073fe8016d1ac440c51d22c77e3765d8f6855";
hash = "sha256-0wL3Pby7e4nbeVHCRfWwxZfEcAF9/s8e6Njva+lj+Rc=";
};
buildInputs = [
final.libcxx
];
propagatedBuildInputs = [
luarocks-build-treesitter-parser-cpp
];
disabled = luaOlder "5.1";
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
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
'';
});

}) {};
};
lua5_1_base =
if prev.stdenv.isDarwin
then
prev.lua5_1.override {
stdenv = final.clangStdenv;
}
else prev.lua5_1;
in {
lua5_1 = lua5_1_base.override {
lua5_1 = prev.lua5_1.override {
packageOverrides = luaPackage-override;
};
lua51Packages = final.lua5_1.pkgs;
Expand Down
Loading

0 comments on commit 7802c9f

Please sign in to comment.