File tree Expand file tree Collapse file tree 6 files changed +83
-23
lines changed Expand file tree Collapse file tree 6 files changed +83
-23
lines changed Original file line number Diff line number Diff line change 1
1
language : cpp
2
- sudo : false
3
- compiler : clang
2
+ sudo : required
3
+ compiler : gcc
4
4
5
5
script :
6
- - mkdir -p target
7
- - cd target
8
- - cmake ..
9
- - make
10
- - ./scalaBindgen /usr/include/ctype.h -name ctype
6
+ - docker-compose build ubuntu-16.04-llvm-$LLVM_VERSION
7
+ - docker run --rm -ti scala-native-bindgen:ubuntu-16.04-llvm-$LLVM_VERSION /usr/include/ctype.h -name ctype --
8
+ - docker run --rm -ti scala-native-bindgen:ubuntu-16.04-llvm-$LLVM_VERSION
9
+
10
+ matrix :
11
+ include :
12
+ - env : LLVM_VERSION=dev
13
+ - env : LLVM_VERSION=6.0
14
+ - env : LLVM_VERSION=5.0
Original file line number Diff line number Diff line change @@ -3,22 +3,13 @@ project(scala-native-bindgen)
3
3
4
4
# Locate $LLVM_PATH/lib/cmake/clang/ClangConfig.cmake
5
5
find_package (Clang REQUIRED CONFIG )
6
+ message (STATUS "Found LLVM ${LLVM_PACKAGE_VERSION} " )
7
+ message (STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR} " )
6
8
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} " )
9
+ include_directories (${LLVM_INCLUDE_DIRS} )
10
+ add_definitions (${LLVM_DEFINITIONS} )
20
11
21
- add_compile_options (-fexceptions )
12
+ add_compile_options (-fexceptions -std=c++11 )
22
13
23
14
add_executable (scalaBindgen
24
15
Main.cpp
Original file line number Diff line number Diff line change
1
+ ARG UBUNTU_VERSION=16.04
2
+ FROM ubuntu:$UBUNTU_VERSION
3
+
4
+ RUN set -x \
5
+ && apt update \
6
+ && apt install -y curl build-essential \
7
+ && rm -rf /var/lib/apt/lists/*
8
+
9
+ WORKDIR /cmake
10
+ ARG CMAKE_ARCHIVE=cmake-3.11.2-Linux-x86_64
11
+ RUN curl https://cmake.org/files/v3.11/$CMAKE_ARCHIVE.tar.gz | tar zxf - \
12
+ && for i in bin share; do \
13
+ cp -r /cmake/$CMAKE_ARCHIVE/$i/* /usr/$i/; \
14
+ done \
15
+ && rm -rf /cmake
16
+
17
+ ARG LLVM_VERSION=6.0
18
+ # LLVM dev versions do not have a "-x.y" version suffix.
19
+ ARG LLVM_DEB_COMPONENT=-$LLVM_VERSION
20
+ RUN set -x \
21
+ && curl https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - \
22
+ && . /etc/lsb-release \
23
+ && echo "deb http://apt.llvm.org/$DISTRIB_CODENAME/ llvm-toolchain-$DISTRIB_CODENAME$LLVM_DEB_COMPONENT main" > /etc/apt/sources.list.d/llvm.list \
24
+ && apt update \
25
+ && apt install -y clang-$LLVM_VERSION libclang-$LLVM_VERSION-dev make \
26
+ && rm -rf /var/lib/apt/lists/*
27
+
28
+ WORKDIR /src/target
29
+ COPY . /src
30
+ RUN cmake .. && make VERBOSE=1
31
+
32
+ ENTRYPOINT ["/src/target/scalaBindgen" ]
Original file line number Diff line number Diff line change @@ -47,8 +47,13 @@ TEST_CASE("native types", "[Type]" ) {
47
47
for (const auto & kv: types){
48
48
std::string code = " #include<uchar.h>\n #include<stddef.h>\n typedef " + kv.first + " a;\n " ;
49
49
std::string answer = " \t type a = " + kv.second + " \n " ;
50
+ std::string translated = Translate (code);
51
+ std::string::size_type last_line_pos = translated.rfind (" \t " );
52
+ // FIXME(jonas): Only test against the last line until we prune
53
+ // type aliases according to referenced output types.
54
+ std::string last_line = translated.substr (last_line_pos);
50
55
51
- REQUIRE (answer == Translate (code) );
56
+ REQUIRE (answer == last_line );
52
57
}
53
58
}
54
59
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ bool TreeVisitor::VisitFunctionDecl(clang::FunctionDecl *func) {
37
37
}
38
38
39
39
// Note the C Iso require at least one argument in a variadic function, so the comma is fine
40
- std::string variad = func->isVariadic () ? " , varArgs: native.CVararg" : " " ;
40
+ std::string variad = func->isVariadic () ? " , varArgs: native.CVararg* " : " " ;
41
41
42
42
declarations += " \t def " + funcName + " (" + params + variad + " ): " + retType + " = native.extern\n " ;
43
43
return true ;
Original file line number Diff line number Diff line change
1
+ version : ' 3'
2
+
3
+ services :
4
+ ubuntu-16.04-llvm-dev :
5
+ image : scala-native-bindgen:ubuntu-16.04-llvm-dev
6
+ build :
7
+ context : .
8
+ args :
9
+ - UBUNTU_VERSION=16.04
10
+ - LLVM_VERSION=7
11
+ - LLVM_DEB_COMPONENT=
12
+
13
+ ubuntu-16.04-llvm-6.0 :
14
+ image : scala-native-bindgen:ubuntu-16.04-llvm-6.0
15
+ build :
16
+ context : .
17
+ args :
18
+ - UBUNTU_VERSION=16.04
19
+ - LLVM_VERSION=6.0
20
+
21
+ ubuntu-16.04-llvm-5.0 :
22
+ image : scala-native-bindgen:ubuntu-16.04-llvm-5.0
23
+ build :
24
+ context : .
25
+ args :
26
+ - UBUNTU_VERSION=16.04
27
+ - LLVM_VERSION=5.0
28
+
You can’t perform that action at this time.
0 commit comments