Skip to content

Commit dfd5933

Browse files
committed
Build the project using an embedded Clang
1 parent 28972c2 commit dfd5933

File tree

4 files changed

+43
-21
lines changed

4 files changed

+43
-21
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
target

.travis.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
language: cpp
2+
sudo: false
3+
compiler: clang
4+
5+
script:
6+
- mkdir -p target
7+
- cd target
8+
- cmake ..
9+
- make
10+
- ./scalaBindgen /usr/include/ctype.h -name ctype

CMakeLists.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,26 @@
1-
set(LLVM_LINK_COMPONENTS support)
1+
cmake_minimum_required(VERSION 3.9)
2+
project(scala-native-bindgen)
3+
4+
# Locate $LLVM_PATH/lib/cmake/clang/ClangConfig.cmake
5+
find_package(Clang REQUIRED CONFIG)
6+
7+
# Read and set CXXFLAGS and LDFLAGS
8+
execute_process(COMMAND llvm-config --cxxflags
9+
OUTPUT_VARIABLE LLVM_CXX_FLAGS
10+
OUTPUT_STRIP_TRAILING_WHITESPACE
11+
)
12+
13+
execute_process(COMMAND llvm-config --ldflags
14+
OUTPUT_VARIABLE LLVM_LINKER_FLAGS
15+
OUTPUT_STRIP_TRAILING_WHITESPACE
16+
)
17+
18+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LLVM_CXX_FLAGS}")
19+
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${LLVM_LINKER_FLAGS}")
220

321
add_compile_options(-fexceptions)
422

5-
add_clang_executable(scalaBindgen
23+
add_executable(scalaBindgen
624
Main.cpp
725
ScalaFrontend.h
826
TreeVisitor.h
@@ -21,16 +39,5 @@ add_clang_executable(scalaBindgen
2139
target_link_libraries(scalaBindgen
2240
PRIVATE
2341
clangFrontend
24-
clangSerialization
25-
clangDriver
2642
clangTooling
27-
clangParse
28-
clangSema
29-
30-
clangAnalysis
31-
32-
clangEdit
33-
clangAST
34-
clangLex
35-
clangBasic
3643
)

README.md

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,15 @@ Running the previous command wild also yield warnings along with the translation
1414

1515
## Building
1616

17-
Building this tool require building LLVM and Clang. This can take hours. Please consider using pre-built binaries.
18-
19-
* Follow the [building instructions](http://clang.llvm.org/docs/LibASTMatchersTutorial.html#step-0-obtaining-clang) for Clang (Only step 0)
20-
* Go to `llvm/tools/clang/tools/extra`
21-
* Clone this repository `git clone https://github.com/mrRosset/scala-native-bindgen scala-bindgen`
22-
* Add `add_subdirectory(scala-bindgen)` to the CMakeLists.txt in the extra folder
23-
* Re-run the llvm/clang compilation
24-
17+
Building this tool requires LLVM and Clang. Ensure that `llvm-config` is in your path.
18+
19+
```sh
20+
# Validate LLVM installation
21+
llvm-config --version --cmakedir --cxxflags --ldflags
22+
23+
mkdir -p target
24+
cd target
25+
cmake ..
26+
make
27+
./scalaBindgen /usr/include/ctype.h -name ctype
28+
```

0 commit comments

Comments
 (0)