Skip to content

Commit

Permalink
Refactor sconscripts to support target var
Browse files Browse the repository at this point in the history
  • Loading branch information
fredyshox committed Aug 2, 2023
1 parent 2689300 commit 7be901d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import('env', 'envCython', 'arch', 'common')
Import('env', 'envCython', 'target', 'common')

import shutil

Expand Down Expand Up @@ -51,7 +51,7 @@ vipc_sources = [
'visionipc/visionbuf.cc',
]

if arch == "larch64":
if target == "larch64":
vipc_sources += ['visionipc/visionbuf_ion.cc']
else:
vipc_sources += ['visionipc/visionbuf_cl.cc']
Expand All @@ -62,7 +62,7 @@ vipc = env.Library('visionipc', vipc_objects)

vipc_frameworks = []
vipc_libs = envCython["LIBS"] + [vipc, messaging_lib, common, "zmq"]
if arch == "Darwin":
if target == "Darwin":
vipc_frameworks.append('OpenCL')
else:
vipc_libs.append('OpenCL')
Expand Down
10 changes: 7 additions & 3 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import numpy as np

arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
if platform.system() == "Darwin":
arch = "Darwin"
target = "Darwin"
elif platform.system() == "Linux":
target = f"linux-{arch}"
else:
raise Exception("Unsupported platform: ", platform.system())

common = ''

Expand Down Expand Up @@ -69,13 +73,13 @@ env = Environment(
tools=["default", "cython"]
)

Export('env', 'arch', 'common')
Export('env', 'target', 'arch', 'common')

envCython = env.Clone(LIBS=[])
envCython["CPPPATH"] += [np.get_include()]
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
envCython["CCFLAGS"].remove('-Werror')
if arch == "Darwin":
if target == "Darwin":
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
else:
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
Expand Down

0 comments on commit 7be901d

Please sign in to comment.