|
@@ -144,6 +144,9 @@ opts.Add(
|
|
)
|
|
)
|
|
opts.Add(BoolVariable("generate_template_get_node", "Generate a template version of the Node class's get_node.", True))
|
|
opts.Add(BoolVariable("generate_template_get_node", "Generate a template version of the Node class's get_node.", True))
|
|
|
|
|
|
|
|
+opts.Add(BoolVariable("build_library", "Build the godot-cpp library.", True))
|
|
|
|
+opts.Add("build_projects", "List of projects to build (comma-separated list of paths).", "")
|
|
|
|
+
|
|
opts.Update(env)
|
|
opts.Update(env)
|
|
Help(opts.GenerateHelpText(env))
|
|
Help(opts.GenerateHelpText(env))
|
|
|
|
|
|
@@ -165,6 +168,13 @@ if host_platform == "windows" and env["platform"] != "android":
|
|
|
|
|
|
opts.Update(env)
|
|
opts.Update(env)
|
|
|
|
|
|
|
|
+# Require C++17
|
|
|
|
+if host_platform == "windows" and env["platform"] == "windows" and not env["use_mingw"]:
|
|
|
|
+ # MSVC
|
|
|
|
+ env.Append(CCFLAGS=["/std:c++17"])
|
|
|
|
+else:
|
|
|
|
+ env.Append(CCFLAGS=["-std=c++17"])
|
|
|
|
+
|
|
if env["target"] == "debug":
|
|
if env["target"] == "debug":
|
|
env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_METHODS_ENABLED"])
|
|
env.Append(CPPDEFINES=["DEBUG_ENABLED", "DEBUG_METHODS_ENABLED"])
|
|
|
|
|
|
@@ -172,7 +182,7 @@ if env["platform"] == "linux" or env["platform"] == "freebsd":
|
|
if env["use_llvm"]:
|
|
if env["use_llvm"]:
|
|
env["CXX"] = "clang++"
|
|
env["CXX"] = "clang++"
|
|
|
|
|
|
- env.Append(CCFLAGS=["-fPIC", "-std=c++17", "-Wwrite-strings"])
|
|
|
|
|
|
+ env.Append(CCFLAGS=["-fPIC", "-Wwrite-strings"])
|
|
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
|
|
env.Append(LINKFLAGS=["-Wl,-R,'$$ORIGIN'"])
|
|
|
|
|
|
if env["target"] == "debug":
|
|
if env["target"] == "debug":
|
|
@@ -201,8 +211,6 @@ elif env["platform"] == "osx":
|
|
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
|
|
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
|
|
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
|
|
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
|
|
|
|
|
|
- env.Append(CCFLAGS=["-std=c++17"])
|
|
|
|
-
|
|
|
|
if env["macos_deployment_target"] != "default":
|
|
if env["macos_deployment_target"] != "default":
|
|
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
|
env.Append(CCFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
|
env.Append(LINKFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
|
env.Append(LINKFLAGS=["-mmacosx-version-min=" + env["macos_deployment_target"]])
|
|
@@ -245,14 +253,13 @@ elif env["platform"] == "ios":
|
|
env["CXX"] = compiler_path + "clang++"
|
|
env["CXX"] = compiler_path + "clang++"
|
|
env["AR"] = compiler_path + "ar"
|
|
env["AR"] = compiler_path + "ar"
|
|
env["RANLIB"] = compiler_path + "ranlib"
|
|
env["RANLIB"] = compiler_path + "ranlib"
|
|
|
|
+ env["SHLIBSUFFIX"] = ".dylib"
|
|
|
|
|
|
- env.Append(CCFLAGS=["-std=c++17", "-arch", env["ios_arch"], "-isysroot", sdk_path])
|
|
|
|
|
|
+ env.Append(CCFLAGS=["-arch", env["ios_arch"], "-isysroot", sdk_path])
|
|
env.Append(
|
|
env.Append(
|
|
LINKFLAGS=[
|
|
LINKFLAGS=[
|
|
"-arch",
|
|
"-arch",
|
|
env["ios_arch"],
|
|
env["ios_arch"],
|
|
- "-framework",
|
|
|
|
- "Cocoa",
|
|
|
|
"-Wl,-undefined,dynamic_lookup",
|
|
"-Wl,-undefined,dynamic_lookup",
|
|
"-isysroot",
|
|
"-isysroot",
|
|
sdk_path,
|
|
sdk_path,
|
|
@@ -292,14 +299,21 @@ elif env["platform"] == "windows":
|
|
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
|
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
|
env = Environment(ENV=os.environ, tools=["mingw"])
|
|
env = Environment(ENV=os.environ, tools=["mingw"])
|
|
opts.Update(env)
|
|
opts.Update(env)
|
|
- # env = env.Clone(tools=['mingw'])
|
|
|
|
|
|
|
|
|
|
+ # Still need to use C++17.
|
|
|
|
+ env.Append(CCFLAGS=["-std=c++17"])
|
|
|
|
+ # Don't want lib prefixes
|
|
|
|
+ env["IMPLIBPREFIX"] = ""
|
|
|
|
+ env["SHLIBPREFIX"] = ""
|
|
|
|
+
|
|
|
|
+ # Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other).
|
|
env["SPAWN"] = mySpawn
|
|
env["SPAWN"] = mySpawn
|
|
|
|
+ env.Replace(ARFLAGS=["q"])
|
|
|
|
|
|
# Native or cross-compilation using MinGW
|
|
# Native or cross-compilation using MinGW
|
|
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
|
|
if host_platform == "linux" or host_platform == "freebsd" or host_platform == "osx" or env["use_mingw"]:
|
|
# These options are for a release build even using target=debug
|
|
# These options are for a release build even using target=debug
|
|
- env.Append(CCFLAGS=["-O3", "-std=c++17", "-Wwrite-strings"])
|
|
|
|
|
|
+ env.Append(CCFLAGS=["-O3", "-Wwrite-strings"])
|
|
env.Append(
|
|
env.Append(
|
|
LINKFLAGS=[
|
|
LINKFLAGS=[
|
|
"--static",
|
|
"--static",
|
|
@@ -314,9 +328,10 @@ elif env["platform"] == "android":
|
|
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
|
# Don't Clone the environment. Because otherwise, SCons will pick up msvc stuff.
|
|
env = Environment(ENV=os.environ, tools=["mingw"])
|
|
env = Environment(ENV=os.environ, tools=["mingw"])
|
|
opts.Update(env)
|
|
opts.Update(env)
|
|
- # env = env.Clone(tools=['mingw'])
|
|
|
|
|
|
|
|
|
|
+ # Long line hack. Use custom spawn, quick AR append (to avoid files with the same names to override each other).
|
|
env["SPAWN"] = mySpawn
|
|
env["SPAWN"] = mySpawn
|
|
|
|
+ env.Replace(ARFLAGS=["q"])
|
|
|
|
|
|
# Verify NDK root
|
|
# Verify NDK root
|
|
if not "ANDROID_NDK_ROOT" in env:
|
|
if not "ANDROID_NDK_ROOT" in env:
|
|
@@ -382,11 +397,13 @@ elif env["platform"] == "android":
|
|
env["CC"] = toolchain + "/bin/clang"
|
|
env["CC"] = toolchain + "/bin/clang"
|
|
env["CXX"] = toolchain + "/bin/clang++"
|
|
env["CXX"] = toolchain + "/bin/clang++"
|
|
env["AR"] = toolchain + "/bin/" + arch_info["tool_path"] + "-ar"
|
|
env["AR"] = toolchain + "/bin/" + arch_info["tool_path"] + "-ar"
|
|
|
|
+ env["SHLIBSUFFIX"] = ".so"
|
|
|
|
|
|
env.Append(
|
|
env.Append(
|
|
CCFLAGS=["--target=" + arch_info["target"] + env["android_api_level"], "-march=" + arch_info["march"], "-fPIC"]
|
|
CCFLAGS=["--target=" + arch_info["target"] + env["android_api_level"], "-march=" + arch_info["march"], "-fPIC"]
|
|
) # , '-fPIE', '-fno-addrsig', '-Oz'])
|
|
) # , '-fPIE', '-fno-addrsig', '-Oz'])
|
|
env.Append(CCFLAGS=arch_info["ccflags"])
|
|
env.Append(CCFLAGS=arch_info["ccflags"])
|
|
|
|
+ env.Append(LINKFLAGS=["--target=" + arch_info["target"] + env["android_api_level"], "-march=" + arch_info["march"]])
|
|
|
|
|
|
if env["target"] == "debug":
|
|
if env["target"] == "debug":
|
|
env.Append(CCFLAGS=["-Og", "-g"])
|
|
env.Append(CCFLAGS=["-Og", "-g"])
|
|
@@ -474,8 +491,16 @@ elif env["platform"] == "javascript":
|
|
elif env["platform"] == "osx":
|
|
elif env["platform"] == "osx":
|
|
arch_suffix = env["macos_arch"]
|
|
arch_suffix = env["macos_arch"]
|
|
|
|
|
|
-library = env.StaticLibrary(
|
|
|
|
- target="bin/" + "libgodot-cpp.{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["LIBSUFFIX"]),
|
|
|
|
- source=sources,
|
|
|
|
-)
|
|
|
|
-Default(library)
|
|
|
|
|
|
+library = None
|
|
|
|
+env["OBJSUFFIX"] = ".{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["OBJSUFFIX"])
|
|
|
|
+library_name = "libgodot-cpp.{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["LIBSUFFIX"])
|
|
|
|
+
|
|
|
|
+if env["build_library"]:
|
|
|
|
+ library = env.StaticLibrary(target=env.File("bin/%s" % library_name), source=sources)
|
|
|
|
+ Default(library)
|
|
|
|
+
|
|
|
|
+env["SHLIBSUFFIX"] = "{}.{}.{}{}".format(env["platform"], env["target"], arch_suffix, env["SHLIBSUFFIX"])
|
|
|
|
+env.Append(CPPPATH=[env.Dir(f) for f in ["gen/include", "include", "godot-headers"]])
|
|
|
|
+env.Append(LIBPATH=[env.Dir("bin")])
|
|
|
|
+env.Append(LIBS=library_name)
|
|
|
|
+Return("env")
|