Skip to content

Commit a265d35

Browse files
authored
Azure pipelines ci (#202)
* add docker file and sconstruct * this should work in ci * remove branch name
1 parent bce9a2e commit a265d35

5 files changed

+145
-4
lines changed

Dockerfile

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
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 Jinja2==2.10.3
11+
12+
13+
ENV PYTHONPATH=/project
14+
15+
# TODO: Add tag to cereal
16+
RUN git clone https://github.com/commaai/cereal.git /project/cereal
17+
RUN /project/cereal/install_capnp.sh
18+
19+
WORKDIR /project
20+
21+
COPY SConstruct .
22+
COPY . /project/opendbc
23+
24+
RUN scons -c && scons -j$(nproc)

SConstruct

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
'#',
11+
'#cereal',
12+
"#cereal/messaging",
13+
"#opendbc/can",
14+
'/usr/lib/include',
15+
]
16+
17+
AddOption('--test',
18+
action='store_true',
19+
help='build test files')
20+
21+
AddOption('--asan',
22+
action='store_true',
23+
help='turn on ASAN')
24+
25+
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else []
26+
ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else []
27+
28+
env = Environment(
29+
ENV=os.environ,
30+
CC='clang',
31+
CXX='clang++',
32+
CCFLAGS=[
33+
"-g",
34+
"-fPIC",
35+
"-O2",
36+
"-Werror=implicit-function-declaration",
37+
"-Werror=incompatible-pointer-types",
38+
"-Werror=int-conversion",
39+
"-Werror=return-type",
40+
"-Werror=format-extra-args",
41+
] + ccflags_asan,
42+
LDFLAGS=ldflags_asan,
43+
LINKFLAGS=ldflags_asan,
44+
45+
CFLAGS="-std=gnu11",
46+
CXXFLAGS="-std=c++14",
47+
CPPPATH=cpppath,
48+
)
49+
50+
Export('env', 'zmq', 'arch')
51+
52+
cereal = [File('#cereal/libcereal.a')]
53+
messaging = [File('#cereal/libmessaging.a')]
54+
Export('cereal', 'messaging')
55+
56+
SConscript(['cereal/SConscript'])
57+
SConscript(['opendbc/can/SConscript'])

azure-pipelines.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
pr: none
2+
3+
pool:
4+
vmImage: 'ubuntu-16.04'
5+
6+
steps:
7+
- script: |
8+
set -e
9+
docker build -t opendbc .
10+
docker run opendbc bash -c "python -m unittest discover opendbc"
11+
12+
displayName: 'Run Tests'

can/packer_pyx_setup.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
11
import os
2+
import sysconfig
23
import subprocess
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+
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))
10+
11+
12+
def get_ext_filename_without_platform_suffix(filename):
13+
name, ext = os.path.splitext(filename)
14+
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
15+
16+
if ext_suffix == ext:
17+
return filename
18+
19+
ext_suffix = ext_suffix.replace(ext, '')
20+
idx = name.find(ext_suffix)
21+
22+
if idx == -1:
23+
return filename
24+
else:
25+
return name[:idx] + ext
26+
27+
28+
class BuildExtWithoutPlatformSuffix(build_ext):
29+
def get_ext_filename(self, ext_name):
30+
filename = super().get_ext_filename(ext_name)
31+
return get_ext_filename_without_platform_suffix(filename)
632

7-
from common.basedir import BASEDIR
8-
from common.cython_hacks import BuildExtWithoutPlatformSuffix
933

1034
sourcefiles = ['packer_pyx.pyx']
1135
extra_compile_args = ["-std=c++11"]

can/parser_pyx_setup.py

+26-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,35 @@
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+
BASEDIR = os.path.abspath(os.path.join(os.path.dirname(os.path.realpath(__file__)), "../../"))
10+
11+
12+
def get_ext_filename_without_platform_suffix(filename):
13+
name, ext = os.path.splitext(filename)
14+
ext_suffix = sysconfig.get_config_var('EXT_SUFFIX')
15+
16+
if ext_suffix == ext:
17+
return filename
18+
19+
ext_suffix = ext_suffix.replace(ext, '')
20+
idx = name.find(ext_suffix)
21+
22+
if idx == -1:
23+
return filename
24+
else:
25+
return name[:idx] + ext
26+
27+
28+
class BuildExtWithoutPlatformSuffix(build_ext):
29+
def get_ext_filename(self, ext_name):
30+
filename = super().get_ext_filename(ext_name)
31+
return get_ext_filename_without_platform_suffix(filename)
632

7-
from common.basedir import BASEDIR
8-
from common.cython_hacks import BuildExtWithoutPlatformSuffix
933

1034
sourcefiles = ['parser_pyx.pyx']
1135
extra_compile_args = ["-std=c++11"]

0 commit comments

Comments
 (0)