diff --git a/SConstruct b/SConstruct index e9f80b7d29..bc77fb25a3 100644 --- a/SConstruct +++ b/SConstruct @@ -2,9 +2,9 @@ import os import shutil import subprocess import sys +import sysconfig import platform import numpy as np -from sysconfig import get_paths TICI = os.path.isfile('/TICI') Decider('MD5-timestamp') @@ -124,10 +124,6 @@ else: # change pythonpath to this lenv["PYTHONPATH"] = Dir("#").path -#Get the path for Python.h for cython linking -python_path = get_paths()['include'] -numpy_path = np.get_include() - env = Environment( ENV=lenv, CCFLAGS=[ @@ -188,9 +184,13 @@ env = Environment( "#selfdrive/common", ], CYTHONCFILESUFFIX=".cpp", - tools=["default", "cython"] + COMPILATIONDB_USE_ABSPATH=True, + tools=["default", "cython", "compilation_db"], ) +if GetOption('test'): + env.CompilationDatabase('compile_commands.json') + if os.environ.get('SCONS_CACHE'): cache_dir = '/tmp/scons_cache' @@ -230,22 +230,20 @@ def abspath(x): # rpath works elsewhere return x[0].path.rsplit("/", 1)[1][:-3] -#Cython build enviroment +# Cython build enviroment +py_include = sysconfig.get_paths()['include'] envCython = env.Clone() -envCython["CPPPATH"] += [python_path, numpy_path] +envCython["CPPPATH"] += [py_include, np.get_include()] envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-deprecated-declarations"] -python_libs = [] +envCython["LIBS"] = [] if arch == "Darwin": - envCython["LINKFLAGS"]=["-bundle", "-undefined", "dynamic_lookup"] + envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] elif arch == "aarch64": - envCython["LINKFLAGS"]=["-shared"] - - python_libs.append(os.path.basename(python_path)) + envCython["LINKFLAGS"] = ["-shared"] + envCython["LIBS"] = os.path.basename(py_include) else: - envCython["LINKFLAGS"]=["-pthread", "-shared"] - -envCython["LIBS"] = python_libs + envCython["LINKFLAGS"] = ["-pthread", "-shared"] Export('envCython') @@ -306,3 +304,4 @@ if arch != "Darwin": if arch == "x86_64": SConscript(['tools/lib/index_log/SConscript']) +