Skip to content

Commit 52c6db8

Browse files
authored
Run scons in CI (#14)
* try to run scons in azure pipelines * sudo * install capnp * does this run * also clean test runner * remove makefiles * this should build
1 parent 9414615 commit 52c6db8

11 files changed

+117
-166
lines changed

.dockerignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.sconsign.dblite

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ libcereal*.a
99
libmessaging.*
1010
libmessaging_shared.*
1111
services.h
12+
.sconsign.dblite
1213

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
from ubuntu:16.04
2+
3+
RUN apt-get update && apt-get install -y libzmq3-dev clang wget git autoconf libtool curl make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev libsqlite3-dev llvm libncurses5-dev libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev python-openssl
4+
5+
RUN curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
6+
ENV PATH="/root/.pyenv/bin:/root/.pyenv/shims:${PATH}"
7+
RUN pyenv install 3.7.3
8+
RUN pyenv global 3.7.3
9+
RUN pyenv rehash
10+
RUN pip3 install pyyaml==5.1.2 Cython==0.29.14 scons==3.1.1 pycapnp==0.6.4
11+
12+
WORKDIR /project/cereal
13+
COPY install_capnp.sh .
14+
RUN ./install_capnp.sh
15+
16+
ENV PYTHONPATH=/project
17+
18+
COPY . .
19+
RUN scons -c && scons -j$(nproc)

Makefile

-62
This file was deleted.

SConscript

+15-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
Import('env', 'arch', 'zmq')
22

3+
gen_dir = Dir('gen')
4+
messaging_dir = Dir('messaging')
5+
36
# TODO: remove src-prefix and cereal from command string. can we set working directory?
4-
env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p cereal/gen/c/include && touch $TARGETS")
7+
env.Command(["gen/c/include/c++.capnp.h", "gen/c/include/java.capnp.h"], [], "mkdir -p " + gen_dir.path + "/c/include && touch $TARGETS")
58
env.Command(
69
['gen/c/car.capnp.c', 'gen/c/log.capnp.c', 'gen/c/car.capnp.h', 'gen/c/log.capnp.h'],
710
['car.capnp', 'log.capnp'],
8-
'capnpc $SOURCES --src-prefix=cereal -o c:cereal/gen/c/')
11+
'capnpc $SOURCES --src-prefix=cereal -o c:' + gen_dir.path + '/c/')
912
env.Command(
1013
['gen/cpp/car.capnp.c++', 'gen/cpp/log.capnp.c++', 'gen/cpp/car.capnp.h', 'gen/cpp/log.capnp.h'],
1114
['car.capnp', 'log.capnp'],
12-
'capnpc $SOURCES --src-prefix=cereal -o c++:cereal/gen/cpp/')
15+
'capnpc $SOURCES --src-prefix=cereal -o c++:' + gen_dir.path + '/cpp/')
1316

1417
env.Library('cereal', [
1518
'gen/c/car.capnp.c',
@@ -18,10 +21,12 @@ env.Library('cereal', [
1821
'gen/cpp/log.capnp.c++',
1922
])
2023

24+
25+
cereal_dir = Dir('.')
2126
env.Command(
2227
['services.h'],
2328
['service_list.yaml', 'services.py'],
24-
'python3 cereal/services.py > $TARGET')
29+
'python3 ' + cereal_dir.path + '/services.py > $TARGET')
2530

2631
messaging_deps = [
2732
'messaging/messaging.cc',
@@ -39,12 +44,16 @@ if arch == "aarch64":
3944
messaging_shared_lib = env.SharedLibrary('messaging_shared', messaging_deps, LIBS=shared_lib_shared_lib)
4045
env.Command(['messaging/messaging.so'], [messaging_shared_lib], "chmod 777 $SOURCES && ln -sf `realpath $SOURCES` $TARGET")
4146

42-
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=['messaging', 'zmq'])
47+
env.Program('messaging/bridge', ['messaging/bridge.cc'], LIBS=[messaging_lib, 'zmq'])
4348

4449
# different target?
4550
#env.Program('messaging/demo', ['messaging/demo.cc'], LIBS=['messaging', 'zmq'])
4651

52+
4753
env.Command(['messaging/messaging_pyx.so'],
4854
[messaging_lib, 'messaging/messaging_pyx_setup.py', 'messaging/messaging_pyx.pyx', 'messaging/messaging.pxd'],
49-
"cd cereal/messaging && python3 messaging_pyx_setup.py build_ext --inplace")
55+
"cd " + messaging_dir.path + " && python3 messaging_pyx_setup.py build_ext --inplace")
56+
5057

58+
if GetOption('test'):
59+
env.Program('messaging/test_runner', ['messaging/test_runner.cc', 'messaging/msgq_tests.cc'], LIBS=[messaging_lib])

SConstruct

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import os
2+
import subprocess
3+
4+
zmq = 'zmq'
5+
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
6+
7+
cereal_dir = Dir('.')
8+
9+
cpppath = [
10+
cereal_dir,
11+
'/usr/lib/include',
12+
]
13+
14+
AddOption('--test',
15+
action='store_true',
16+
help='build test files')
17+
18+
AddOption('--asan',
19+
action='store_true',
20+
help='turn on ASAN')
21+
22+
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else []
23+
ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else []
24+
25+
env = Environment(
26+
ENV=os.environ,
27+
CC='clang',
28+
CXX='clang++',
29+
CCFLAGS=[
30+
"-g",
31+
"-fPIC",
32+
"-O2",
33+
"-Werror=implicit-function-declaration",
34+
"-Werror=incompatible-pointer-types",
35+
"-Werror=int-conversion",
36+
"-Werror=return-type",
37+
"-Werror=format-extra-args",
38+
] + ccflags_asan,
39+
LDFLAGS=ldflags_asan,
40+
LINKFLAGS=ldflags_asan,
41+
42+
CFLAGS="-std=gnu11",
43+
CXXFLAGS="-std=c++14",
44+
CPPPATH=cpppath,
45+
)
46+
47+
48+
Export('env', 'zmq', 'arch')
49+
SConscript(['SConscript'])

azure-pipelines.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ pool:
33

44
steps:
55
- script: |
6-
cd messaging
7-
ASAN=1 make test_runner
8-
./test_runner -r junit -o tests.xml
6+
docker build -t cereal .
7+
docker run cereal bash -c "scons --test --asan -j$(nproc) && messaging/test_runner"
8+
99
displayName: 'Run Tests'
10-
- task: PublishTestResults@2
11-
inputs:
12-
testResultsFiles: 'messaging/tests.xml'

install_capnp.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ tar xvf capnproto-c++-${VERSION}.tar.gz
88
cd capnproto-c++-${VERSION}
99
CXXFLAGS="-fPIC" ./configure
1010

11-
make -j4
11+
make -j$(nproc)
12+
make install
1213

1314
# manually build binaries statically
1415
g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnp src/capnp/compiler/module-loader.o src/capnp/compiler/capnp.o ./.libs/libcapnpc.a ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread
@@ -18,7 +19,6 @@ g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -D
1819
g++ -std=gnu++11 -I./src -I./src -DKJ_HEADER_WARNINGS -DCAPNP_HEADER_WARNINGS -DCAPNP_INCLUDE_DIR=\"/usr/local/include\" -pthread -O2 -DNDEBUG -pthread -pthread -o .libs/capnpc-capnp src/capnp/compiler/capnpc-capnp.o ./.libs/libcapnp.a ./.libs/libkj.a -lpthread -pthread
1920

2021
cp .libs/capnp /usr/local/bin/
21-
ln -s /usr/local/bin/capnp /usr/local/bin/capnpc
2222
cp .libs/capnpc-c++ /usr/local/bin/
2323
cp .libs/capnpc-capnp /usr/local/bin/
2424
cp .libs/*.a /usr/local/lib
@@ -30,7 +30,8 @@ cd c-capnproto
3030
git submodule update --init --recursive
3131
autoreconf -f -i -s
3232
CXXFLAGS="-fPIC" ./configure
33-
make -j4
33+
make -j$(nproc)
34+
make install
3435

3536
# manually build binaries statically
3637
gcc -fPIC -o .libs/capnpc-c compiler/capnpc-c.o compiler/schema.capnp.o compiler/str.o ./.libs/libcapnp_c.a

messaging/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ test_runner
77
*.a
88
*.so
99
messaging_pyx.cpp
10+
build/

messaging/Makefile

-88
This file was deleted.

messaging/messaging_pyx_setup.py

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,33 @@
11
import os
22
import subprocess
3+
import sysconfig
34
from distutils.core import Extension, setup # pylint: disable=import-error,no-name-in-module
45

56
from Cython.Build import cythonize
7+
from Cython.Distutils import build_ext
8+
9+
10+
def get_ext_filename_without_platform_suffix(filename):
11+
name, ext = os.path.splitext(filename)
12+
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
13+
14+
if ext_suffix == ext:
15+
return filename
16+
17+
ext_suffix = ext_suffix.replace(ext, '')
18+
idx = name.find(ext_suffix)
19+
20+
if idx == -1:
21+
return filename
22+
else:
23+
return name[:idx] + ext
24+
25+
26+
class BuildExtWithoutPlatformSuffix(build_ext):
27+
def get_ext_filename(self, ext_name):
28+
filename = super().get_ext_filename(ext_name)
29+
return get_ext_filename_without_platform_suffix(filename)
630

7-
from common.cython_hacks import BuildExtWithoutPlatformSuffix
831

932
sourcefiles = ['messaging_pyx.pyx']
1033
extra_compile_args = ["-std=c++11"]

0 commit comments

Comments
 (0)