Commit 6d2e26dd authored by qinsoon's avatar qinsoon

allow using release build

parent 7c33f99b
...@@ -17,7 +17,12 @@ elif sys.platform.startswith('linux'): ...@@ -17,7 +17,12 @@ elif sys.platform.startswith('linux'):
libext = '.so' libext = '.so'
else: else:
libext = '.dll' libext = '.dll'
libmu_path = proj_dir.join('target', 'debug', 'libmu' + libext)
libmu_build = os.environ.get('ZEBU_BUILD', 'debug')
libmu_dir_path = proj_dir.join('target', libmu_build)
libmu_dylib_path = proj_dir.join('target', libmu_build, 'libmu' + libext)
libmu_staticlib_path = proj_dir.join('target', libmu_build, 'libmu.a')
def mu_instance_via_ctyeps(): def mu_instance_via_ctyeps():
...@@ -46,7 +51,7 @@ def compile_c_script(c_src_name): ...@@ -46,7 +51,7 @@ def compile_c_script(c_src_name):
CFLAGS = [ CFLAGS = [
"-std=c11", "-std=c11",
"-I%(proj_dir)s/src/vm/api" % globals(), "-I%(proj_dir)s/src/vm/api" % globals(),
"-L" + libmu_path.dirname, "-L" + libmu_dir_path.strpath,
"-lmu" "-lmu"
] ]
cmd = [CC] + CFLAGS + ['-o', bin_path.strpath] + [src_c.strpath] cmd = [CC] + CFLAGS + ['-o', bin_path.strpath] + [src_c.strpath]
...@@ -59,7 +64,7 @@ def compile_c_script(c_src_name): ...@@ -59,7 +64,7 @@ def compile_c_script(c_src_name):
sys.stderr.write(err + '\n') sys.stderr.write(err + '\n')
raise subp.CalledProcessError(p.returncode, cmd) raise subp.CalledProcessError(p.returncode, cmd)
os.environ['LD_LIBRARY_PATH'] = "%s:%s" % ("%(proj_dir)s/target/debug" % globals(), os.environ['LD_LIBRARY_PATH'] = "%s:%s" % (libmu_dir_path.strpath,
os.environ['LD_LIBRARY_PATH'] if 'LD_LIBRARY_PATH' in os.environ else "") os.environ['LD_LIBRARY_PATH'] if 'LD_LIBRARY_PATH' in os.environ else "")
# run # run
p = subp.Popen([bin_path.strpath], stdout=subp.PIPE, stderr=subp.PIPE, env=os.environ) p = subp.Popen([bin_path.strpath], stdout=subp.PIPE, stderr=subp.PIPE, env=os.environ)
...@@ -139,7 +144,7 @@ def fncptr_from_py_script(py_fnc, heapinit_fnc, name, argtypes=[], restype=ctype ...@@ -139,7 +144,7 @@ def fncptr_from_py_script(py_fnc, heapinit_fnc, name, argtypes=[], restype=ctype
def preload_libmu(): def preload_libmu():
# load libmu before rffi so to load it with RTLD_GLOBAL # load libmu before rffi so to load it with RTLD_GLOBAL
return ctypes.CDLL(libmu_path.strpath, ctypes.RTLD_GLOBAL) return ctypes.CDLL(libmu_dylib_path.strpath, ctypes.RTLD_GLOBAL)
spawn_proc = bool(int(os.environ.get('SPAWN_PROC', '1'))) spawn_proc = bool(int(os.environ.get('SPAWN_PROC', '1')))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment