2019-11-21 08:32:42 +08:00
|
|
|
import os
|
2021-01-08 21:54:41 +08:00
|
|
|
import platform
|
2019-11-21 08:32:42 +08:00
|
|
|
import subprocess
|
2020-11-26 09:14:50 +08:00
|
|
|
import sysconfig
|
2021-08-30 13:00:09 +08:00
|
|
|
import numpy as np
|
2019-11-21 08:32:42 +08:00
|
|
|
|
2021-01-08 21:54:41 +08:00
|
|
|
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
|
|
|
if platform.system() == "Darwin":
|
|
|
|
arch = "Darwin"
|
2020-07-17 04:33:19 +08:00
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
cereal_dir = Dir('.')
|
2021-01-08 21:54:41 +08:00
|
|
|
messaging_dir = Dir('./messaging')
|
2021-07-29 16:32:29 +08:00
|
|
|
common = ''
|
2019-11-21 08:32:42 +08:00
|
|
|
|
|
|
|
cpppath = [
|
2020-10-24 15:07:24 +08:00
|
|
|
cereal_dir,
|
2021-01-08 21:54:41 +08:00
|
|
|
messaging_dir,
|
2020-10-24 15:07:24 +08:00
|
|
|
'/usr/lib/include',
|
2021-05-03 01:34:00 +08:00
|
|
|
'/opt/homebrew/include',
|
2020-11-26 09:14:50 +08:00
|
|
|
sysconfig.get_paths()['include'],
|
2019-11-21 08:32:42 +08:00
|
|
|
]
|
|
|
|
|
2021-05-03 01:34:00 +08:00
|
|
|
libpath = [
|
|
|
|
'/opt/homebrew/lib',
|
|
|
|
]
|
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
AddOption('--test',
|
|
|
|
action='store_true',
|
|
|
|
help='build test files')
|
|
|
|
|
|
|
|
AddOption('--asan',
|
|
|
|
action='store_true',
|
|
|
|
help='turn on ASAN')
|
|
|
|
|
|
|
|
ccflags_asan = ["-fsanitize=address", "-fno-omit-frame-pointer"] if GetOption('asan') else []
|
|
|
|
ldflags_asan = ["-fsanitize=address"] if GetOption('asan') else []
|
|
|
|
|
|
|
|
env = Environment(
|
|
|
|
ENV=os.environ,
|
|
|
|
CC='clang',
|
|
|
|
CXX='clang++',
|
|
|
|
CCFLAGS=[
|
|
|
|
"-g",
|
|
|
|
"-fPIC",
|
|
|
|
"-O2",
|
2020-07-09 07:03:57 +08:00
|
|
|
"-Wunused",
|
2020-06-28 08:23:19 +08:00
|
|
|
"-Werror",
|
2019-11-21 08:32:42 +08:00
|
|
|
] + ccflags_asan,
|
|
|
|
LDFLAGS=ldflags_asan,
|
|
|
|
LINKFLAGS=ldflags_asan,
|
|
|
|
|
|
|
|
CFLAGS="-std=gnu11",
|
2020-10-18 03:40:42 +08:00
|
|
|
CXXFLAGS="-std=c++1z",
|
2019-11-21 08:32:42 +08:00
|
|
|
CPPPATH=cpppath,
|
2021-05-03 01:34:00 +08:00
|
|
|
LIBPATH=libpath,
|
2020-11-26 09:14:50 +08:00
|
|
|
CYTHONCFILESUFFIX=".cpp",
|
|
|
|
tools=["default", "cython"]
|
2019-11-21 08:32:42 +08:00
|
|
|
)
|
2020-10-24 15:07:24 +08:00
|
|
|
|
2021-07-29 16:32:29 +08:00
|
|
|
Export('env', 'arch', 'common')
|
2020-11-26 09:14:50 +08:00
|
|
|
|
2021-01-08 21:54:41 +08:00
|
|
|
envCython = env.Clone(LIBS=[])
|
2021-08-30 13:00:09 +08:00
|
|
|
envCython["CPPPATH"] += [np.get_include()]
|
2021-01-08 21:54:41 +08:00
|
|
|
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"]
|
2020-11-26 09:14:50 +08:00
|
|
|
if arch == "Darwin":
|
|
|
|
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
|
|
|
|
elif arch == "aarch64":
|
|
|
|
envCython["LINKFLAGS"] = ["-shared"]
|
2021-04-11 05:24:10 +08:00
|
|
|
envCython["LIBS"] = [os.path.basename(sysconfig.get_paths()['include'])]
|
2020-11-26 09:14:50 +08:00
|
|
|
else:
|
|
|
|
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
|
|
|
|
|
|
|
Export('envCython')
|
|
|
|
|
|
|
|
|
2019-11-21 08:32:42 +08:00
|
|
|
SConscript(['SConscript'])
|