Skip to content

Commit ef24a36

Browse files
authored
Merge pull request #191 from Faless/build/openssl
[SCons] Build OpenSSL from source.
2 parents b8d79c3 + 955ec02 commit ef24a36

File tree

11 files changed

+314
-32
lines changed

11 files changed

+314
-32
lines changed

.gitignore

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,11 @@ extension_api.json
1717
# Mac stuff
1818
.DS_Store
1919

20+
# Vim
21+
*.swp
22+
2023
# Binaries
24+
__pycache__/
2125
build/
2226
bin/
2327
macos/
@@ -29,4 +33,4 @@ win64/
2933
*.os
3034
*.ilk
3135
*.pdb
32-
!thirdparty/openssl/*
36+
*.pyc

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,6 @@
99
[submodule "thirdparty/ssh2/libssh2"]
1010
path = thirdparty/ssh2/libssh2
1111
url = https://github.com/libssh2/libssh2
12+
[submodule "thirdparty/openssl"]
13+
path = thirdparty/openssl
14+
url = https://github.com/openssl/openssl

SConstruct

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,6 @@ opts.Add(PathVariable("target_path",
1414
"The path where the lib is installed.", "demo/addons/godot-git-plugin/"))
1515
opts.Add(PathVariable("target_name", "The library name.",
1616
"libgit_plugin", PathVariable.PathAccept))
17-
opts.Add(PathVariable("macos_openssl", "Path to OpenSSL library root - only used in macOS builds.",
18-
"/usr/local/opt/[email protected]/", PathVariable.PathAccept)) # TODO: Find a way to configure this to use the cloned OpenSSL source code, based on `macos_arch`.
19-
opts.Add(PathVariable("macos_openssl_static_ssl", "Path to OpenSSL libssl.a library - only used in macOS builds.",
20-
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libssl.a"), PathVariable.PathAccept))
21-
opts.Add(PathVariable("macos_openssl_static_crypto", "Path to OpenSSL libcrypto.a library - only used in macOS builds.",
22-
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libcrypto.a"), PathVariable.PathAccept))
23-
opts.Add(PathVariable("linux_openssl_static_ssl", "Path to OpenSSL libssl.a library - only used in Linux builds.",
24-
"/usr/lib/x86_64-linux-gnu/libssl.a", PathVariable.PathAccept))
25-
opts.Add(PathVariable("linux_openssl_static_crypto", "Path to OpenSSL libcrypto.a library - only used in Linux builds.",
26-
"/usr/lib/x86_64-linux-gnu/libcrypto.a", PathVariable.PathAccept))
2717

2818
# Updates the environment with the option variables.
2919
opts.Update(env)
@@ -33,8 +23,18 @@ if ARGUMENTS.get("custom_api_file", "") != "":
3323

3424
ARGUMENTS["target"] = "editor"
3525
env = SConscript("godot-cpp/SConstruct").Clone()
26+
27+
# OpenSSL Builder
28+
env.Tool("openssl", toolpath=["tools"])
29+
3630
opts.Update(env)
3731

32+
if env["platform"] != "windows": # Windows does not need OpenSSL
33+
ssl = env.OpenSSL()
34+
else:
35+
ssl = []
36+
37+
Export("ssl")
3838
Export("env")
3939

4040
SConscript("thirdparty/SCsub")

THIRDPARTY.md

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,7 @@ The Godot Git Plugin source code uses the following third-party source code:
55
1. godotengine/godot-cpp - MIT License - https://github.com/godotengine/godot-cpp/tree/02336831735fd6affbe0a6fa252ec98d3e78120c
66
2. libgit2/libgit2 - GPLv2 with a special Linking Exception - https://github.com/libgit2/libgit2/tree/b7bad55e4bb0a285b073ba5e02b01d3f522fc95d
77
3. libssh2/libssh2 - BSD-3-Clause License - https://github.com/libssh2/libssh2/tree/635caa90787220ac3773c1d5ba11f1236c22eae8
8-
9-
We also link to these third-party libraries (only in the compiled binary form):
10-
11-
1. OpenSSL - Only on Linux and MacOS - OpenSSL License - http://www.openssl.org/source/openssl-1.1.1s.tar.gz
8+
4. openssl (only on Linux and MacOS) - OpenSSL License - https://github.com/openssl/openssl/tree/26baecb28ce461696966dac9ac889629db0b3b96
129

1310
## License Texts
1411

godot-git-plugin/SCsub

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import os
44

55
env = {}
66
Import("env")
7+
Import("ssl")
78

89
# Process some arguments
910
if env["use_llvm"]:
@@ -24,8 +25,6 @@ if env["platform"] == "macos":
2425
env["target_path"] += "macos/"
2526

2627
# Force static linkage (https://stackoverflow.com/a/2995999/7370948)
27-
env.Append(LIBS=[File(env["macos_openssl_static_ssl"]),
28-
File(env["macos_openssl_static_crypto"])])
2928

3029
if env["macos_deployment_target"] != "default":
3130
env.Append(CCFLAGS=["-mmacosx-version-min=" +
@@ -35,8 +34,6 @@ if env["platform"] == "macos":
3534

3635
elif env["platform"] == "linux":
3736
env["target_path"] += "linux/"
38-
env.Append(LIBS=[File(env["linux_openssl_static_ssl"]),
39-
File(env["linux_openssl_static_crypto"])])
4037

4138
elif env["platform"] == "windows":
4239
env["target_path"] += "win64/"
@@ -50,9 +47,11 @@ env.Append(CPPPATH=["../thirdparty/git2/libgit2/include/"])
5047
env.Append(LIBPATH=["../thirdparty/bin/"])
5148
env.Prepend(LIBS=["git2", "ssh2"])
5249

50+
lib_sources = Glob("src/*.cpp")
51+
env.Depends(lib_sources, ssl)
5352
library = env.SharedLibrary(
5453
target=env["target_path"] +
5554
"{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
56-
source=Glob("src/*.cpp")
55+
source=lib_sources
5756
)
5857
Default(library)

thirdparty/git2/SCsub

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Adopted from https://github.com/goostengine/goost/blob/20d8ce4c7d74c26832d69283305b25a72165784a/modules/git/SCsub
44

55
Import("env")
6+
Import("ssl")
67

78
env_git = env.Clone()
89

@@ -125,11 +126,6 @@ if env_git["platform"] in ["linux", "macos"]:
125126
"UNICODE_BUILTIN"
126127
]
127128
)
128-
129-
if env_git["platform"] == "macos":
130-
env_git.Prepend(CPPPATH=[env_git["macos_openssl"] + "include/"])
131-
static_ssl = File(env_git["macos_openssl_static_ssl"])
132-
static_crypto = File(env_git["macos_openssl_static_crypto"])
133-
env_git.Append(LIBS=[static_ssl, static_crypto])
129+
env_git.Depends(libgit2_sources, ssl)
134130

135131
env_git.StaticLibrary(target="../bin/" + "git2", source=libgit2_sources)

thirdparty/openssl

Submodule openssl added at 2cf4e90

thirdparty/openssl/libcrypto.a

-7.86 MB
Binary file not shown.

thirdparty/openssl/libssl.a

-1.49 MB
Binary file not shown.

thirdparty/ssh2/SCsub

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Adopted from https://github.com/nodegit/nodegit/blob/4561dcb7c120474a4553baa27e4c4c2f4be23a2b/vendor/libgit2.gyp
44

55
Import("env")
6+
Import("ssl")
67

78
env_ssh2 = env.Clone()
89

@@ -104,11 +105,6 @@ if env_ssh2["platform"] in ["linux", "macos"]:
104105
("STDC_HEADERS", 1)
105106
]
106107
)
107-
108-
if env_ssh2["platform"] == "macos":
109-
env_ssh2.Append(CPPPATH=[env_ssh2["macos_openssl"] + "include/"])
110-
static_ssl = File(env_ssh2["macos_openssl_static_ssl"])
111-
static_crypto = File(env_ssh2["macos_openssl_static_crypto"])
112-
env_ssh2.Append(LIBS=[static_ssl, static_crypto])
108+
env_ssh2.Depends(libssh2_sources, ssl)
113109

114110
env_ssh2.StaticLibrary(target="../bin/" + "ssh2", source=libssh2_sources)

0 commit comments

Comments
 (0)