2019-12-04 02:45:33 +08:00
|
|
|
import os
|
|
|
|
import subprocess
|
2020-11-27 08:11:23 +08:00
|
|
|
import sysconfig
|
2024-11-22 06:16:17 +08:00
|
|
|
import platform
|
2021-08-31 08:53:14 +08:00
|
|
|
import numpy as np
|
2019-12-04 02:45:33 +08:00
|
|
|
|
|
|
|
arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
2024-11-22 06:16:17 +08:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
arch = "Darwin"
|
2019-12-04 02:45:33 +08:00
|
|
|
|
2020-11-27 08:11:23 +08:00
|
|
|
python_path = sysconfig.get_paths()['include']
|
2019-12-04 02:45:33 +08:00
|
|
|
cpppath = [
|
2020-11-27 08:11:23 +08:00
|
|
|
'#',
|
|
|
|
'/usr/lib/include',
|
|
|
|
python_path
|
2019-12-04 02:45:33 +08:00
|
|
|
]
|
|
|
|
|
2023-08-25 05:04:09 +08:00
|
|
|
AddOption('--minimal',
|
|
|
|
action='store_false',
|
|
|
|
dest='extras',
|
|
|
|
default=True,
|
|
|
|
help='the minimum build. no tests, tools, etc.')
|
2019-12-04 02:45:33 +08:00
|
|
|
|
|
|
|
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,
|
2024-08-18 03:04:46 +08:00
|
|
|
CC='gcc',
|
|
|
|
CXX='g++',
|
2019-12-04 02:45:33 +08:00
|
|
|
CCFLAGS=[
|
|
|
|
"-g",
|
|
|
|
"-fPIC",
|
|
|
|
"-O2",
|
2020-07-08 15:39:35 +08:00
|
|
|
"-Wunused",
|
2020-06-28 08:43:51 +08:00
|
|
|
"-Werror",
|
2021-11-02 21:40:00 +08:00
|
|
|
"-Wshadow",
|
2024-04-29 05:04:59 +08:00
|
|
|
"-Wno-vla-cxx-extension",
|
2024-08-18 03:04:46 +08:00
|
|
|
"-Wno-unknown-warning-option", # for compatibility across compiler versions
|
2019-12-04 02:45:33 +08:00
|
|
|
] + ccflags_asan,
|
|
|
|
LDFLAGS=ldflags_asan,
|
|
|
|
LINKFLAGS=ldflags_asan,
|
2020-11-27 08:11:23 +08:00
|
|
|
LIBPATH=[
|
|
|
|
"#opendbc/can/",
|
|
|
|
],
|
2019-12-04 02:45:33 +08:00
|
|
|
CFLAGS="-std=gnu11",
|
2022-05-13 08:59:33 +08:00
|
|
|
CXXFLAGS=["-std=c++1z"],
|
2019-12-04 02:45:33 +08:00
|
|
|
CPPPATH=cpppath,
|
2020-11-27 08:11:23 +08:00
|
|
|
CYTHONCFILESUFFIX=".cpp",
|
|
|
|
tools=["default", "cython"]
|
2019-12-04 02:45:33 +08:00
|
|
|
)
|
|
|
|
|
2021-08-31 08:53:14 +08:00
|
|
|
common = ''
|
2024-08-18 03:04:46 +08:00
|
|
|
Export('env', 'arch', 'common')
|
2019-12-04 02:45:33 +08:00
|
|
|
|
2020-11-27 08:11:23 +08:00
|
|
|
envCython = env.Clone()
|
2021-08-31 08:53:14 +08:00
|
|
|
envCython["CPPPATH"] += [np.get_include()]
|
2021-11-02 21:40:00 +08:00
|
|
|
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
|
2023-07-19 05:06:53 +08:00
|
|
|
envCython["CCFLAGS"].remove("-Werror")
|
2020-11-27 08:11:23 +08:00
|
|
|
|
|
|
|
python_libs = []
|
|
|
|
if arch == "Darwin":
|
|
|
|
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
|
|
|
|
elif arch == "aarch64":
|
|
|
|
envCython["LINKFLAGS"] = ["-shared"]
|
|
|
|
|
|
|
|
python_libs.append(os.path.basename(python_path))
|
|
|
|
else:
|
|
|
|
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
|
|
|
|
|
|
|
envCython["LIBS"] = python_libs
|
|
|
|
|
|
|
|
Export('envCython')
|
|
|
|
|
2024-11-22 06:16:17 +08:00
|
|
|
SConscript(['opendbc/can/SConscript'])
|