From 0967424cb0803033f70107535c182f94bd29c5fe Mon Sep 17 00:00:00 2001 From: Twarit Waikar Date: Mon, 11 Oct 2021 23:05:52 +0530 Subject: [PATCH] Add libssh2 to SCons build --- .gitmodules | 3 ++ godot-git-plugin/SCsub | 14 ++++---- thirdparty/SCsub | 1 + thirdparty/git2/SCsub | 10 ++++-- thirdparty/ssh2/SCsub | 76 +++++++++++++++++++++++++++++++++++++++++ thirdparty/ssh2/libssh2 | 1 + 6 files changed, 95 insertions(+), 10 deletions(-) create mode 100644 thirdparty/ssh2/SCsub create mode 160000 thirdparty/ssh2/libssh2 diff --git a/.gitmodules b/.gitmodules index 83fdcd7..b767d60 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ [submodule "libgit2"] path = thirdparty/git2/libgit2 url = https://github.com/libgit2/libgit2 +[submodule "thirdparty/ssh2/libssh2"] + path = thirdparty/ssh2/libssh2 + url = https://github.com/libssh2/libssh2 diff --git a/godot-git-plugin/SCsub b/godot-git-plugin/SCsub index ee8f73e..991d78f 100644 --- a/godot-git-plugin/SCsub +++ b/godot-git-plugin/SCsub @@ -41,7 +41,7 @@ if env["platform"] == "osx": elif env["platform"] in ("x11", "linux"): env["target_path"] += "x11/" cpp_library += ".linux" - env.Append(LIBS=["ssl", "crypto", "ssh2", "pcre"]) + env.Append(LIBS=["ssl"]) if env["target"] in ("debug", "d"): env.Append(CCFLAGS = ["-fPIC", "-g3","-Og", "-std=c++17"]) @@ -56,7 +56,7 @@ elif env["platform"] == "windows": env.Append(ENV = os.environ) env.Append(CCFLAGS = ["-DWIN32", "-D_WIN32", "-D_WINDOWS", "-W3", "-GR", "-D_CRT_SECURE_NO_WARNINGS", "/std:c++17"]) - env.Append(LIBS=["Advapi32", "Winhttp", "Rpcrt4", "crypt32", "OLE32"]) + env.Append(LIBS=["Advapi32", "Winhttp", "Rpcrt4", "crypt32", "OLE32", "user32"]) if env["target"] in ("debug", "d"): env.Append(CCFLAGS = ["-EHsc", "-D_DEBUG", "-MDd", "/DEBUG"]) env["PDB"] = env["target_name"] + ".pdb" @@ -73,11 +73,11 @@ if env["platform"] == "osx": else: cpp_library += "." + str(bits) -env.Append(CPPPATH=[".", "src/"]) -env.Append(CPPPATH=[godot_headers_path, cpp_bindings_path + "include/", cpp_bindings_path + "include/core/", cpp_bindings_path + "include/gen/"]) -env.Append(CPPPATH=["../thirdparty/git2/libgit2/include/"]) -env.Append(LIBPATH=[cpp_bindings_path + "bin/", "../thirdparty/bin/"]) -env.Append(LIBS=[cpp_library, "git2"]) +env.Append(CPPPATH = [".", "src/"]) +env.Append(CPPPATH = [godot_headers_path, cpp_bindings_path + "include/", cpp_bindings_path + "include/core/", cpp_bindings_path + "include/gen/"]) +env.Append(CPPPATH = ["../thirdparty/git2/libgit2/include/"]) +env.Append(LIBPATH = [cpp_bindings_path + "bin/", "../thirdparty/bin/"]) +env.Append(LIBS = [cpp_library, "git2", "ssh2"]) library = env.SharedLibrary( target = env["target_path"] + env["target_name"], diff --git a/thirdparty/SCsub b/thirdparty/SCsub index 9001a8b..405e14a 100644 --- a/thirdparty/SCsub +++ b/thirdparty/SCsub @@ -1,3 +1,4 @@ #!/usr/bin/env python +SConscript("ssh2/SCsub") SConscript("git2/SCsub") diff --git a/thirdparty/git2/SCsub b/thirdparty/git2/SCsub index 767deeb..afc84d2 100644 --- a/thirdparty/git2/SCsub +++ b/thirdparty/git2/SCsub @@ -42,14 +42,15 @@ env_git.Prepend( "libgit2/deps/http-parser/", "libgit2/deps/pcre/", "libgit2/deps/zlib/", + "../ssh2/libssh2/include/", ] ) env_git.Prepend( CPPDEFINES=[ "GIT_THREADS", - #"GIT_SSH", - #"GIT_SSH_MEMORY_CREDENTIALS", + "GIT_SSH", + "GIT_SSH_MEMORY_CREDENTIALS", "LIBGIT2_NO_FEATURES_H", "GIT_SHA1_COLLISIONDETECT", "GIT_HTTPS", @@ -83,6 +84,8 @@ if env_git["platform"] == "windows": "PCREGREP_BUFSIZE", ("MAX_NAME_SIZE", "32"), ("MAX_NAME_COUNT", "10000"), + "HAVE_WINCNG", + "LIBSSH2_WINCNG" ] ) @@ -116,5 +119,6 @@ if env_git["platform"] in ["x11", "osx"]: ] ) -env_git["PDB"] = "git2.pdb" +env.Append(LIBPATH=["../bin/"]) + env_git.StaticLibrary(target = "../bin/" + "git2", source = libgit2_sources) diff --git a/thirdparty/ssh2/SCsub b/thirdparty/ssh2/SCsub new file mode 100644 index 0000000..e4c4877 --- /dev/null +++ b/thirdparty/ssh2/SCsub @@ -0,0 +1,76 @@ +#!/usr/bin/env python + +# Adopted from https://github.com/nodegit/nodegit/blob/4561dcb7c120474a4553baa27e4c4c2f4be23a2b/vendor/libgit2.gyp + +Import("env") + +env_ssh2 = env.Clone() + +# Thirdparty source files. +libssh2_sources = [ + "libssh2/src/agent.c", + "libssh2/src/bcrypt_pbkdf.c", + "libssh2/src/blowfish.c", + "libssh2/src/crypt.c", + "libssh2/src/keepalive.c", + "libssh2/src/libgcrypt.c", + "libssh2/src/openssl.c", + "libssh2/src/publickey.c", + "libssh2/src/sftp.c", + "libssh2/src/version.c", + "libssh2/src/channel.c", + "libssh2/src/global.c", + "libssh2/src/kex.c", + "libssh2/src/mac.c", + "libssh2/src/packet.c", + "libssh2/src/scp.c", + "libssh2/src/transport.c", + "libssh2/src/comp.c", + "libssh2/src/hostkey.c", + "libssh2/src/knownhost.c", + "libssh2/src/misc.c", + "libssh2/src/pem.c", + "libssh2/src/session.c", + "libssh2/src/userauth.c", +] + +env_ssh2.Prepend( + CPPPATH=[ + "libssh2/include/" + "libssh2/src/" + ] +) + +env_ssh2.Prepend( + CPPDEFINES=[ + ] +) + +if env_ssh2["platform"] == "windows": + env_ssh2.Append( + CPPPATH=[ + "libssh2/include/", + "libssh2/win32/" + ] + ) + libssh2_sources += [ "libssh2/src/agent_win.c", "libssh2/src/wincng.c"] + env_ssh2.Append( + CPPDEFINES=[ + "LIBSSH2_WINCNG", + "HAVE_WINCNG" + ] + ) + env_ssh2.Append(LIBS = ["crypt32", "user32"]) + +if env_ssh2["platform"] == "osx": + env_ssh2.Append( + CPPPATH=[ + "libssh2/os400/" + ] + ) + libssh2_sources += ["libssh2/os400/" + "*.c"] + env_ssh2.Append( + CPPDEFINES=[] + ) + +env_ssh2.StaticLibrary(target = "../bin/" + "ssh2", source = libssh2_sources) diff --git a/thirdparty/ssh2/libssh2 b/thirdparty/ssh2/libssh2 new file mode 160000 index 0000000..635caa9 --- /dev/null +++ b/thirdparty/ssh2/libssh2 @@ -0,0 +1 @@ +Subproject commit 635caa90787220ac3773c1d5ba11f1236c22eae8