Skip to content

Commit

Permalink
Set CFLAGS for Lua build if users don't have it. (GH-225)
Browse files Browse the repository at this point in the history
  • Loading branch information
wheybags authored Nov 16, 2022
1 parent 93c0bde commit a1383f3
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def use_bundled_luajit(path, macros):
print('Using bundled LuaJIT in %s' % libname)
print('Building LuaJIT for %r in %s' % (platform, libname))

build_env = dict(os.environ)
src_dir = os.path.join(path, "src")
if platform.startswith('win'):
build_script = [os.path.join(src_dir, "msvcbuild.bat"), "static"]
Expand All @@ -233,7 +234,13 @@ def use_bundled_luajit(path, macros):
build_script = ["make", "libluajit.a"]
lib_file = "libluajit.a"

output = subprocess.check_output(build_script, cwd=src_dir)
if 'CFLAGS' in build_env:
if "-fPIC" not in build_env['CFLAGS']:
build_env['CFLAGS'] += " -fPIC"
else:
build_env['CFLAGS'] = "-fPIC"

output = subprocess.check_output(build_script, cwd=src_dir, env=build_env)
if lib_file.encode("ascii") not in output:
print("Building LuaJIT did not report success:")
print(output.decode().strip())
Expand Down

0 comments on commit a1383f3

Please sign in to comment.