-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathSConstruct
More file actions
119 lines (105 loc) · 3.71 KB
/
SConstruct
File metadata and controls
119 lines (105 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
#!/usr/bin/env python
from glob import glob
from pathlib import Path
import os
env = SConscript("thirdparty/godot-cpp/SConstruct")
opts = Variables('custom.py', ARGUMENTS)
opts.Add(PathVariable("meta_headers", "Path to the directory containing Meta OpenXR preview headers", None))
opts.Update(env)
# Add common includes
env.Append(CPPPATH=[
"#plugin/src/main/cpp/include/",
"#thirdparty/openxr/include/",
"#thirdparty/androidxr/include/",
])
# Include Meta OpenXR preview headers if provided
meta_headers = env.get("meta_headers")
if meta_headers:
meta_headers = os.path.normpath(meta_headers)
if os.path.basename(meta_headers) == "meta_openxr_preview":
meta_headers = os.path.dirname(meta_headers)
env.Append(CPPDEFINES=["META_HEADERS_ENABLED"])
env.Append(CPPPATH=[meta_headers])
sources = []
sources += Glob("#plugin/src/main/cpp/*.cpp")
sources += Glob("#plugin/src/main/cpp/export/*.cpp")
sources += Glob("#plugin/src/main/cpp/extensions/*.cpp")
sources += Glob("#plugin/src/main/cpp/classes/*.cpp")
sources += Glob("#plugin/src/main/cpp/editor/*.cpp")
if env["target"] in ["editor", "template_debug"]:
doc_data = env.GodotCPPDocData("#plugin/src/gen/doc_data.gen.cpp", source=Glob("doc_classes/*.xml"))
sources.append(doc_data)
binary_path = '#demo/addons/godotopenxrvendors/.bin'
android_src_path = '#plugin/src'
project_name = 'godotopenxrvendors'
from build_raw_headers import build_raw_headers_action
env.Append(
BUILDERS={
"RawHeaders": Builder(action=build_raw_headers_action),
})
raw_headers = env.RawHeaders(
target=[
'#plugin/src/main/cpp/include/raw_headers/mr_startup.tscn.gen.h',
'#plugin/src/main/cpp/include/raw_headers/start_mr.gd.gen.h',
'#plugin/src/main/cpp/include/raw_headers/start_vr.gd.gen.h',
'#plugin/src/main/cpp/include/raw_headers/vr_startup.tscn.gen.h',
],
source=[
'#plugin/src/main/cpp/include/raw_headers/mr_startup.tscn',
'#plugin/src/main/cpp/include/raw_headers/start_mr.gd',
'#plugin/src/main/cpp/include/raw_headers/start_vr.gd',
'#plugin/src/main/cpp/include/raw_headers/vr_startup.tscn',
],
)
# Statically link with libgcc and libstdc++ for wider compatibility on Linux and Android.
if env["platform"] in ["linux", "android"]:
env.Append(
LINKFLAGS=[
"-Wl,--no-undefined",
"-static-libgcc",
"-static-libstdc++",
]
)
# Create the library target
if env["platform"] == "macos":
library = env.SharedLibrary(
"{0}/{1}/{2}/lib{3}.{1}.framework/{3}.{1}".format(
binary_path,
env["platform"],
env["target"],
project_name,
),
source=sources,
)
else:
library = env.SharedLibrary(
"{}/{}/{}/{}/lib{}{}".format(
binary_path,
env["platform"],
env["target"],
env["arch"],
project_name,
env["SHLIBSUFFIX"],
),
source=sources,
)
env.Depends(library, raw_headers)
Default(library)
if env["platform"] == "android":
android_target = "release" if env["target"] == "template_release" else "debug"
android_arch = ""
if env["arch"] == "arm64":
android_arch = "arm64-v8a"
elif env["arch"] == "x86_64":
android_arch = "x86_64"
else:
raise Exception("Unable to map %s to Android architecture name" % env["arch"])
library_copy_path = "{}/main/libs/{}/{}/{}/lib{}{}".format(
android_src_path,
android_target,
android_arch,
android_arch,
project_name,
env["SHLIBSUFFIX"])
library_copy = env.Command(library_copy_path, library, Copy('$TARGET', '$SOURCE'))
Default(library_copy)