mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-06 02:09:44 +03:00
Update to Godot 4.0 beta9.
Simplify build system.
This commit is contained in:
18
.github/workflows/build.yml
vendored
18
.github/workflows/build.yml
vendored
@@ -7,15 +7,15 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-linux-release-x64
|
||||
- name: build-linux-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=linux target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=extension_api.ci.json -j $(nproc)
|
||||
scons platform=linux bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes -j $(nproc)
|
||||
ldd demo/addons/godot-git-plugin/linux/*.so
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.linux.x86_64.release.dll-${{ github.sha }}
|
||||
name: libgit_plugin.linux.x86_64.editor.dll-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
@@ -29,15 +29,15 @@ jobs:
|
||||
python-version: "3.x"
|
||||
architecture: "x64"
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-release-x64
|
||||
- name: build-windows-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=windows target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=extension_api.ci.json -j $env:NUMBER_OF_PROCESSORS
|
||||
scons platform=windows bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes -j $env:NUMBER_OF_PROCESSORS
|
||||
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\*.dll
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.windows.x86_64.release.dll-${{ github.sha }}
|
||||
name: libgit_plugin.windows.x86_64.editor.dll-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
@@ -46,15 +46,15 @@ jobs:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-macos-release-x64
|
||||
- name: build-macos-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
brew install scons
|
||||
scons platform=macos target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=extension_api.ci.json macos_arch=universal use_llvm=yes -j $(sysctl -n hw.logicalcpu)
|
||||
scons platform=macos bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes macos_arch=universal use_llvm=yes -j $(sysctl -n hw.logicalcpu)
|
||||
otool -L demo/addons/godot-git-plugin/macos/*.dylib
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.macos.x86_64.release.dylib-${{ github.sha }}
|
||||
name: libgit_plugin.macos.x86_64.editor.dylib-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
37
SConstruct
37
SConstruct
@@ -10,23 +10,10 @@ opts = Variables([], ARGUMENTS)
|
||||
env = Environment(ENV=os.environ)
|
||||
|
||||
# Define our options
|
||||
opts.Add(EnumVariable("target", "Compilation target",
|
||||
"debug", ["d", "debug", "r", "release"]))
|
||||
opts.Add(EnumVariable("platform", "Compilation platform",
|
||||
"", ["", "windows", "linux", "macos"]))
|
||||
opts.Add(EnumVariable("p", "Compilation target, alias for \"platform\"",
|
||||
"", ["", "windows", "linux", "macos"]))
|
||||
opts.Add(BoolVariable(
|
||||
"godot_cpp", "Build godot-cpp by forwarding arguments to it.", "no"))
|
||||
opts.Add(BoolVariable("use_llvm",
|
||||
"Use the LLVM / Clang compiler - only effective when targeting Linux or FreeBSD.", "no"))
|
||||
opts.Add(PathVariable("target_path",
|
||||
"The path where the lib is installed.", "demo/addons/godot-git-plugin/"))
|
||||
opts.Add(PathVariable("target_name", "The library name.",
|
||||
"libgit_plugin", PathVariable.PathAccept))
|
||||
opts.Add(EnumVariable("bits", "The bit architecture.", "64", ["64"]))
|
||||
opts.Add(EnumVariable("macos_arch", "Target macOS architecture",
|
||||
"universal", ["universal", "x86_64", "arm64"]))
|
||||
opts.Add(PathVariable("macos_openssl", "Path to OpenSSL library root - only used in macOS builds.",
|
||||
"/usr/local/opt/openssl@1.1/", PathVariable.PathAccept)) # TODO: Find a way to configure this to use the cloned OpenSSL source code, based on `macos_arch`.
|
||||
opts.Add(PathVariable("macos_openssl_static_ssl", "Path to OpenSSL libssl.a library - only used in macOS builds.",
|
||||
@@ -37,31 +24,17 @@ opts.Add(PathVariable("macos_openssl_static_crypto", "Path to OpenSSL libcrypto.
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
|
||||
if env["p"] != "":
|
||||
env["platform"] = env["p"]
|
||||
if ARGUMENTS.get("custom_api_file", "") != "":
|
||||
ARGUMENTS["custom_api_file"] = "../" + ARGUMENTS["custom_api_file"]
|
||||
|
||||
if env["platform"] == "macos":
|
||||
# Use only clang on macos because we need to do universal builds
|
||||
env["CXX"] = "clang++"
|
||||
env["CC"] = "clang"
|
||||
|
||||
if env["macos_arch"] == "universal":
|
||||
env.Append(LINKFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||
env.Append(CCFLAGS=["-arch", "x86_64", "-arch", "arm64"])
|
||||
else:
|
||||
env.Append(LINKFLAGS=["-arch", env["macos_arch"]])
|
||||
env.Append(CCFLAGS=["-arch", env["macos_arch"]])
|
||||
ARGUMENTS["target"] = "editor"
|
||||
env = SConscript("godot-cpp/SConstruct").Clone()
|
||||
opts.Update(env)
|
||||
|
||||
Export("env")
|
||||
|
||||
SConscript("thirdparty/SCsub")
|
||||
|
||||
if env["godot_cpp"]:
|
||||
if ARGUMENTS.get("custom_api_file", "") != "":
|
||||
ARGUMENTS["custom_api_file"] = "../" + ARGUMENTS["custom_api_file"]
|
||||
|
||||
SConscript("godot-cpp/SConstruct")
|
||||
|
||||
SConscript("godot-git-plugin/SCsub")
|
||||
|
||||
# Generates help for the -h scons option.
|
||||
|
||||
@@ -4,13 +4,8 @@ entry_symbol = "git_plugin_init"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.debug = "macos/libgit_plugin.macos.universal.debug.dylib"
|
||||
macos.release = "macos/libgit_plugin.macos.universal.release.dylib"
|
||||
windows.debug.x86_64 = "win64/libgit_plugin.windows.x86_64.debug.dll"
|
||||
windows.release.x86_64 = "win64/libgit_plugin.windows.x86_64.release.dll"
|
||||
linux.debug.x86_64 = "linux/libgit_plugin.linux.x86_64.debug.so"
|
||||
linux.release.x86_64 = "linux/libgit_plugin.linux.x86_64.release.so"
|
||||
linux.debug.arm64 = "linux/libgit_plugin.linux.arm64.debug.so"
|
||||
linux.release.arm64 = "linux/libgit_plugin.linux.arm64.release.so"
|
||||
linux.debug.rv64 = ""
|
||||
linux.release.rv64 = ""
|
||||
macos.editor = "res://macos/libgit_plugin.macos.editor.universal.dylib"
|
||||
windows.editor.x86_64 = "win64/libgit_plugin.windows.editor.x86_64.dll"
|
||||
linux.editor.x86_64 = "linux/libgit_plugin.linux.editor.x86_64.so"
|
||||
linux.editor.arm64 = "linux/libgit_plugin.linux.editor.arm64.so"
|
||||
linux.editor.rv64 = ""
|
||||
|
||||
263248
extension_api.ci.json
263248
extension_api.ci.json
File diff suppressed because it is too large
Load Diff
Submodule godot-cpp updated: 8ba1c059da...0233683173
@@ -5,12 +5,6 @@ import os
|
||||
env = {}
|
||||
Import("env")
|
||||
|
||||
godot_headers_path = "../godot-cpp/godot-headers/"
|
||||
cpp_bindings_path = "../godot-cpp/"
|
||||
cpp_library = "libgodot-cpp"
|
||||
target_arch = ""
|
||||
dynamic_lib_extension = ""
|
||||
|
||||
# Process some arguments
|
||||
if env["use_llvm"]:
|
||||
env["CC"] = "clang"
|
||||
@@ -20,9 +14,6 @@ if env["platform"] == "":
|
||||
print("No valid target platform selected.")
|
||||
quit()
|
||||
|
||||
if env["bits"] == "64":
|
||||
target_arch = "x86_64"
|
||||
|
||||
env["target_path"] = "../" + env["target_path"]
|
||||
|
||||
if not os.path.isdir(env["target_path"]):
|
||||
@@ -31,72 +22,29 @@ if not os.path.isdir(env["target_path"]):
|
||||
# Check our platform specifics
|
||||
if env["platform"] == "macos":
|
||||
env["target_path"] += "macos/"
|
||||
cpp_library += ".macos"
|
||||
dynamic_lib_extension = "dylib"
|
||||
target_arch = env["macos_arch"]
|
||||
|
||||
# Force static linkage (https://stackoverflow.com/a/2995999/7370948)
|
||||
static_ssl = File(env["macos_openssl_static_ssl"])
|
||||
static_crypto = File(env["macos_openssl_static_crypto"])
|
||||
env.Append(LIBS=[static_ssl, static_crypto])
|
||||
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-g", "-O2", "-std=c++17"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-g", "-O3", "-std=c++17"])
|
||||
|
||||
elif env["platform"] == "linux":
|
||||
env["target_path"] += "linux/"
|
||||
cpp_library += ".linux"
|
||||
env.Append(LIBS=["ssl", "crypto"])
|
||||
dynamic_lib_extension = "so"
|
||||
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-fPIC", "-g3", "-Og", "-std=c++17"])
|
||||
else:
|
||||
env.Append(CCFLAGS=["-fPIC", "-g", "-O3", "-std=c++17"])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
# TODO: Make this only apply when using MSVC
|
||||
env.Append(CPPDEFINES=["TYPED_METHOD_BIND"])
|
||||
env["target_path"] += "win64/"
|
||||
cpp_library += ".windows"
|
||||
# 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.Append(ENV=os.environ)
|
||||
dynamic_lib_extension = "dll"
|
||||
|
||||
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", "user32"])
|
||||
if env["target"] in ("debug", "d"):
|
||||
env.Append(CCFLAGS=["-EHsc", "-D_DEBUG", "-MDd", "/DEBUG"])
|
||||
env["PDB"] = env["target_name"] + ".pdb"
|
||||
else:
|
||||
env.Append(CCFLAGS=["-O2", "-EHsc", "-DNDEBUG", "-MD"])
|
||||
|
||||
if env["target"] in ("debug", "d"):
|
||||
cpp_library += ".debug"
|
||||
else:
|
||||
cpp_library += ".release"
|
||||
|
||||
cpp_library += "." + target_arch
|
||||
env.Append(LIBS=["advapi32", "winhttp", "rpcrt4", "crypt32", "ole32", "user32", "wsock32", "ws2_32", "bcrypt"])
|
||||
|
||||
env.Append(CPPPATH=[".", "src/"])
|
||||
env.Append(CPPPATH=[
|
||||
godot_headers_path,
|
||||
cpp_bindings_path + "include/",
|
||||
cpp_bindings_path + "gen/include/"
|
||||
])
|
||||
|
||||
env.Append(CPPPATH=["../thirdparty/git2/libgit2/include/"])
|
||||
env.Append(LIBPATH=[cpp_bindings_path + "bin/", "../thirdparty/bin/"])
|
||||
env.Prepend(LIBS=[cpp_library, "git2", "ssh2"])
|
||||
env.Append(LIBPATH=["../thirdparty/bin/"])
|
||||
env.Prepend(LIBS=["git2", "ssh2"])
|
||||
|
||||
library = env.SharedLibrary(
|
||||
target=env["target_path"] + env["target_name"] + "." +
|
||||
env["platform"] + "." + target_arch + "." +
|
||||
env["target"] + "." + dynamic_lib_extension,
|
||||
source=Glob("src/*.cpp"))
|
||||
target=env["target_path"] + "{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
|
||||
source=Glob("src/*.cpp")
|
||||
)
|
||||
Default(library)
|
||||
|
||||
@@ -19,7 +19,7 @@ void uninitialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
|
||||
|
||||
extern "C" {
|
||||
|
||||
GDNativeBool GDN_EXPORT git_plugin_init(const GDNativeInterface *p_interface, const GDNativeExtensionClassLibraryPtr p_library, GDNativeInitialization *r_initialization) {
|
||||
GDExtensionBool GDE_EXPORT git_plugin_init(const GDExtensionInterface *p_interface, const GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization) {
|
||||
godot::GDExtensionBinding::InitObject init_obj(p_interface, p_library, r_initialization);
|
||||
|
||||
init_obj.register_initializer(initialize_git_plugin_module);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include <git2/tree.h>
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/classes/file.hpp"
|
||||
#include "godot_cpp/classes/file_access.hpp"
|
||||
|
||||
#define GIT2_CALL(error, msg) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
|
||||
@@ -184,19 +184,18 @@ void GitPlugin::_unstage_file(const godot::String &file_path) {
|
||||
}
|
||||
|
||||
void GitPlugin::create_gitignore_and_gitattributes() {
|
||||
if (!godot::File::file_exists(repo_project_path + "/.gitignore")) {
|
||||
godot::File file;
|
||||
file.open(repo_project_path + "/.gitignore", godot::File::ModeFlags::WRITE);
|
||||
file.store_string(
|
||||
if (!godot::FileAccess::file_exists(repo_project_path + "/.gitignore")) {
|
||||
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(repo_project_path + "/.gitignore", godot::FileAccess::ModeFlags::WRITE);
|
||||
ERR_FAIL_COND(file.is_null());
|
||||
file->store_string(
|
||||
"# Godot 4+ specific ignores\n"
|
||||
".godot/\n");
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!godot::File::file_exists(repo_project_path + "/.gitattributes")) {
|
||||
godot::File file;
|
||||
file.open(repo_project_path + "/.gitattributes", godot::File::ModeFlags::WRITE);
|
||||
file.store_string(
|
||||
if (!godot::FileAccess::file_exists(repo_project_path + "/.gitattributes")) {
|
||||
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(repo_project_path + "/.gitattributes", godot::FileAccess::ModeFlags::WRITE);
|
||||
ERR_FAIL_COND(file.is_null());
|
||||
file->store_string(
|
||||
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
|
||||
"* text=auto\n\n"
|
||||
|
||||
@@ -214,12 +213,11 @@ void GitPlugin::create_gitignore_and_gitattributes() {
|
||||
"# Denote all files that are truly binary and should not be modified.\n"
|
||||
"*.png binary\n"
|
||||
"*.jpg binary\n");
|
||||
file.close();
|
||||
}
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_modified_files_data() {
|
||||
godot::Array stats_files;
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
godot::TypedArray<godot::Dictionary> stats_files;
|
||||
|
||||
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
||||
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
||||
@@ -227,7 +225,7 @@ godot::Array GitPlugin::_get_modified_files_data() {
|
||||
opts.flags |= GIT_STATUS_OPT_INCLUDE_UNTRACKED | GIT_STATUS_OPT_RENAMES_HEAD_TO_INDEX | GIT_STATUS_OPT_SORT_CASE_SENSITIVELY | GIT_STATUS_OPT_RECURSE_UNTRACKED_DIRS;
|
||||
|
||||
git_status_list_ptr statuses;
|
||||
GIT2_CALL_R(git_status_list_new(Capture(statuses), repo.get(), &opts), "Could not get status information from repository", godot::Array());
|
||||
GIT2_CALL_R(git_status_list_new(Capture(statuses), repo.get(), &opts), "Could not get status information from repository", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
size_t count = git_status_list_entrycount(statuses.get());
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
@@ -260,18 +258,18 @@ godot::Array GitPlugin::_get_modified_files_data() {
|
||||
return stats_files;
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_branch_list() {
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_branch_list() {
|
||||
git_branch_iterator_ptr it;
|
||||
GIT2_CALL_R(git_branch_iterator_new(Capture(it), repo.get(), GIT_BRANCH_LOCAL), "Could not create branch iterator", godot::Array());
|
||||
GIT2_CALL_R(git_branch_iterator_new(Capture(it), repo.get(), GIT_BRANCH_LOCAL), "Could not create branch iterator", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Array branch_names;
|
||||
godot::TypedArray<godot::Dictionary> branch_names;
|
||||
|
||||
git_reference_ptr ref;
|
||||
git_branch_t type;
|
||||
while (git_branch_next(Capture(ref), &type, it.get()) != GIT_ITEROVER) {
|
||||
const char *name = nullptr;
|
||||
|
||||
GIT2_CALL_R(git_branch_name(&name, ref.get()), "Could not get branch name", godot::Array());
|
||||
GIT2_CALL_R(git_branch_name(&name, ref.get()), "Could not get branch name", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
if (git_branch_is_head(ref.get())) {
|
||||
// Always send the current branch as the first branch in list
|
||||
@@ -310,31 +308,31 @@ void GitPlugin::_remove_remote(const godot::String &remote_name) {
|
||||
GIT2_CALL(git_remote_delete(repo.get(), CString(remote_name).data), "Could not delete remote " + remote_name);
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_line_diff(const godot::String &file_path, const godot::String &text) {
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_line_diff(const godot::String &file_path, const godot::String &text) {
|
||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||
|
||||
opts.context_lines = 0;
|
||||
opts.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED;
|
||||
|
||||
git_index_ptr index;
|
||||
GIT2_CALL_R(git_repository_index(Capture(index), repo.get()), "Failed to get repository index", godot::Array());
|
||||
GIT2_CALL_R(git_index_read(index.get(), 0), "Failed to read index", godot::Array());
|
||||
GIT2_CALL_R(git_repository_index(Capture(index), repo.get()), "Failed to get repository index", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_index_read(index.get(), 0), "Failed to read index", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
const git_index_entry *entry = git_index_get_bypath(index.get(), CString(file_path).data, GIT_INDEX_STAGE_NORMAL);
|
||||
if (!entry) {
|
||||
return godot::Array();
|
||||
return godot::TypedArray<godot::Dictionary>();
|
||||
}
|
||||
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", godot::Array());
|
||||
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
git_blob_ptr blob;
|
||||
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", godot::Array());
|
||||
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Array diff_contents;
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
|
||||
DiffHelper diff_helper = { &diff_contents, this };
|
||||
GIT2_CALL_R(git_diff_blob_to_buffer(blob.get(), nullptr, CString(text).data, text.length(), nullptr, &opts, nullptr, nullptr, diff_hunk_cb, nullptr, &diff_helper), "Failed to make diff", godot::Array());
|
||||
GIT2_CALL_R(git_diff_blob_to_buffer(blob.get(), nullptr, CString(text).data, text.length(), nullptr, &opts, nullptr, nullptr, diff_hunk_cb, nullptr, &diff_helper), "Failed to make diff", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
return diff_contents;
|
||||
}
|
||||
@@ -357,11 +355,11 @@ godot::String GitPlugin::_get_current_branch_name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_remotes() {
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_remotes() {
|
||||
git_strarray remote_array;
|
||||
GIT2_CALL_R(git_remote_list(&remote_array, repo.get()), "Could not get list of remotes", godot::Array());
|
||||
GIT2_CALL_R(git_remote_list(&remote_array, repo.get()), "Could not get list of remotes", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Array remotes;
|
||||
godot::TypedArray<godot::Dictionary> remotes;
|
||||
for (int i = 0; i < remote_array.count; i++) {
|
||||
remotes.push_back(remote_array.strings[i]);
|
||||
}
|
||||
@@ -369,15 +367,15 @@ godot::Array GitPlugin::_get_remotes() {
|
||||
return remotes;
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_previous_commits(int64_t max_commits) {
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int64_t max_commits) {
|
||||
git_revwalk_ptr walker;
|
||||
GIT2_CALL_R(git_revwalk_new(Capture(walker), repo.get()), "Could not create new revwalk", godot::Array());
|
||||
GIT2_CALL_R(git_revwalk_sorting(walker.get(), GIT_SORT_TIME), "Could not sort revwalk by time", godot::Array());
|
||||
GIT2_CALL_R(git_revwalk_new(Capture(walker), repo.get()), "Could not create new revwalk", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_revwalk_sorting(walker.get(), GIT_SORT_TIME), "Could not sort revwalk by time", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
GIT2_CALL_R_IGNORE(git_revwalk_push_head(walker.get()), "Could not push HEAD to revwalk", godot::Array(), { GIT_ENOTFOUND COMMA GIT_ERROR });
|
||||
GIT2_CALL_R_IGNORE(git_revwalk_push_head(walker.get()), "Could not push HEAD to revwalk", godot::TypedArray<godot::Dictionary>(), { GIT_ENOTFOUND COMMA GIT_ERROR });
|
||||
|
||||
git_oid oid;
|
||||
godot::Array commits;
|
||||
godot::TypedArray<godot::Dictionary> commits;
|
||||
char commit_id[GIT_OID_HEXSZ + 1];
|
||||
for (int i = 0; !git_revwalk_next(&oid, walker.get()) && i <= max_commits; i++) {
|
||||
git_commit_ptr commit;
|
||||
@@ -562,9 +560,9 @@ bool GitPlugin::_checkout_branch(const godot::String &branch_name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_get_diff(const godot::String &identifier, const int64_t area) {
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_diff(const godot::String &identifier, const int64_t area) {
|
||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||
godot::Array diff_contents;
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
|
||||
opts.context_lines = 2;
|
||||
opts.interhunk_lines = 0;
|
||||
@@ -623,28 +621,28 @@ godot::Array GitPlugin::_get_diff(const godot::String &identifier, const int64_t
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::Array GitPlugin::_parse_diff(git_diff *diff) {
|
||||
godot::Array diff_contents;
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
for (int i = 0; i < git_diff_num_deltas(diff); i++) {
|
||||
const git_diff_delta *delta = git_diff_get_delta(diff, i);
|
||||
|
||||
git_patch_ptr patch;
|
||||
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", godot::Array());
|
||||
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Dictionary diff_file = create_diff_file(delta->new_file.path, delta->old_file.path);
|
||||
|
||||
godot::Array diff_hunks;
|
||||
godot::TypedArray<godot::Dictionary> diff_hunks;
|
||||
for (int j = 0; j < git_patch_num_hunks(patch.get()); j++) {
|
||||
const git_diff_hunk *git_hunk;
|
||||
size_t line_count;
|
||||
GIT2_CALL_R(git_patch_get_hunk(&git_hunk, &line_count, patch.get(), j), "Could not get hunk from patch", godot::Array());
|
||||
GIT2_CALL_R(git_patch_get_hunk(&git_hunk, &line_count, patch.get(), j), "Could not get hunk from patch", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Dictionary diff_hunk = create_diff_hunk(git_hunk->old_start, git_hunk->new_start, git_hunk->old_lines, git_hunk->new_lines);
|
||||
|
||||
godot::Array diff_lines;
|
||||
godot::TypedArray<godot::Dictionary> diff_lines;
|
||||
for (int k = 0; k < line_count; k++) {
|
||||
const git_diff_line *git_diff_line;
|
||||
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", godot::Array());
|
||||
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
char *content = new char[git_diff_line->content_len + 1];
|
||||
std::memcpy(content, git_diff_line->content, git_diff_line->content_len);
|
||||
|
||||
@@ -35,17 +35,17 @@ public:
|
||||
// Endpoints
|
||||
bool _initialize(const godot::String &project_path) override;
|
||||
void _set_credentials(const godot::String &username, const godot::String &password, const godot::String &ssh_public_key_path, const godot::String &ssh_private_key_path, const godot::String &ssh_passphrase) override;
|
||||
godot::Array _get_modified_files_data() override;
|
||||
godot::TypedArray<godot::Dictionary> _get_modified_files_data() override;
|
||||
void _stage_file(const godot::String &file_path) override;
|
||||
void _unstage_file(const godot::String &file_path) override;
|
||||
void _discard_file(const godot::String &file_path) override;
|
||||
void _commit(const godot::String &msg) override;
|
||||
godot::Array _get_diff(const godot::String &identifier, int64_t area) override;
|
||||
godot::TypedArray<godot::Dictionary> _get_diff(const godot::String &identifier, int64_t area) override;
|
||||
bool _shut_down() override;
|
||||
godot::String _get_vcs_name() override;
|
||||
godot::Array _get_previous_commits(int64_t max_commits) override;
|
||||
godot::Array _get_branch_list() override;
|
||||
godot::Array _get_remotes() override;
|
||||
godot::TypedArray<godot::Dictionary> _get_previous_commits(int64_t max_commits) override;
|
||||
godot::TypedArray<godot::Dictionary> _get_branch_list() override;
|
||||
godot::TypedArray<godot::Dictionary> _get_remotes() override;
|
||||
void _create_branch(const godot::String &branch_name) override;
|
||||
void _remove_branch(const godot::String &branch_name) override;
|
||||
void _create_remote(const godot::String &remote_name, const godot::String &remote_url) override;
|
||||
@@ -55,10 +55,10 @@ public:
|
||||
void _pull(const godot::String &remote) override;
|
||||
void _push(const godot::String &remote, bool force) override;
|
||||
void _fetch(const godot::String &remote) override;
|
||||
godot::Array _get_line_diff(const godot::String &file_path, const godot::String &text) override;
|
||||
godot::TypedArray<godot::Dictionary> _get_line_diff(const godot::String &file_path, const godot::String &text) override;
|
||||
|
||||
// Helpers
|
||||
godot::Array _parse_diff(git_diff *p_diff);
|
||||
godot::TypedArray<godot::Dictionary> _parse_diff(git_diff *p_diff);
|
||||
bool check_errors(int error, godot::String function, godot::String file, int line, godot::String message, const std::vector<git_error_code> &ignores = {});
|
||||
void create_gitignore_and_gitattributes();
|
||||
bool create_initial_commit();
|
||||
|
||||
6
thirdparty/git2/SCsub
vendored
6
thirdparty/git2/SCsub
vendored
@@ -23,10 +23,10 @@ libgit2_sources += Glob("libgit2/deps/http-parser/" + "*.c")
|
||||
libgit2_sources += Glob("libgit2/deps/pcre/" + "*.c")
|
||||
libgit2_sources += Glob("libgit2/deps/zlib/" + "*.c")
|
||||
|
||||
if env_git["bits"] == 64:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_64"])
|
||||
elif env_git["bits"] == 32:
|
||||
if "32" in env["arch"]:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_32"])
|
||||
else:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_64"])
|
||||
|
||||
env_git.Prepend(
|
||||
CPPPATH=[
|
||||
|
||||
Reference in New Issue
Block a user