elixir-lang / tree-sitter-elixir

Elixir grammar for tree-sitter
https://elixir-lang.org/tree-sitter-elixir
Apache License 2.0
245 stars 24 forks source link

Makefile #40

Closed mattmassicotte closed 1 year ago

mattmassicotte commented 1 year ago

This change adds a Makefile and bindings to more easily build static/dynamic libraries for use in C-based languages. The implementation is intended to be as generic as possible, to make for easier adoption and diffing.

This comes from discussion in the main tree-sitter repo https://github.com/tree-sitter/tree-sitter/issues/1488.

jonatanklosko commented 1 year ago

Hey @mattmassicotte! Building locally I get:

cc  -shared -Wl,-lc++-soname,libtree-sitter-elixir.so.0 src/parser.o src/scanner.o  -o libtree-sitter-elixir.so.0.0
/usr/bin/ld: cannot find -lc++-soname
/usr/bin/ld: cannot find libtree-sitter-elixir.so.0: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:81: libtree-sitter-elixir.so.0.0] Error 1

I assume that's because I'm missing clang, but in a fresh ubuntu20 docker image I did apt install build-essential clang libc++-dev libc++abi-dev and sill could build. Did you successfully built on linux?

mattmassicotte commented 1 year ago

@jonatanklosko thanks so much for trying this. I'm afraid that no, I did not build on linux. I should have, but am just not set up to do that easily at the moment.

Building up this Makefile has been a pretty long and arduous process, and I apologize for the issue. I think (hope) the problem is not clang, but a typo. I've just pushed a change. Would you be willing to try it out again?

jonatanklosko commented 1 year ago

It does build correctly with clang now, thanks! FTR here's how I tested it:

docker run -it --rm ubuntu:20.04

then

apt update
apt install git build-essential clang libc++-dev libc++abi-dev
git clone https://github.com/mattmassicotte/tree-sitter-elixir.git
cd tree-sitter-elixir
make

Also, we are not gitignoring the generated .so files, because they have the version suffix. Let's add libtree-sitter-elixir.so*?

mattmassicotte commented 1 year ago

Thanks so much for documenting what you were doing to test. And thanks again for your patience.

Great suggestions for the .gitignore. I've both expanded it and made the matches more explicit.

the-mikedavis commented 1 year ago

Thanks @mattmassicotte!