Skip to content

Commit 296b298

Browse files
committed
Refactor build system, move src folder to top level
1 parent da656d6 commit 296b298

22 files changed

Lines changed: 65 additions & 90 deletions

.github/workflows/clang-format.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,6 @@ jobs:
1010
- uses: actions/checkout@v4
1111
- uses: DoozyX/clang-format-lint-action@v0.18.2
1212
with:
13-
source: "godot-git-plugin/src"
13+
source: "src"
1414
extensions: "h,cpp"
1515
clangFormatVersion: 18

.gitignore

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ extension_api.json
1919

2020
# Binaries
2121
__pycache__/
22-
build/
23-
bin/
24-
macos/
25-
linux/
26-
win64/
22+
/bin/
2723
*.lib
2824
*.a
2925
*.obj

.gitmodules

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
path = godot-cpp
33
url = https://github.com/godotengine/godot-cpp
44
[submodule "thirdparty/git2/libgit2"]
5-
path = thirdparty/git2/libgit2
6-
url = https://github.com/libgit2/libgit2
5+
path = thirdparty/libgit2
6+
url = https://github.com/libgit2/libgit2.git
77
ignore = untracked
88
[submodule "thirdparty/ssh2/libssh2"]
9-
path = thirdparty/ssh2/libssh2
10-
url = https://github.com/libssh2/libssh2
9+
path = thirdparty/libssh2
10+
url = https://github.com/libssh2/libssh2.git
1111
[submodule "thirdparty/mbedtls"]
1212
path = thirdparty/mbedtls
1313
url = https://github.com/Mbed-TLS/mbedtls.git

SConstruct

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,12 @@
22

33
import os
44

5-
EnsureSConsVersion(3, 1, 2)
6-
EnsurePythonVersion(3, 6)
5+
EnsureSConsVersion(3, 0, 0)
6+
EnsurePythonVersion(3, 5)
77

88
opts = Variables([], ARGUMENTS)
99

10-
env = Environment(ENV=os.environ)
11-
12-
# Define our options
13-
opts.Add(PathVariable("target_path",
14-
"The path where the lib is installed.", "addons/godot-git-plugin/"))
15-
opts.Add(PathVariable("target_name", "The library name.",
16-
"libgit_plugin", PathVariable.PathAccept))
10+
env = Environment()
1711

1812
# Updates the environment with the option variables.
1913
opts.Update(env)
@@ -23,28 +17,36 @@ if ARGUMENTS.get("custom_api_file", "") != "":
2317

2418
ARGUMENTS["target"] = "editor"
2519
env = SConscript("godot-cpp/SConstruct").Clone()
26-
env.PrependENVPath("PATH", os.getenv("PATH")) # Prepend PATH, done upstream in recent godot-cpp verions.
2720

28-
# Force linking with LTO on windows MSVC, silence the linker complaining that libgit uses LTO but we are not linking with it.
21+
# Prepend PATH to allow using custom toolchains, done upstream in recent godot-cpp verions.
22+
env.PrependENVPath("PATH", os.getenv("PATH"))
23+
2924
if env["platform"] == "windows" and env.get("is_msvc", False):
25+
# Force linking with LTO on windows MSVC, silence the linker complaining that libgit uses LTO but we are not linking with it.
3026
env.AppendUnique(LINKFLAGS=["/LTCG"])
27+
# Do not treat empty pdb as errors.
28+
env.AppendUnique(LINKFLAGS=["/IGNORE:4099"])
3129

3230
env.Tool("cmake", toolpath=["tools"])
3331
env.Tool("mbedtls", toolpath=["tools"])
3432
env.Tool("ssh2", toolpath=["tools"])
3533
env.Tool("git2", toolpath=["tools"])
3634

37-
opts.Update(env)
38-
3935
mbedtls = env.BuildMbedTLS()
4036
ssh2 = env.BuildSSH2(mbedtls)
4137
mbedtls += ssh2
4238
git2 = env.BuildGIT2(mbedtls)
4339

44-
Export("mbedtls")
45-
Export("env")
40+
env.Append(CPPPATH=[".", "src/"])
41+
env.Append(CPPPATH=["#thirdparty/git2/libgit2/include/"])
42+
43+
lib_sources = Glob("src/*.cpp")
44+
env.Depends(lib_sources, mbedtls)
4645

47-
SConscript("godot-git-plugin/SCsub")
46+
library = env.SharedLibrary(
47+
target="bin/addons/godot-git-plugin/lib/libgit_plugin{}{}".format(env["suffix"], env["SHLIBSUFFIX"]),
48+
source=lib_sources
49+
)
50+
extension = env.InstallAs("bin/addons/godot-git-plugin/git_plugin.gdextension", "misc/git_plugin.gdextension")
4851

49-
# Generates help for the -h scons option.
50-
Help(opts.GenerateHelpText(env))
52+
Default(library + extension)

addons/godot-git-plugin/git_plugin.gdextension

Lines changed: 0 additions & 10 deletions
This file was deleted.
File renamed without changes.

godot-git-plugin/SCsub

Lines changed: 0 additions & 38 deletions
This file was deleted.

misc/git_plugin.gdextension

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[configuration]
2+
3+
entry_symbol = "git_plugin_init"
4+
compatibility_minimum = "4.1.0"
5+
6+
[libraries]
7+
8+
macos.editor = "lib/libgit_plugin.macos.editor.universal.dylib"
9+
windows.editor.x86_32 = "lib/libgit_plugin.windows.editor.x86_32.dll"
10+
windows.editor.x86_64 = "lib/libgit_plugin.windows.editor.x86_64.dll"
11+
windows.editor.arm64 = "lib/libgit_plugin.windows.editor.arm64.dll"
12+
linux.editor.x86_32 = "lib/libgit_plugin.linux.editor.x86_32.so"
13+
linux.editor.x86_64 = "lib/libgit_plugin.linux.editor.x86_64.so"
14+
linux.editor.arm32 = "lib/libgit_plugin.linux.editor.arm32.so"
15+
linux.editor.arm64 = "lib/libgit_plugin.linux.editor.arm64.so"
16+
linux.editor.rv64 = ""

0 commit comments

Comments
 (0)