92 lines
3.5 KiB
Python
92 lines
3.5 KiB
Python
#!/usr/bin/env python
|
|
import os
|
|
import sys
|
|
import subprocess
|
|
|
|
env = SConscript("godot-cpp/SConstruct")
|
|
|
|
# For the reference:
|
|
# - CCFLAGS are compilation flags shared between C and C++
|
|
# - CFLAGS are for C-specific compilation flags
|
|
# - CXXFLAGS are for C++-specific compilation flags
|
|
# - CPPFLAGS are for pre-processor flags
|
|
# - CPPDEFINES are for pre-processor defines
|
|
# - LINKFLAGS are for linking flags
|
|
|
|
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
|
env.Append(CPPPATH=["src/"])
|
|
sources = Glob("src/*.cpp")
|
|
post_actions = []
|
|
library = None
|
|
|
|
if env["platform"] == "macos":
|
|
target = "demo/addons/godot_ultraleap_plugin/bin/libgdultraleap.{}.{}.framework/libgdultraleap.{}.{}".format(
|
|
env["platform"], env["target"], env["platform"], env["target"]
|
|
)
|
|
|
|
library = env.SharedLibrary(
|
|
target,
|
|
source=sources,
|
|
)
|
|
|
|
env.Append(LIBS=['LeapC'])
|
|
|
|
env.Append(LIBPATH = ["/Applications/Ultraleap Hand Tracking Service.app/Contents/LeapSDK/lib"])
|
|
env.Append(CPPPATH = ["/Applications/Ultraleap Hand Tracking Service.app/Contents/LeapSDK/include"])
|
|
|
|
def sys_exec(args):
|
|
proc = subprocess.Popen(args, stdout=subprocess.PIPE, text=True)
|
|
(out, err) = proc.communicate()
|
|
return out.rstrip("\r\n").lstrip()
|
|
|
|
def change_rpath(self, arg, env, executor = None):
|
|
sys_exec(["install_name_tool", "-change", "@rpath/%s" % "libLeapC.5.dylib", "@loader_path/../%s" % "libLeapC.5.dylib", target])
|
|
|
|
change_rpath_action = Action('', change_rpath)
|
|
|
|
AddPostAction(library, change_rpath_action)
|
|
elif env["platform"] == "windows":
|
|
library = env.SharedLibrary(
|
|
"demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
|
|
source=sources,
|
|
)
|
|
env.Append(LIBS=['LeapC'])
|
|
env.Append(LIBPATH = ['C:/Program Files/Ultraleap/LeapSDK/lib/x64'])
|
|
env.Append(CPPPATH = ["C:/Program Files/Ultraleap/LeapSDK/include"])
|
|
|
|
post_actions = [
|
|
Copy("demo/addons/godot_ultraleap_plugin/bin/LeapC.dll", "C:/Program Files/Ultraleap/LeapSDK/lib/x64/LeapC.dll")
|
|
]
|
|
elif env["platform"] == "android":
|
|
library = env.SharedLibrary(
|
|
"demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
|
|
source=sources,
|
|
)
|
|
env.Append(LIBS=['LeapC'])
|
|
env.Append(LIBPATH = ['./android'])
|
|
env.Append(CPPPATH = ["./android"])
|
|
|
|
post_actions = [
|
|
Mkdir("demo/android"),
|
|
Mkdir("demo/android/plugins"),
|
|
Mkdir("demo/android/plugins/ultraleap_binder"),
|
|
Copy("demo/android/plugins/UltraleapBinder.gdap", "godot-ultraleap-binder/UltraleapBinder.gdap"),
|
|
Copy("demo/android/plugins/ultraleap_binder/UltraleapTrackingServiceBinder.aar", "godot-ultraleap-binder/ultraleap-binder/libs/UltraleapTrackingServiceBinder.aar"),
|
|
Copy("demo/android/plugins/ultraleap_binder/ultraleap-binder-debug.aar", "godot-ultraleap-binder/ultraleap-binder/build/outputs/aar/ultraleap-binder-debug.aar"),
|
|
Copy("demo/addons/godot_ultraleap_plugin/bin/libLeapC.so", "android/libLeapC.so")
|
|
]
|
|
else:
|
|
library = env.SharedLibrary(
|
|
"demo/addons/godot_ultraleap_plugin/bin/libgdultraleap{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
|
|
source=sources,
|
|
)
|
|
env.Append(LIBS=['LeapC'])
|
|
env.Append(LIBPATH = ['/usr/lib/ultraleap-hand-tracking-service'])
|
|
|
|
if library is not None:
|
|
for post_action in post_actions:
|
|
AddPostAction(library, post_action)
|
|
|
|
Default(library)
|
|
else:
|
|
print("Nothing to build, weird") |