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 7d0841d commit a1276e9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
import os
import platform
import subprocess
import sysconfig
import numpy as np

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

common = ''

Expand Down Expand Up @@ -44,11 +51,8 @@ envCython = env.Clone()
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]

envCython["LIBS"] = []
if arch == "Darwin":
if target == "Darwin":
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"]
elif arch == "aarch64":
envCython["LINKFLAGS"] = ["-shared"]
envCython["LIBS"] = [os.path.basename(python_path)]
else:
envCython["LINKFLAGS"] = ["-pthread", "-shared"]

Expand All @@ -64,5 +68,5 @@ rednose_config = {
},
}

Export('env', 'envCython', 'arch', 'rednose_config', 'common')
Export('env', 'envCython', 'rednose_config', 'common')
SConscript(['#rednose/SConscript'])
2 changes: 1 addition & 1 deletion rednose/SConscript
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Import('env', 'envCython', 'arch', 'rednose_config', 'common')
Import('env', 'envCython', 'rednose_config', 'common')

generated_folder = rednose_config['generated_folder']

Expand Down

0 comments on commit a1276e9

Please sign in to comment.