mirror of
https://github.com/godotengine/gdnative-demos.git
synced 2025-12-30 21:49:05 +03:00
Refactor remaining C demos to match simple C demo
The projects don't work as of this commit, but are fixed in a later commit in the same PR.
This commit is contained in:
92
c/glfw/SConstruct
Normal file
92
c/glfw/SConstruct
Normal file
@@ -0,0 +1,92 @@
|
||||
#!python
|
||||
import os, subprocess
|
||||
|
||||
opts = Variables([], ARGUMENTS)
|
||||
|
||||
# Define the relative path to the Godot headers.
|
||||
godot_headers_path = "godot_headers/"
|
||||
|
||||
# Gets the standard flags CC, CCX, etc.
|
||||
env = DefaultEnvironment()
|
||||
env["STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME"] = 1
|
||||
|
||||
# Define our options. Use future-proofed names for platforms.
|
||||
platform_array = ["", "windows", "linuxbsd", "macos", "x11", "linux", "osx"]
|
||||
opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"]))
|
||||
opts.Add(EnumVariable("platform", "Compilation platform", "", platform_array))
|
||||
opts.Add(EnumVariable("p", "Alias for 'platform'", "", platform_array))
|
||||
opts.Add(BoolVariable("use_llvm", "Use the LLVM / Clang compiler", "no"))
|
||||
opts.Add(PathVariable("target_path", "The path where the lib is installed.", "project/gdnative/"))
|
||||
opts.Add(PathVariable("target_name", "The library name.", "libglfw", PathVariable.PathAccept))
|
||||
|
||||
# Only support 64-bit systems.
|
||||
bits = 64
|
||||
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
|
||||
# Process platform arguments.
|
||||
if env["p"] != "":
|
||||
env["platform"] = env["p"]
|
||||
|
||||
if env["platform"] == "osx":
|
||||
env["platform"] = "macos"
|
||||
elif env["platform"] in ("x11", "linux"):
|
||||
env["platform"] = "linuxbsd"
|
||||
|
||||
if env["platform"] == "":
|
||||
print("No valid target platform selected.")
|
||||
quit()
|
||||
|
||||
env["target_path"] += env["platform"] + "/"
|
||||
|
||||
# Process other arguments.
|
||||
if env["use_llvm"]:
|
||||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
# Check our platform specifics
|
||||
if env["platform"] == "macos":
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"])
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"])
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64"])
|
||||
|
||||
elif env["platform"] == "linuxbsd":
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-fPIC", "-g", "-O3"])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
# This makes sure to keep the session environment variables
|
||||
# on Windows, so that you can run scons in a VS 2017 prompt
|
||||
# and it will find all the required tools.
|
||||
env.Append(ENV=os.environ)
|
||||
|
||||
env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"])
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "-MDd"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"])
|
||||
|
||||
# Make sure our library includes the Godot headers.
|
||||
env.Append(CPPPATH=[".", godot_headers_path])
|
||||
|
||||
# Make sure our library looks in the target path for any other
|
||||
# libraries it may need. The path needs to be project-relative.
|
||||
env.Append(LINKFLAGS=["-Wl,-rpath,gdnative/" + env["platform"]])
|
||||
|
||||
# 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/*.c")
|
||||
|
||||
library = env.SharedLibrary(target=env["target_path"] + env["target_name"], source=sources)
|
||||
|
||||
Default(library)
|
||||
|
||||
# Generates help for the -h scons option.
|
||||
Help(opts.GenerateHelpText(env))
|
||||
2
c/glfw/project/gdnative/linuxbsd/.gitignore
vendored
Normal file
2
c/glfw/project/gdnative/linuxbsd/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
c/glfw/project/gdnative/macos/.gitignore
vendored
Normal file
2
c/glfw/project/gdnative/macos/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
c/glfw/project/gdnative/windows/.gitignore
vendored
Normal file
2
c/glfw/project/gdnative/windows/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
@@ -1,49 +1,92 @@
|
||||
#!python
|
||||
import os, subprocess
|
||||
|
||||
# Local dependency paths, adapt them to your setup
|
||||
godot_headers_path = ARGUMENTS.get("headers", os.getenv("GODOT_HEADERS", "../../../godot_headers/"))
|
||||
opts = Variables([], ARGUMENTS)
|
||||
|
||||
target = ARGUMENTS.get("target", "debug")
|
||||
# Define the relative path to the Godot headers.
|
||||
godot_headers_path = "godot_headers/"
|
||||
|
||||
# platform= makes it in line with Godots scons file, keeping p for backwards compatibility
|
||||
platform = ARGUMENTS.get("p", "linux")
|
||||
platform = ARGUMENTS.get("platform", platform)
|
||||
# Gets the standard flags CC, CCX, etc.
|
||||
env = DefaultEnvironment()
|
||||
env["STATIC_AND_SHARED_OBJECTS_ARE_THE_SAME"] = 1
|
||||
|
||||
# This makes sure to keep the session environment variables on windows,
|
||||
# that way you can run scons in a vs 2017 prompt and it will find all the required tools
|
||||
env = Environment()
|
||||
if platform == "windows":
|
||||
env = Environment(ENV=os.environ)
|
||||
# Define our options. Use future-proofed names for platforms.
|
||||
platform_array = ["", "windows", "linuxbsd", "macos", "x11", "linux", "osx"]
|
||||
opts.Add(EnumVariable("target", "Compilation target", "debug", ["d", "debug", "r", "release"]))
|
||||
opts.Add(EnumVariable("platform", "Compilation platform", "", platform_array))
|
||||
opts.Add(EnumVariable("p", "Alias for 'platform'", "", platform_array))
|
||||
opts.Add(BoolVariable("use_llvm", "Use the LLVM / Clang compiler", "no"))
|
||||
opts.Add(PathVariable("target_path", "The path where the lib is installed.", "project/gdnative/"))
|
||||
opts.Add(PathVariable("target_name", "The library name.", "libinstance_binding", PathVariable.PathAccept))
|
||||
|
||||
if ARGUMENTS.get("use_llvm", "no") == "yes":
|
||||
# Only support 64-bit systems.
|
||||
bits = 64
|
||||
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
|
||||
# Process platform arguments.
|
||||
if env["p"] != "":
|
||||
env["platform"] = env["p"]
|
||||
|
||||
if env["platform"] == "osx":
|
||||
env["platform"] = "macos"
|
||||
elif env["platform"] in ("x11", "linux"):
|
||||
env["platform"] = "linuxbsd"
|
||||
|
||||
if env["platform"] == "":
|
||||
print("No valid target platform selected.")
|
||||
quit()
|
||||
|
||||
env["target_path"] += env["platform"] + "/"
|
||||
|
||||
# Process other arguments.
|
||||
if env["use_llvm"]:
|
||||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
|
||||
def add_sources(sources, directory):
|
||||
for file in os.listdir(directory):
|
||||
if file.endswith(".c"):
|
||||
sources.append(directory + "/" + file)
|
||||
|
||||
|
||||
if platform == "osx":
|
||||
env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"])
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64"])
|
||||
|
||||
if platform == "linux":
|
||||
env.Append(CCFLAGS=["-fPIC", "-g", "-O3", "-std=c11"])
|
||||
|
||||
if platform == "windows":
|
||||
if target == "debug":
|
||||
env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "/MDd"])
|
||||
# Check our platform specifics
|
||||
if env["platform"] == "macos":
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-g", "-O2", "-arch", "x86_64"])
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "/MD"])
|
||||
env.Append(CCFLAGS=["-g", "-O3", "-arch", "x86_64"])
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64"])
|
||||
|
||||
# , 'include', 'include/core'
|
||||
elif env["platform"] == "linuxbsd":
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-fPIC", "-g3", "-Og"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-fPIC", "-g", "-O3"])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
# This makes sure to keep the session environment variables
|
||||
# on Windows, so that you can run scons in a VS 2017 prompt
|
||||
# and it will find all the required tools.
|
||||
env.Append(ENV=os.environ)
|
||||
|
||||
env.Append(CCFLAGS=["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS"])
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "-MDd"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"])
|
||||
|
||||
# Make sure our library includes the Godot headers.
|
||||
env.Append(CPPPATH=[".", godot_headers_path])
|
||||
|
||||
sources = []
|
||||
add_sources(sources, "src")
|
||||
# Make sure our library looks in the target path for any other
|
||||
# libraries it may need. The path needs to be project-relative.
|
||||
env.Append(LINKFLAGS=["-Wl,-rpath,gdnative/" + env["platform"]])
|
||||
|
||||
# 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/*.c")
|
||||
|
||||
library = env.SharedLibrary(target=env["target_path"] + env["target_name"], source=sources)
|
||||
|
||||
library = env.SharedLibrary(target="bin/instance_binding_demo", source=sources)
|
||||
Default(library)
|
||||
|
||||
# Generates help for the -h scons option.
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
||||
2
c/instance_binding/project/gdnative/linuxbsd/.gitignore
vendored
Normal file
2
c/instance_binding/project/gdnative/linuxbsd/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
c/instance_binding/project/gdnative/macos/.gitignore
vendored
Normal file
2
c/instance_binding/project/gdnative/macos/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
2
c/instance_binding/project/gdnative/windows/.gitignore
vendored
Normal file
2
c/instance_binding/project/gdnative/windows/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
*
|
||||
!.gitignore
|
||||
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
Reference in New Issue
Block a user