mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-01 01:48:28 +03:00
Compare commits
12 Commits
v3.0.0-bet
...
v2.x
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74d50dc1d9 | ||
|
|
516a24de6e | ||
|
|
7a8ea16f8e | ||
|
|
c38a44d192 | ||
|
|
dcdd042859 | ||
|
|
e1b0f45511 | ||
|
|
17e6a3c920 | ||
|
|
fc4885e019 | ||
|
|
89cbb972a9 | ||
|
|
49866fc60d | ||
|
|
92a82dc293 | ||
|
|
39b5c5f7f9 |
26
.github/workflows/build.yml
vendored
26
.github/workflows/build.yml
vendored
@@ -7,15 +7,15 @@ jobs:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-linux-editor-x64
|
||||
- name: build-linux-release-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=linux target=editor generate_bindings=yes gdextension_dir="../ci/" -j $(nproc)
|
||||
ldd demo/addons/godot-git-plugin/linux/*.so
|
||||
scons platform=linux target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $(nproc)
|
||||
ldd demo/addons/godot-git-plugin/linux/libgitapi.so
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.linux.x86_64.editor.so-${{ github.sha }}
|
||||
name: godot-git-plugin-linux-release-x64-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
@@ -29,32 +29,32 @@ jobs:
|
||||
python-version: "3.x"
|
||||
architecture: "x64"
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-editor-x64
|
||||
- name: build-windows-release-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
scons platform=windows target=editor generate_bindings=yes gdextension_dir="../ci/" -j $env:NUMBER_OF_PROCESSORS
|
||||
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\*.dll
|
||||
scons platform=windows target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json -j $env:NUMBER_OF_PROCESSORS
|
||||
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\libgitapi.dll
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.windows.x86_64.editor.dll-${{ github.sha }}
|
||||
name: godot-git-plugin-windows-release-x64-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
macos-universal:
|
||||
macos-x64:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-macos-editor-universal
|
||||
- name: build-macos-release-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
brew install scons
|
||||
scons platform=macos target=editor generate_bindings=yes gdextension_dir="../ci/" macos_arch=universal use_llvm=yes macos_deployment_target=10.13 -j $(sysctl -n hw.logicalcpu)
|
||||
otool -L demo/addons/godot-git-plugin/macos/*.dylib
|
||||
scons platform=osx target=release bits=64 godot_cpp=yes generate_bindings=yes use_custom_api_file=yes custom_api_file=api.ci.json macos_arch=universal macos_deployment_target=10.13 use_llvm=yes -j $(sysctl -n hw.logicalcpu)
|
||||
otool -L demo/addons/godot-git-plugin/osx/libgitapi.dylib
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: libgit_plugin.macos.universal.editor.dylib-${{ github.sha }}
|
||||
name: godot-git-plugin-macos-release-x64-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
8
.gitignore
vendored
8
.gitignore
vendored
@@ -1,12 +1,8 @@
|
||||
# SConstruct db
|
||||
*.dblite
|
||||
|
||||
# Godot ignores
|
||||
demo/.godot/
|
||||
|
||||
# Godot Serialisations
|
||||
extension_api.json
|
||||
!/ci/extension_api.json
|
||||
api.json
|
||||
|
||||
# Visual Studio Cache
|
||||
.vs/
|
||||
@@ -20,7 +16,7 @@ extension_api.json
|
||||
# Binaries
|
||||
build/
|
||||
bin/
|
||||
macos/
|
||||
osx/
|
||||
linux/
|
||||
win64/
|
||||
*.lib
|
||||
|
||||
2
LICENSE
2
LICENSE
@@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2016-2022 The Godot Engine community
|
||||
Copyright (c) 2016-2023 The Godot Engine community
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
37
README.md
37
README.md
@@ -4,9 +4,9 @@
|
||||
|
||||
# Godot Git Plugin
|
||||
|
||||
Git implementation of the Godot Engine VCS interface in Godot. We use [libgit2](https://libgit2.org) as our backend to simulate Git in code.
|
||||
Git implementation of the Godot Engine VCS interface using GDNative in Godot. We use [libgit2](https://libgit2.org) as our backend to simulate Git in code.
|
||||
|
||||
> Planned for the upcoming version of Godot. Look for other branches for support in other Godot releases.
|
||||
> Supported in Godot 3.5.x. Look for other branches for support in other Godot releases.
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
@@ -26,44 +26,29 @@ This section onwards is only meant to be used if you intend to compile the plugi
|
||||
- Windows
|
||||
- No extra steps required other than setting up the compilers.
|
||||
- MacOS
|
||||
- For making universal builds targeting both Apple Silicon and x86_64, you can optionally run `build_openssl_universal_macos.sh` to build OpenSSL yourself and replace the already prebuilt libraries provided inside `thirdparty/openssl/`, otherwise, just run `brew install openssl@1.1` to use the prebuilt libraries provided in this repository.
|
||||
- For making universal builds targeting both Apple Silicon and x86_64, you can optionally run `build_openssl_universal_osx.sh` to build OpenSSL yourself and replace the already prebuilt libraries provided inside `thirdparty/openssl/`, otherwise, just run `brew install openssl@1.1`.
|
||||
- Linux
|
||||
- Run `sudo apt-get install libssl-dev`, or your local package manager's equivalent.
|
||||
- Run `sudo apt-get install libssl-dev`, or local package manager equivalent.
|
||||
|
||||
### Release Build
|
||||
### Build
|
||||
|
||||
```
|
||||
scons platform=<platform> target=editor gdextension_dir="../path/to/gdextension/dump/" -j 6
|
||||
scons platform=<platform> target=release bits=64 -j 6
|
||||
```
|
||||
|
||||
> You may get the gdextension dump yourself from Godot using the instructions in the next section, or use the ones provided in `godot-cpp/gdextension` or `ci/`.
|
||||
|
||||
For more build options, run `scons platform=<platform> -h`
|
||||
|
||||
## Dev builds
|
||||
## Bleeding Edge
|
||||
|
||||
When new features are being worked on for the Godot VCS Integration, the build process sometimes requires developers to make changes in the GDExtension API along with this plugin. This means we need to manually generate the GDExtension API from the custom Godot builds and use it to compile godot-cpp, and then finally link the resulting godot-cpp binary into this plugin.
|
||||
Most of the times when new features are being worked on for the Godot VCS Integration, it requires developers to make changes in the Godot Editor source code along with this plugin. This means we need to manually generate the GDNative API from the custom Godot builds and then use it to compile godot-cpp.
|
||||
|
||||
If you need to use a custom GDExtension API:
|
||||
|
||||
1. Dump the new bindings from the custom Godot build.
|
||||
|
||||
```shell
|
||||
cd local/copy/of/godot/source
|
||||
.\bin\godot.xxx --headless --dump-gdextension-interface --dump-extension-api
|
||||
```
|
||||
|
||||
2. Build the plugin along with the godot-cpp library.
|
||||
To build using custom GDNative API definition JSON files, run the below helper command:
|
||||
|
||||
```
|
||||
scons platform=<platform> target=editor generate_bindings=yes dev_build=yes gdextension_dir="path/to/gdextension/dump" -j 6
|
||||
scons platform=<platform> target=debug godot_cpp=yes generate_bindings=yes bits=64 use_custom_api_file=yes custom_api_file=path/to/api.json -j 6
|
||||
```
|
||||
|
||||
> You only need to build godot-cpp once every change in the GDExtension API, hence, `generate_bindings=yes` should only be passed in during the first time after generating a new GDExtension API dump.
|
||||
|
||||
3. Open the project provided inside `demo/` in the custom Godot build.
|
||||
|
||||
To view more options available while recompiling godot-git-plugin, run `scons platform=<platform> -h`.
|
||||
Once this command is completed successfully, the standard build commands in the above section can be run without recompiling godot-cpp. Once compiled, to stop godot-cpp from recompiling, do not use the `godot_cpp` option in SCons arguments. To view more options available while recompiling godot-cpp, run `scons platform=<platform> godot_cpp=yes -h`.
|
||||
|
||||
---
|
||||
|
||||
|
||||
47
SConstruct
47
SConstruct
@@ -10,35 +10,62 @@ 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", "osx"]))
|
||||
opts.Add(EnumVariable("p", "Compilation target, alias for \"platform\"",
|
||||
"", ["", "windows", "linux", "osx"]))
|
||||
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))
|
||||
"libgitapi", 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.",
|
||||
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libssl.a"), PathVariable.PathAccept))
|
||||
opts.Add(PathVariable("macos_openssl_static_crypto", "Path to OpenSSL libcrypto.a library - only used in macOS builds.",
|
||||
os.path.join(os.path.abspath(os.getcwd()), "thirdparty/openssl/libcrypto.a"), PathVariable.PathAccept))
|
||||
opts.Add(PathVariable("linux_openssl_static_ssl", "Path to OpenSSL libssl.a library - only used in Linux builds.",
|
||||
"/usr/lib/x86_64-linux-gnu/libssl.a", PathVariable.PathAccept))
|
||||
opts.Add(PathVariable("linux_openssl_static_crypto", "Path to OpenSSL libcrypto.a library - only used in Linux builds.",
|
||||
"/usr/lib/x86_64-linux-gnu/libcrypto.a", PathVariable.PathAccept))
|
||||
opts.Add("macos_deployment_target", "macOS deployment target", "default")
|
||||
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
|
||||
if ARGUMENTS.get("custom_api_file", "") != "":
|
||||
ARGUMENTS["custom_api_file"] = "../" + ARGUMENTS["custom_api_file"]
|
||||
if env["platform"] == "osx":
|
||||
# Use only clang on osx because we need to do universal builds
|
||||
env["CXX"] = "clang++"
|
||||
env["CC"] = "clang"
|
||||
|
||||
ARGUMENTS["target"] = "editor"
|
||||
env = SConscript("godot-cpp/SConstruct").Clone()
|
||||
opts.Update(env)
|
||||
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"]])
|
||||
|
||||
if env["macos_deployment_target"] != "default":
|
||||
env.Append(CCFLAGS=["-mmacosx-version-min=" +
|
||||
env["macos_deployment_target"]])
|
||||
env.Append(LINKFLAGS=["-mmacosx-version-min=" +
|
||||
env["macos_deployment_target"]])
|
||||
|
||||
Export("env")
|
||||
|
||||
SConscript("thirdparty/SCsub")
|
||||
|
||||
if env["godot_cpp"]:
|
||||
if ARGUMENTS.get("use_custom_api_file", False) and 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.
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
|
||||
The Godot Git Plugin source code uses the following third-party source code:
|
||||
|
||||
1. godotengine/godot-cpp - MIT License - https://github.com/godotengine/godot-cpp/tree/02336831735fd6affbe0a6fa252ec98d3e78120c
|
||||
1. godotengine/godot-cpp - MIT License - https://github.com/godotengine/godot-cpp/tree/99e9dd1d9396ed3af40678263b509078e5265ffc
|
||||
2. libgit2/libgit2 - GPLv2 with a special Linking Exception - https://github.com/libgit2/libgit2/tree/b7bad55e4bb0a285b073ba5e02b01d3f522fc95d
|
||||
3. libssh2/libssh2 - BSD-3-Clause License - https://github.com/libssh2/libssh2/tree/635caa90787220ac3773c1d5ba11f1236c22eae8
|
||||
|
||||
We also link to these third-party libraries (only in the compiled binary form):
|
||||
|
||||
1. OpenSSL - Only on Linux and MacOS - OpenSSL License - http://www.openssl.org/source/openssl-1.1.1s.tar.gz
|
||||
1. OpenSSL - Only on Linux and MacOS - OpenSSL License - http://www.openssl.org/source/openssl-1.1.1i.tar.gz
|
||||
|
||||
## License Texts
|
||||
|
||||
@@ -17,7 +17,7 @@ We also link to these third-party libraries (only in the compiled binary form):
|
||||
```
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2017-2022 Godot Engine contributors.
|
||||
Copyright (c) 2017-2021 Godot Engine contributors.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
212598
api.ci.json
Normal file
212598
api.ci.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
OPENSSL_VERSION="1.1.1s"
|
||||
OPENSSL_VERSION="1.1.1i"
|
||||
|
||||
curl -OL http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||
tar -xzvf openssl-$OPENSSL_VERSION.tar.gz
|
||||
266325
ci/extension_api.json
266325
ci/extension_api.json
File diff suppressed because it is too large
Load Diff
@@ -1,619 +0,0 @@
|
||||
/*************************************************************************/
|
||||
/* gdextension_interface.h */
|
||||
/*************************************************************************/
|
||||
/* This file is part of: */
|
||||
/* GODOT ENGINE */
|
||||
/* https://godotengine.org */
|
||||
/*************************************************************************/
|
||||
/* Copyright (c) 2007-2022 Juan Linietsky, Ariel Manzur. */
|
||||
/* Copyright (c) 2014-2022 Godot Engine contributors (cf. AUTHORS.md). */
|
||||
/* */
|
||||
/* Permission is hereby granted, free of charge, to any person obtaining */
|
||||
/* a copy of this software and associated documentation files (the */
|
||||
/* "Software"), to deal in the Software without restriction, including */
|
||||
/* without limitation the rights to use, copy, modify, merge, publish, */
|
||||
/* distribute, sublicense, and/or sell copies of the Software, and to */
|
||||
/* permit persons to whom the Software is furnished to do so, subject to */
|
||||
/* the following conditions: */
|
||||
/* */
|
||||
/* The above copyright notice and this permission notice shall be */
|
||||
/* included in all copies or substantial portions of the Software. */
|
||||
/* */
|
||||
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
|
||||
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
|
||||
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
|
||||
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
|
||||
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
|
||||
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
|
||||
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
|
||||
/*************************************************************************/
|
||||
|
||||
#ifndef GDEXTENSION_INTERFACE_H
|
||||
#define GDEXTENSION_INTERFACE_H
|
||||
|
||||
/* This is a C class header, you can copy it and use it directly in your own binders.
|
||||
* Together with the JSON file, you should be able to generate any binder.
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#ifndef __cplusplus
|
||||
typedef uint32_t char32_t;
|
||||
typedef uint16_t char16_t;
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/* VARIANT TYPES */
|
||||
|
||||
typedef enum {
|
||||
GDEXTENSION_VARIANT_TYPE_NIL,
|
||||
|
||||
/* atomic types */
|
||||
GDEXTENSION_VARIANT_TYPE_BOOL,
|
||||
GDEXTENSION_VARIANT_TYPE_INT,
|
||||
GDEXTENSION_VARIANT_TYPE_FLOAT,
|
||||
GDEXTENSION_VARIANT_TYPE_STRING,
|
||||
|
||||
/* math types */
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR2,
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR2I,
|
||||
GDEXTENSION_VARIANT_TYPE_RECT2,
|
||||
GDEXTENSION_VARIANT_TYPE_RECT2I,
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR3,
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR3I,
|
||||
GDEXTENSION_VARIANT_TYPE_TRANSFORM2D,
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR4,
|
||||
GDEXTENSION_VARIANT_TYPE_VECTOR4I,
|
||||
GDEXTENSION_VARIANT_TYPE_PLANE,
|
||||
GDEXTENSION_VARIANT_TYPE_QUATERNION,
|
||||
GDEXTENSION_VARIANT_TYPE_AABB,
|
||||
GDEXTENSION_VARIANT_TYPE_BASIS,
|
||||
GDEXTENSION_VARIANT_TYPE_TRANSFORM3D,
|
||||
GDEXTENSION_VARIANT_TYPE_PROJECTION,
|
||||
|
||||
/* misc types */
|
||||
GDEXTENSION_VARIANT_TYPE_COLOR,
|
||||
GDEXTENSION_VARIANT_TYPE_STRING_NAME,
|
||||
GDEXTENSION_VARIANT_TYPE_NODE_PATH,
|
||||
GDEXTENSION_VARIANT_TYPE_RID,
|
||||
GDEXTENSION_VARIANT_TYPE_OBJECT,
|
||||
GDEXTENSION_VARIANT_TYPE_CALLABLE,
|
||||
GDEXTENSION_VARIANT_TYPE_SIGNAL,
|
||||
GDEXTENSION_VARIANT_TYPE_DICTIONARY,
|
||||
GDEXTENSION_VARIANT_TYPE_ARRAY,
|
||||
|
||||
/* typed arrays */
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_BYTE_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_INT32_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_INT64_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT32_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_FLOAT64_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_STRING_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR2_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_VECTOR3_ARRAY,
|
||||
GDEXTENSION_VARIANT_TYPE_PACKED_COLOR_ARRAY,
|
||||
|
||||
GDEXTENSION_VARIANT_TYPE_VARIANT_MAX
|
||||
} GDExtensionVariantType;
|
||||
|
||||
typedef enum {
|
||||
/* comparison */
|
||||
GDEXTENSION_VARIANT_OP_EQUAL,
|
||||
GDEXTENSION_VARIANT_OP_NOT_EQUAL,
|
||||
GDEXTENSION_VARIANT_OP_LESS,
|
||||
GDEXTENSION_VARIANT_OP_LESS_EQUAL,
|
||||
GDEXTENSION_VARIANT_OP_GREATER,
|
||||
GDEXTENSION_VARIANT_OP_GREATER_EQUAL,
|
||||
|
||||
/* mathematic */
|
||||
GDEXTENSION_VARIANT_OP_ADD,
|
||||
GDEXTENSION_VARIANT_OP_SUBTRACT,
|
||||
GDEXTENSION_VARIANT_OP_MULTIPLY,
|
||||
GDEXTENSION_VARIANT_OP_DIVIDE,
|
||||
GDEXTENSION_VARIANT_OP_NEGATE,
|
||||
GDEXTENSION_VARIANT_OP_POSITIVE,
|
||||
GDEXTENSION_VARIANT_OP_MODULE,
|
||||
GDEXTENSION_VARIANT_OP_POWER,
|
||||
|
||||
/* bitwise */
|
||||
GDEXTENSION_VARIANT_OP_SHIFT_LEFT,
|
||||
GDEXTENSION_VARIANT_OP_SHIFT_RIGHT,
|
||||
GDEXTENSION_VARIANT_OP_BIT_AND,
|
||||
GDEXTENSION_VARIANT_OP_BIT_OR,
|
||||
GDEXTENSION_VARIANT_OP_BIT_XOR,
|
||||
GDEXTENSION_VARIANT_OP_BIT_NEGATE,
|
||||
|
||||
/* logic */
|
||||
GDEXTENSION_VARIANT_OP_AND,
|
||||
GDEXTENSION_VARIANT_OP_OR,
|
||||
GDEXTENSION_VARIANT_OP_XOR,
|
||||
GDEXTENSION_VARIANT_OP_NOT,
|
||||
|
||||
/* containment */
|
||||
GDEXTENSION_VARIANT_OP_IN,
|
||||
GDEXTENSION_VARIANT_OP_MAX
|
||||
|
||||
} GDExtensionVariantOperator;
|
||||
|
||||
typedef void *GDExtensionVariantPtr;
|
||||
typedef const void *GDExtensionConstVariantPtr;
|
||||
typedef void *GDExtensionStringNamePtr;
|
||||
typedef const void *GDExtensionConstStringNamePtr;
|
||||
typedef void *GDExtensionStringPtr;
|
||||
typedef const void *GDExtensionConstStringPtr;
|
||||
typedef void *GDExtensionObjectPtr;
|
||||
typedef const void *GDExtensionConstObjectPtr;
|
||||
typedef void *GDExtensionTypePtr;
|
||||
typedef const void *GDExtensionConstTypePtr;
|
||||
typedef const void *GDExtensionMethodBindPtr;
|
||||
typedef int64_t GDExtensionInt;
|
||||
typedef uint8_t GDExtensionBool;
|
||||
typedef uint64_t GDObjectInstanceID;
|
||||
typedef void *GDExtensionRefPtr;
|
||||
typedef const void *GDExtensionConstRefPtr;
|
||||
|
||||
/* VARIANT DATA I/O */
|
||||
|
||||
typedef enum {
|
||||
GDEXTENSION_CALL_OK,
|
||||
GDEXTENSION_CALL_ERROR_INVALID_METHOD,
|
||||
GDEXTENSION_CALL_ERROR_INVALID_ARGUMENT, // Expected a different variant type.
|
||||
GDEXTENSION_CALL_ERROR_TOO_MANY_ARGUMENTS, // Expected lower number of arguments.
|
||||
GDEXTENSION_CALL_ERROR_TOO_FEW_ARGUMENTS, // Expected higher number of arguments.
|
||||
GDEXTENSION_CALL_ERROR_INSTANCE_IS_NULL,
|
||||
GDEXTENSION_CALL_ERROR_METHOD_NOT_CONST, // Used for const call.
|
||||
} GDExtensionCallErrorType;
|
||||
|
||||
typedef struct {
|
||||
GDExtensionCallErrorType error;
|
||||
int32_t argument;
|
||||
int32_t expected;
|
||||
} GDExtensionCallError;
|
||||
|
||||
typedef void (*GDExtensionVariantFromTypeConstructorFunc)(GDExtensionVariantPtr, GDExtensionTypePtr);
|
||||
typedef void (*GDExtensionTypeFromVariantConstructorFunc)(GDExtensionTypePtr, GDExtensionVariantPtr);
|
||||
typedef void (*GDExtensionPtrOperatorEvaluator)(GDExtensionConstTypePtr p_left, GDExtensionConstTypePtr p_right, GDExtensionTypePtr r_result);
|
||||
typedef void (*GDExtensionPtrBuiltInMethod)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_return, int p_argument_count);
|
||||
typedef void (*GDExtensionPtrConstructor)(GDExtensionTypePtr p_base, const GDExtensionConstTypePtr *p_args);
|
||||
typedef void (*GDExtensionPtrDestructor)(GDExtensionTypePtr p_base);
|
||||
typedef void (*GDExtensionPtrSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_value);
|
||||
typedef void (*GDExtensionPtrGetter)(GDExtensionConstTypePtr p_base, GDExtensionTypePtr r_value);
|
||||
typedef void (*GDExtensionPtrIndexedSetter)(GDExtensionTypePtr p_base, GDExtensionInt p_index, GDExtensionConstTypePtr p_value);
|
||||
typedef void (*GDExtensionPtrIndexedGetter)(GDExtensionConstTypePtr p_base, GDExtensionInt p_index, GDExtensionTypePtr r_value);
|
||||
typedef void (*GDExtensionPtrKeyedSetter)(GDExtensionTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionConstTypePtr p_value);
|
||||
typedef void (*GDExtensionPtrKeyedGetter)(GDExtensionConstTypePtr p_base, GDExtensionConstTypePtr p_key, GDExtensionTypePtr r_value);
|
||||
typedef uint32_t (*GDExtensionPtrKeyedChecker)(GDExtensionConstVariantPtr p_base, GDExtensionConstVariantPtr p_key);
|
||||
typedef void (*GDExtensionPtrUtilityFunction)(GDExtensionTypePtr r_return, const GDExtensionConstTypePtr *p_args, int p_argument_count);
|
||||
|
||||
typedef GDExtensionObjectPtr (*GDExtensionClassConstructor)();
|
||||
|
||||
typedef void *(*GDExtensionInstanceBindingCreateCallback)(void *p_token, void *p_instance);
|
||||
typedef void (*GDExtensionInstanceBindingFreeCallback)(void *p_token, void *p_instance, void *p_binding);
|
||||
typedef GDExtensionBool (*GDExtensionInstanceBindingReferenceCallback)(void *p_token, void *p_binding, GDExtensionBool p_reference);
|
||||
|
||||
typedef struct {
|
||||
GDExtensionInstanceBindingCreateCallback create_callback;
|
||||
GDExtensionInstanceBindingFreeCallback free_callback;
|
||||
GDExtensionInstanceBindingReferenceCallback reference_callback;
|
||||
} GDExtensionInstanceBindingCallbacks;
|
||||
|
||||
/* EXTENSION CLASSES */
|
||||
|
||||
typedef void *GDExtensionClassInstancePtr;
|
||||
|
||||
typedef GDExtensionBool (*GDExtensionClassSet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
|
||||
typedef GDExtensionBool (*GDExtensionClassGet)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
typedef uint64_t (*GDExtensionClassGetRID)(GDExtensionClassInstancePtr p_instance);
|
||||
|
||||
typedef struct {
|
||||
GDExtensionVariantType type;
|
||||
GDExtensionStringNamePtr name;
|
||||
GDExtensionStringNamePtr class_name;
|
||||
uint32_t hint; // Bitfield of `PropertyHint` (defined in `extension_api.json`).
|
||||
GDExtensionStringPtr hint_string;
|
||||
uint32_t usage; // Bitfield of `PropertyUsageFlags` (defined in `extension_api.json`).
|
||||
} GDExtensionPropertyInfo;
|
||||
|
||||
typedef struct {
|
||||
GDExtensionStringNamePtr name;
|
||||
GDExtensionPropertyInfo return_value;
|
||||
uint32_t flags; // Bitfield of `GDExtensionClassMethodFlags`.
|
||||
int32_t id;
|
||||
|
||||
/* Arguments: `default_arguments` is an array of size `argument_count`. */
|
||||
uint32_t argument_count;
|
||||
GDExtensionPropertyInfo *arguments;
|
||||
|
||||
/* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
|
||||
uint32_t default_argument_count;
|
||||
GDExtensionVariantPtr *default_arguments;
|
||||
} GDExtensionMethodInfo;
|
||||
|
||||
typedef const GDExtensionPropertyInfo *(*GDExtensionClassGetPropertyList)(GDExtensionClassInstancePtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionClassFreePropertyList)(GDExtensionClassInstancePtr p_instance, const GDExtensionPropertyInfo *p_list);
|
||||
typedef GDExtensionBool (*GDExtensionClassPropertyCanRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name);
|
||||
typedef GDExtensionBool (*GDExtensionClassPropertyGetRevert)(GDExtensionClassInstancePtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
typedef void (*GDExtensionClassNotification)(GDExtensionClassInstancePtr p_instance, int32_t p_what);
|
||||
typedef void (*GDExtensionClassToString)(GDExtensionClassInstancePtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr p_out);
|
||||
typedef void (*GDExtensionClassReference)(GDExtensionClassInstancePtr p_instance);
|
||||
typedef void (*GDExtensionClassUnreference)(GDExtensionClassInstancePtr p_instance);
|
||||
typedef void (*GDExtensionClassCallVirtual)(GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
|
||||
typedef GDExtensionObjectPtr (*GDExtensionClassCreateInstance)(void *p_userdata);
|
||||
typedef void (*GDExtensionClassFreeInstance)(void *p_userdata, GDExtensionClassInstancePtr p_instance);
|
||||
typedef GDExtensionClassCallVirtual (*GDExtensionClassGetVirtual)(void *p_userdata, GDExtensionConstStringNamePtr p_name);
|
||||
|
||||
typedef struct {
|
||||
GDExtensionBool is_virtual;
|
||||
GDExtensionBool is_abstract;
|
||||
GDExtensionClassSet set_func;
|
||||
GDExtensionClassGet get_func;
|
||||
GDExtensionClassGetPropertyList get_property_list_func;
|
||||
GDExtensionClassFreePropertyList free_property_list_func;
|
||||
GDExtensionClassPropertyCanRevert property_can_revert_func;
|
||||
GDExtensionClassPropertyGetRevert property_get_revert_func;
|
||||
GDExtensionClassNotification notification_func;
|
||||
GDExtensionClassToString to_string_func;
|
||||
GDExtensionClassReference reference_func;
|
||||
GDExtensionClassUnreference unreference_func;
|
||||
GDExtensionClassCreateInstance create_instance_func; // (Default) constructor; mandatory. If the class is not instantiable, consider making it virtual or abstract.
|
||||
GDExtensionClassFreeInstance free_instance_func; // Destructor; mandatory.
|
||||
GDExtensionClassGetVirtual get_virtual_func; // Queries a virtual function by name and returns a callback to invoke the requested virtual function.
|
||||
GDExtensionClassGetRID get_rid_func;
|
||||
void *class_userdata; // Per-class user data, later accessible in instance bindings.
|
||||
} GDExtensionClassCreationInfo;
|
||||
|
||||
typedef void *GDExtensionClassLibraryPtr;
|
||||
|
||||
/* Method */
|
||||
|
||||
typedef enum {
|
||||
GDEXTENSION_METHOD_FLAG_NORMAL = 1,
|
||||
GDEXTENSION_METHOD_FLAG_EDITOR = 2,
|
||||
GDEXTENSION_METHOD_FLAG_CONST = 4,
|
||||
GDEXTENSION_METHOD_FLAG_VIRTUAL = 8,
|
||||
GDEXTENSION_METHOD_FLAG_VARARG = 16,
|
||||
GDEXTENSION_METHOD_FLAG_STATIC = 32,
|
||||
GDEXTENSION_METHOD_FLAGS_DEFAULT = GDEXTENSION_METHOD_FLAG_NORMAL,
|
||||
} GDExtensionClassMethodFlags;
|
||||
|
||||
typedef enum {
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_NONE,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT8,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT16,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT32,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_INT64,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT8,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT16,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT32,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_INT_IS_UINT64,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_FLOAT,
|
||||
GDEXTENSION_METHOD_ARGUMENT_METADATA_REAL_IS_DOUBLE
|
||||
} GDExtensionClassMethodArgumentMetadata;
|
||||
|
||||
typedef void (*GDExtensionClassMethodCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
typedef void (*GDExtensionClassMethodPtrCall)(void *method_userdata, GDExtensionClassInstancePtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
|
||||
|
||||
typedef struct {
|
||||
GDExtensionStringNamePtr name;
|
||||
void *method_userdata;
|
||||
GDExtensionClassMethodCall call_func;
|
||||
GDExtensionClassMethodPtrCall ptrcall_func;
|
||||
uint32_t method_flags; // Bitfield of `GDExtensionClassMethodFlags`.
|
||||
|
||||
/* If `has_return_value` is false, `return_value_info` and `return_value_metadata` are ignored. */
|
||||
GDExtensionBool has_return_value;
|
||||
GDExtensionPropertyInfo *return_value_info;
|
||||
GDExtensionClassMethodArgumentMetadata return_value_metadata;
|
||||
|
||||
/* Arguments: `arguments_info` and `arguments_metadata` are array of size `argument_count`.
|
||||
* Name and hint information for the argument can be omitted in release builds. Class name should always be present if it applies.
|
||||
*/
|
||||
uint32_t argument_count;
|
||||
GDExtensionPropertyInfo *arguments_info;
|
||||
GDExtensionClassMethodArgumentMetadata *arguments_metadata;
|
||||
|
||||
/* Default arguments: `default_arguments` is an array of size `default_argument_count`. */
|
||||
uint32_t default_argument_count;
|
||||
GDExtensionVariantPtr *default_arguments;
|
||||
} GDExtensionClassMethodInfo;
|
||||
|
||||
/* SCRIPT INSTANCE EXTENSION */
|
||||
|
||||
typedef void *GDExtensionScriptInstanceDataPtr; // Pointer to custom ScriptInstance native implementation.
|
||||
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceSet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceGet)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
typedef const GDExtensionPropertyInfo *(*GDExtensionScriptInstanceGetPropertyList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionScriptInstanceFreePropertyList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionPropertyInfo *p_list);
|
||||
typedef GDExtensionVariantType (*GDExtensionScriptInstanceGetPropertyType)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionBool *r_is_valid);
|
||||
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstancePropertyCanRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstancePropertyGetRevert)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name, GDExtensionVariantPtr r_ret);
|
||||
|
||||
typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetOwner)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
typedef void (*GDExtensionScriptInstancePropertyStateAdd)(GDExtensionConstStringNamePtr p_name, GDExtensionConstVariantPtr p_value, void *p_userdata);
|
||||
typedef void (*GDExtensionScriptInstanceGetPropertyState)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionScriptInstancePropertyStateAdd p_add_func, void *p_userdata);
|
||||
|
||||
typedef const GDExtensionMethodInfo *(*GDExtensionScriptInstanceGetMethodList)(GDExtensionScriptInstanceDataPtr p_instance, uint32_t *r_count);
|
||||
typedef void (*GDExtensionScriptInstanceFreeMethodList)(GDExtensionScriptInstanceDataPtr p_instance, const GDExtensionMethodInfo *p_list);
|
||||
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceHasMethod)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionConstStringNamePtr p_name);
|
||||
|
||||
typedef void (*GDExtensionScriptInstanceCall)(GDExtensionScriptInstanceDataPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
typedef void (*GDExtensionScriptInstanceNotification)(GDExtensionScriptInstanceDataPtr p_instance, int32_t p_what);
|
||||
typedef void (*GDExtensionScriptInstanceToString)(GDExtensionScriptInstanceDataPtr p_instance, GDExtensionBool *r_is_valid, GDExtensionStringPtr r_out);
|
||||
|
||||
typedef void (*GDExtensionScriptInstanceRefCountIncremented)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceRefCountDecremented)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
|
||||
typedef GDExtensionObjectPtr (*GDExtensionScriptInstanceGetScript)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
typedef GDExtensionBool (*GDExtensionScriptInstanceIsPlaceholder)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
|
||||
typedef void *GDExtensionScriptLanguagePtr;
|
||||
|
||||
typedef GDExtensionScriptLanguagePtr (*GDExtensionScriptInstanceGetLanguage)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
|
||||
typedef void (*GDExtensionScriptInstanceFree)(GDExtensionScriptInstanceDataPtr p_instance);
|
||||
|
||||
typedef void *GDExtensionScriptInstancePtr; // Pointer to ScriptInstance.
|
||||
|
||||
typedef struct {
|
||||
GDExtensionScriptInstanceSet set_func;
|
||||
GDExtensionScriptInstanceGet get_func;
|
||||
GDExtensionScriptInstanceGetPropertyList get_property_list_func;
|
||||
GDExtensionScriptInstanceFreePropertyList free_property_list_func;
|
||||
|
||||
GDExtensionScriptInstancePropertyCanRevert property_can_revert_func;
|
||||
GDExtensionScriptInstancePropertyGetRevert property_get_revert_func;
|
||||
|
||||
GDExtensionScriptInstanceGetOwner get_owner_func;
|
||||
GDExtensionScriptInstanceGetPropertyState get_property_state_func;
|
||||
|
||||
GDExtensionScriptInstanceGetMethodList get_method_list_func;
|
||||
GDExtensionScriptInstanceFreeMethodList free_method_list_func;
|
||||
GDExtensionScriptInstanceGetPropertyType get_property_type_func;
|
||||
|
||||
GDExtensionScriptInstanceHasMethod has_method_func;
|
||||
|
||||
GDExtensionScriptInstanceCall call_func;
|
||||
GDExtensionScriptInstanceNotification notification_func;
|
||||
|
||||
GDExtensionScriptInstanceToString to_string_func;
|
||||
|
||||
GDExtensionScriptInstanceRefCountIncremented refcount_incremented_func;
|
||||
GDExtensionScriptInstanceRefCountDecremented refcount_decremented_func;
|
||||
|
||||
GDExtensionScriptInstanceGetScript get_script_func;
|
||||
|
||||
GDExtensionScriptInstanceIsPlaceholder is_placeholder_func;
|
||||
|
||||
GDExtensionScriptInstanceSet set_fallback_func;
|
||||
GDExtensionScriptInstanceGet get_fallback_func;
|
||||
|
||||
GDExtensionScriptInstanceGetLanguage get_language_func;
|
||||
|
||||
GDExtensionScriptInstanceFree free_func;
|
||||
|
||||
} GDExtensionScriptInstanceInfo;
|
||||
|
||||
/* INTERFACE */
|
||||
|
||||
typedef struct {
|
||||
uint32_t version_major;
|
||||
uint32_t version_minor;
|
||||
uint32_t version_patch;
|
||||
const char *version_string;
|
||||
|
||||
/* GODOT CORE */
|
||||
|
||||
void *(*mem_alloc)(size_t p_bytes);
|
||||
void *(*mem_realloc)(void *p_ptr, size_t p_bytes);
|
||||
void (*mem_free)(void *p_ptr);
|
||||
|
||||
void (*print_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
|
||||
void (*print_warning)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
|
||||
void (*print_script_error)(const char *p_description, const char *p_function, const char *p_file, int32_t p_line);
|
||||
|
||||
uint64_t (*get_native_struct_size)(GDExtensionConstStringNamePtr p_name);
|
||||
|
||||
/* GODOT VARIANT */
|
||||
|
||||
/* variant general */
|
||||
void (*variant_new_copy)(GDExtensionVariantPtr r_dest, GDExtensionConstVariantPtr p_src);
|
||||
void (*variant_new_nil)(GDExtensionVariantPtr r_dest);
|
||||
void (*variant_destroy)(GDExtensionVariantPtr p_self);
|
||||
|
||||
/* variant type */
|
||||
void (*variant_call)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
void (*variant_call_static)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_argument_count, GDExtensionVariantPtr r_return, GDExtensionCallError *r_error);
|
||||
void (*variant_evaluate)(GDExtensionVariantOperator p_op, GDExtensionConstVariantPtr p_a, GDExtensionConstVariantPtr p_b, GDExtensionVariantPtr r_return, GDExtensionBool *r_valid);
|
||||
void (*variant_set)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
|
||||
void (*variant_set_named)(GDExtensionVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
|
||||
void (*variant_set_keyed)(GDExtensionVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid);
|
||||
void (*variant_set_indexed)(GDExtensionVariantPtr p_self, GDExtensionInt p_index, GDExtensionConstVariantPtr p_value, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
|
||||
void (*variant_get)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
|
||||
void (*variant_get_named)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
|
||||
void (*variant_get_keyed)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
|
||||
void (*variant_get_indexed)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_index, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid, GDExtensionBool *r_oob);
|
||||
GDExtensionBool (*variant_iter_init)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
|
||||
GDExtensionBool (*variant_iter_next)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionBool *r_valid);
|
||||
void (*variant_iter_get)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_iter, GDExtensionVariantPtr r_ret, GDExtensionBool *r_valid);
|
||||
GDExtensionInt (*variant_hash)(GDExtensionConstVariantPtr p_self);
|
||||
GDExtensionInt (*variant_recursive_hash)(GDExtensionConstVariantPtr p_self, GDExtensionInt p_recursion_count);
|
||||
GDExtensionBool (*variant_hash_compare)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_other);
|
||||
GDExtensionBool (*variant_booleanize)(GDExtensionConstVariantPtr p_self);
|
||||
void (*variant_duplicate)(GDExtensionConstVariantPtr p_self, GDExtensionVariantPtr r_ret, GDExtensionBool p_deep);
|
||||
void (*variant_stringify)(GDExtensionConstVariantPtr p_self, GDExtensionStringPtr r_ret);
|
||||
|
||||
GDExtensionVariantType (*variant_get_type)(GDExtensionConstVariantPtr p_self);
|
||||
GDExtensionBool (*variant_has_method)(GDExtensionConstVariantPtr p_self, GDExtensionConstStringNamePtr p_method);
|
||||
GDExtensionBool (*variant_has_member)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
|
||||
GDExtensionBool (*variant_has_key)(GDExtensionConstVariantPtr p_self, GDExtensionConstVariantPtr p_key, GDExtensionBool *r_valid);
|
||||
void (*variant_get_type_name)(GDExtensionVariantType p_type, GDExtensionStringPtr r_name);
|
||||
GDExtensionBool (*variant_can_convert)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
|
||||
GDExtensionBool (*variant_can_convert_strict)(GDExtensionVariantType p_from, GDExtensionVariantType p_to);
|
||||
|
||||
/* ptrcalls */
|
||||
GDExtensionVariantFromTypeConstructorFunc (*get_variant_from_type_constructor)(GDExtensionVariantType p_type);
|
||||
GDExtensionTypeFromVariantConstructorFunc (*get_variant_to_type_constructor)(GDExtensionVariantType p_type);
|
||||
GDExtensionPtrOperatorEvaluator (*variant_get_ptr_operator_evaluator)(GDExtensionVariantOperator p_operator, GDExtensionVariantType p_type_a, GDExtensionVariantType p_type_b);
|
||||
GDExtensionPtrBuiltInMethod (*variant_get_ptr_builtin_method)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_method, GDExtensionInt p_hash);
|
||||
GDExtensionPtrConstructor (*variant_get_ptr_constructor)(GDExtensionVariantType p_type, int32_t p_constructor);
|
||||
GDExtensionPtrDestructor (*variant_get_ptr_destructor)(GDExtensionVariantType p_type);
|
||||
void (*variant_construct)(GDExtensionVariantType p_type, GDExtensionVariantPtr p_base, const GDExtensionConstVariantPtr *p_args, int32_t p_argument_count, GDExtensionCallError *r_error);
|
||||
GDExtensionPtrSetter (*variant_get_ptr_setter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
|
||||
GDExtensionPtrGetter (*variant_get_ptr_getter)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_member);
|
||||
GDExtensionPtrIndexedSetter (*variant_get_ptr_indexed_setter)(GDExtensionVariantType p_type);
|
||||
GDExtensionPtrIndexedGetter (*variant_get_ptr_indexed_getter)(GDExtensionVariantType p_type);
|
||||
GDExtensionPtrKeyedSetter (*variant_get_ptr_keyed_setter)(GDExtensionVariantType p_type);
|
||||
GDExtensionPtrKeyedGetter (*variant_get_ptr_keyed_getter)(GDExtensionVariantType p_type);
|
||||
GDExtensionPtrKeyedChecker (*variant_get_ptr_keyed_checker)(GDExtensionVariantType p_type);
|
||||
void (*variant_get_constant_value)(GDExtensionVariantType p_type, GDExtensionConstStringNamePtr p_constant, GDExtensionVariantPtr r_ret);
|
||||
GDExtensionPtrUtilityFunction (*variant_get_ptr_utility_function)(GDExtensionConstStringNamePtr p_function, GDExtensionInt p_hash);
|
||||
|
||||
/* extra utilities */
|
||||
void (*string_new_with_latin1_chars)(GDExtensionStringPtr r_dest, const char *p_contents);
|
||||
void (*string_new_with_utf8_chars)(GDExtensionStringPtr r_dest, const char *p_contents);
|
||||
void (*string_new_with_utf16_chars)(GDExtensionStringPtr r_dest, const char16_t *p_contents);
|
||||
void (*string_new_with_utf32_chars)(GDExtensionStringPtr r_dest, const char32_t *p_contents);
|
||||
void (*string_new_with_wide_chars)(GDExtensionStringPtr r_dest, const wchar_t *p_contents);
|
||||
void (*string_new_with_latin1_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
|
||||
void (*string_new_with_utf8_chars_and_len)(GDExtensionStringPtr r_dest, const char *p_contents, GDExtensionInt p_size);
|
||||
void (*string_new_with_utf16_chars_and_len)(GDExtensionStringPtr r_dest, const char16_t *p_contents, GDExtensionInt p_size);
|
||||
void (*string_new_with_utf32_chars_and_len)(GDExtensionStringPtr r_dest, const char32_t *p_contents, GDExtensionInt p_size);
|
||||
void (*string_new_with_wide_chars_and_len)(GDExtensionStringPtr r_dest, const wchar_t *p_contents, GDExtensionInt p_size);
|
||||
/* Information about the following functions:
|
||||
* - The return value is the resulting encoded string length.
|
||||
* - The length returned is in characters, not in bytes. It also does not include a trailing zero.
|
||||
* - These functions also do not write trailing zero, If you need it, write it yourself at the position indicated by the length (and make sure to allocate it).
|
||||
* - Passing NULL in r_text means only the length is computed (again, without including trailing zero).
|
||||
* - p_max_write_length argument is in characters, not bytes. It will be ignored if r_text is NULL.
|
||||
* - p_max_write_length argument does not affect the return value, it's only to cap write length.
|
||||
*/
|
||||
GDExtensionInt (*string_to_latin1_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
|
||||
GDExtensionInt (*string_to_utf8_chars)(GDExtensionConstStringPtr p_self, char *r_text, GDExtensionInt p_max_write_length);
|
||||
GDExtensionInt (*string_to_utf16_chars)(GDExtensionConstStringPtr p_self, char16_t *r_text, GDExtensionInt p_max_write_length);
|
||||
GDExtensionInt (*string_to_utf32_chars)(GDExtensionConstStringPtr p_self, char32_t *r_text, GDExtensionInt p_max_write_length);
|
||||
GDExtensionInt (*string_to_wide_chars)(GDExtensionConstStringPtr p_self, wchar_t *r_text, GDExtensionInt p_max_write_length);
|
||||
char32_t *(*string_operator_index)(GDExtensionStringPtr p_self, GDExtensionInt p_index);
|
||||
const char32_t *(*string_operator_index_const)(GDExtensionConstStringPtr p_self, GDExtensionInt p_index);
|
||||
|
||||
/* Packed array functions */
|
||||
|
||||
uint8_t *(*packed_byte_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray
|
||||
const uint8_t *(*packed_byte_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedByteArray
|
||||
|
||||
GDExtensionTypePtr (*packed_color_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr
|
||||
GDExtensionTypePtr (*packed_color_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedColorArray, returns Color ptr
|
||||
|
||||
float *(*packed_float32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array
|
||||
const float *(*packed_float32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat32Array
|
||||
double *(*packed_float64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array
|
||||
const double *(*packed_float64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedFloat64Array
|
||||
|
||||
int32_t *(*packed_int32_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
|
||||
const int32_t *(*packed_int32_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
|
||||
int64_t *(*packed_int64_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
|
||||
const int64_t *(*packed_int64_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedInt32Array
|
||||
|
||||
GDExtensionStringPtr (*packed_string_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray
|
||||
GDExtensionStringPtr (*packed_string_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedStringArray
|
||||
|
||||
GDExtensionTypePtr (*packed_vector2_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
|
||||
GDExtensionTypePtr (*packed_vector2_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector2Array, returns Vector2 ptr
|
||||
GDExtensionTypePtr (*packed_vector3_array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
|
||||
GDExtensionTypePtr (*packed_vector3_array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be a PackedVector3Array, returns Vector3 ptr
|
||||
|
||||
GDExtensionVariantPtr (*array_operator_index)(GDExtensionTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr
|
||||
GDExtensionVariantPtr (*array_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionInt p_index); // p_self should be an Array ptr
|
||||
|
||||
/* Dictionary functions */
|
||||
|
||||
GDExtensionVariantPtr (*dictionary_operator_index)(GDExtensionTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr
|
||||
GDExtensionVariantPtr (*dictionary_operator_index_const)(GDExtensionConstTypePtr p_self, GDExtensionConstVariantPtr p_key); // p_self should be an Dictionary ptr
|
||||
|
||||
/* OBJECT */
|
||||
|
||||
void (*object_method_bind_call)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstVariantPtr *p_args, GDExtensionInt p_arg_count, GDExtensionVariantPtr r_ret, GDExtensionCallError *r_error);
|
||||
void (*object_method_bind_ptrcall)(GDExtensionMethodBindPtr p_method_bind, GDExtensionObjectPtr p_instance, const GDExtensionConstTypePtr *p_args, GDExtensionTypePtr r_ret);
|
||||
void (*object_destroy)(GDExtensionObjectPtr p_o);
|
||||
GDExtensionObjectPtr (*global_get_singleton)(GDExtensionConstStringNamePtr p_name);
|
||||
|
||||
void *(*object_get_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, const GDExtensionInstanceBindingCallbacks *p_callbacks);
|
||||
void (*object_set_instance_binding)(GDExtensionObjectPtr p_o, void *p_token, void *p_binding, const GDExtensionInstanceBindingCallbacks *p_callbacks);
|
||||
|
||||
void (*object_set_instance)(GDExtensionObjectPtr p_o, GDExtensionConstStringNamePtr p_classname, GDExtensionClassInstancePtr p_instance); /* p_classname should be a registered extension class and should extend the p_o object's class. */
|
||||
|
||||
GDExtensionObjectPtr (*object_cast_to)(GDExtensionConstObjectPtr p_object, void *p_class_tag);
|
||||
GDExtensionObjectPtr (*object_get_instance_from_id)(GDObjectInstanceID p_instance_id);
|
||||
GDObjectInstanceID (*object_get_instance_id)(GDExtensionConstObjectPtr p_object);
|
||||
|
||||
/* REFERENCE */
|
||||
|
||||
GDExtensionObjectPtr (*ref_get_object)(GDExtensionConstRefPtr p_ref);
|
||||
void (*ref_set_object)(GDExtensionRefPtr p_ref, GDExtensionObjectPtr p_object);
|
||||
|
||||
/* SCRIPT INSTANCE */
|
||||
|
||||
GDExtensionScriptInstancePtr (*script_instance_create)(const GDExtensionScriptInstanceInfo *p_info, GDExtensionScriptInstanceDataPtr p_instance_data);
|
||||
|
||||
/* CLASSDB */
|
||||
|
||||
GDExtensionObjectPtr (*classdb_construct_object)(GDExtensionConstStringNamePtr p_classname); /* The passed class must be a built-in godot class, or an already-registered extension class. In both case, object_set_instance should be called to fully initialize the object. */
|
||||
GDExtensionMethodBindPtr (*classdb_get_method_bind)(GDExtensionConstStringNamePtr p_classname, GDExtensionConstStringNamePtr p_methodname, GDExtensionInt p_hash);
|
||||
void *(*classdb_get_class_tag)(GDExtensionConstStringNamePtr p_classname);
|
||||
|
||||
/* CLASSDB EXTENSION */
|
||||
|
||||
/* Provided parameters for `classdb_register_extension_*` can be safely freed once the function returns. */
|
||||
void (*classdb_register_extension_class)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_parent_class_name, const GDExtensionClassCreationInfo *p_extension_funcs);
|
||||
void (*classdb_register_extension_class_method)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionClassMethodInfo *p_method_info);
|
||||
void (*classdb_register_extension_class_integer_constant)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_enum_name, GDExtensionConstStringNamePtr p_constant_name, GDExtensionInt p_constant_value, GDExtensionBool p_is_bitfield);
|
||||
void (*classdb_register_extension_class_property)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, const GDExtensionPropertyInfo *p_info, GDExtensionConstStringNamePtr p_setter, GDExtensionConstStringNamePtr p_getter);
|
||||
void (*classdb_register_extension_class_property_group)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_group_name, GDExtensionConstStringPtr p_prefix);
|
||||
void (*classdb_register_extension_class_property_subgroup)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringPtr p_subgroup_name, GDExtensionConstStringPtr p_prefix);
|
||||
void (*classdb_register_extension_class_signal)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name, GDExtensionConstStringNamePtr p_signal_name, const GDExtensionPropertyInfo *p_argument_info, GDExtensionInt p_argument_count);
|
||||
void (*classdb_unregister_extension_class)(GDExtensionClassLibraryPtr p_library, GDExtensionConstStringNamePtr p_class_name); /* Unregistering a parent class before a class that inherits it will result in failure. Inheritors must be unregistered first. */
|
||||
|
||||
void (*get_library_path)(GDExtensionClassLibraryPtr p_library, GDExtensionStringPtr r_path);
|
||||
|
||||
} GDExtensionInterface;
|
||||
|
||||
/* INITIALIZATION */
|
||||
|
||||
typedef enum {
|
||||
GDEXTENSION_INITIALIZATION_CORE,
|
||||
GDEXTENSION_INITIALIZATION_SERVERS,
|
||||
GDEXTENSION_INITIALIZATION_SCENE,
|
||||
GDEXTENSION_INITIALIZATION_EDITOR,
|
||||
GDEXTENSION_MAX_INITIALIZATION_LEVEL,
|
||||
} GDExtensionInitializationLevel;
|
||||
|
||||
typedef struct {
|
||||
/* Minimum initialization level required.
|
||||
* If Core or Servers, the extension needs editor or game restart to take effect */
|
||||
GDExtensionInitializationLevel minimum_initialization_level;
|
||||
/* Up to the user to supply when initializing */
|
||||
void *userdata;
|
||||
/* This function will be called multiple times for each initialization level. */
|
||||
void (*initialize)(void *userdata, GDExtensionInitializationLevel p_level);
|
||||
void (*deinitialize)(void *userdata, GDExtensionInitializationLevel p_level);
|
||||
} GDExtensionInitialization;
|
||||
|
||||
/* Define a C function prototype that implements the function below and expose it to dlopen() (or similar).
|
||||
* This is the entry point of the GDExtension library and will be called on initialization.
|
||||
* It can be used to set up different init levels, which are called during various stages of initialization/shutdown.
|
||||
* The function name must be a unique one specified in the .gdextension config file.
|
||||
*/
|
||||
typedef GDExtensionBool (*GDExtensionInitializationFunction)(const GDExtensionInterface *p_interface, GDExtensionClassLibraryPtr p_library, GDExtensionInitialization *r_initialization);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // GDEXTENSION_INTERFACE_H
|
||||
19
demo/.gitattributes
vendored
19
demo/.gitattributes
vendored
@@ -1,2 +1,17 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
# Set the default behavior, in case people don't have core.autocrlf set.
|
||||
* text=auto
|
||||
|
||||
# Explicitly declare text files you want to always be normalized and converted
|
||||
# to native line endings on checkout.
|
||||
*.cpp text
|
||||
*.c text
|
||||
*.h text
|
||||
*.gd text
|
||||
*.cs text
|
||||
|
||||
# Declare files that will always have CRLF line endings on checkout.
|
||||
*.sln text eol=crlf
|
||||
|
||||
# Denote all files that are truly binary and should not be modified.
|
||||
*.png binary
|
||||
*.jpg binary
|
||||
|
||||
13
demo/.gitignore
vendored
13
demo/.gitignore
vendored
@@ -1,2 +1,11 @@
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
# Godot-specific ignores
|
||||
.import/
|
||||
export.cfg
|
||||
export_presets.cfg
|
||||
|
||||
# Imported translations (automatically generated from CSV files)
|
||||
*.translation
|
||||
|
||||
# Mono-specific ignores
|
||||
.mono/
|
||||
data_*/
|
||||
|
||||
18
demo/addons/godot-git-plugin/git_api.gdnlib
Normal file
18
demo/addons/godot-git-plugin/git_api.gdnlib
Normal file
@@ -0,0 +1,18 @@
|
||||
[general]
|
||||
|
||||
load_once=true
|
||||
symbol_prefix="godot_"
|
||||
reloadable=false
|
||||
singleton=false
|
||||
|
||||
[entry]
|
||||
|
||||
OSX.64="res://addons/godot-git-plugin/osx/libgitapi.dylib"
|
||||
Windows.64="res://addons/godot-git-plugin/win64/libgitapi.dll"
|
||||
X11.64="res://addons/godot-git-plugin/linux/libgitapi.so"
|
||||
|
||||
[dependencies]
|
||||
|
||||
OSX.64=[ ]
|
||||
Windows.64=[ ]
|
||||
X11.64=[ ]
|
||||
9
demo/addons/godot-git-plugin/git_api.gdns
Normal file
9
demo/addons/godot-git-plugin/git_api.gdns
Normal file
@@ -0,0 +1,9 @@
|
||||
[gd_resource type="NativeScript" load_steps=2 format=2]
|
||||
|
||||
[ext_resource path="res://addons/godot-git-plugin/git_api.gdnlib" type="GDNativeLibrary" id=1]
|
||||
|
||||
[resource]
|
||||
resource_name = "GitAPI"
|
||||
class_name = "GitAPI"
|
||||
library = ExtResource( 1 )
|
||||
script_class_name = "GitAPI"
|
||||
@@ -1,11 +0,0 @@
|
||||
[configuration]
|
||||
|
||||
entry_symbol = "git_plugin_init"
|
||||
|
||||
[libraries]
|
||||
|
||||
macos.editor = "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 = ""
|
||||
@@ -2,6 +2,6 @@
|
||||
|
||||
name="Godot Git Plugin"
|
||||
description="This plugin lets you interact with Git without leaving the Godot editor. More information can be found at https://github.com/godotengine/godot-git-plugin/wiki"
|
||||
author="twaritwaikar"
|
||||
version="v3.0.0-beta1"
|
||||
script="godot-git-plugin.gd"
|
||||
author="ChronicallySerious"
|
||||
version="v2.0.0"
|
||||
script="git_api.gdns"
|
||||
|
||||
7
demo/default_env.tres
Normal file
7
demo/default_env.tres
Normal file
@@ -0,0 +1,7 @@
|
||||
[gd_resource type="Environment" load_steps=2 format=2]
|
||||
|
||||
[sub_resource type="ProceduralSky" id=1]
|
||||
|
||||
[resource]
|
||||
background_mode = 2
|
||||
background_sky = SubResource( 1 )
|
||||
@@ -1,3 +1,3 @@
|
||||
[gd_scene format=3 uid="uid://cr5ci1iwmxnlb"]
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Node3D" type="Node3D"]
|
||||
[node name="Node2D" type="Node2D"]
|
||||
|
||||
BIN
demo/icon.png
Normal file
BIN
demo/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
35
demo/icon.png.import
Normal file
35
demo/icon.png.import
Normal file
@@ -0,0 +1,35 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="StreamTexture"
|
||||
path="res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://icon.png"
|
||||
dest_files=[ "res://.import/icon.png-487276ed1e3a0c39cad0279d744ee560.stex" ]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_mode=0
|
||||
compress/bptc_ldr=0
|
||||
compress/normal_map=0
|
||||
flags/repeat=0
|
||||
flags/filter=true
|
||||
flags/mipmaps=false
|
||||
flags/anisotropic=false
|
||||
flags/srgb=2
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/HDR_as_SRGB=false
|
||||
process/invert_color=false
|
||||
process/normal_map_invert_y=false
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
@@ -1,12 +1,16 @@
|
||||
extends Node
|
||||
|
||||
|
||||
# Declare member variables here. Examples:
|
||||
# var a = 2
|
||||
# var b = "text"
|
||||
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready():
|
||||
print("Hello world!")
|
||||
print("Hello Godot!")
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta):
|
||||
pass
|
||||
#func _process(delta):
|
||||
# pass
|
||||
|
||||
@@ -6,17 +6,29 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=5
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "EditorVCSInterface",
|
||||
"class": "GitAPI",
|
||||
"language": "NativeScript",
|
||||
"path": "res://addons/godot-git-plugin/git_api.gdns"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"GitAPI": ""
|
||||
}
|
||||
|
||||
[application]
|
||||
|
||||
config/features=PackedStringArray("4.0")
|
||||
config/name="demo"
|
||||
run/main_scene="res://demo.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[editor]
|
||||
|
||||
version_control/plugin_name="GitPlugin"
|
||||
version_control/autoload_on_startup=true
|
||||
version_control/plugin_name="GitAPI"
|
||||
|
||||
[editor_plugins]
|
||||
[rendering]
|
||||
|
||||
enabled=PackedStringArray()
|
||||
environment/default_environment="res://default_env.tres"
|
||||
|
||||
Submodule godot-cpp updated: 0233683173...8366761930
@@ -5,11 +5,19 @@ import os
|
||||
env = {}
|
||||
Import("env")
|
||||
|
||||
godot_headers_path = "../godot-cpp/godot-headers/"
|
||||
cpp_bindings_path = "../godot-cpp/"
|
||||
cpp_library = "libgodot-cpp"
|
||||
bits = env["bits"]
|
||||
|
||||
# Process some arguments
|
||||
if env["use_llvm"]:
|
||||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
if env["p"] != "":
|
||||
env["platform"] = env["p"]
|
||||
|
||||
if env["platform"] == "":
|
||||
print("No valid target platform selected.")
|
||||
quit()
|
||||
@@ -20,39 +28,65 @@ if not os.path.isdir(env["target_path"]):
|
||||
os.mkdir(env["target_path"])
|
||||
|
||||
# Check our platform specifics
|
||||
if env["platform"] == "macos":
|
||||
env["target_path"] += "macos/"
|
||||
if env["platform"] == "osx":
|
||||
env["target_path"] += "osx/"
|
||||
cpp_library += ".osx"
|
||||
|
||||
# Force static linkage (https://stackoverflow.com/a/2995999/7370948)
|
||||
env.Append(LIBS=[File(env["macos_openssl_static_ssl"]),
|
||||
File(env["macos_openssl_static_crypto"])])
|
||||
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["macos_deployment_target"] != "default":
|
||||
env.Append(CCFLAGS=["-mmacosx-version-min=" +
|
||||
env["macos_deployment_target"]])
|
||||
env.Append(LINKFLAGS=["-mmacosx-version-min=" +
|
||||
env["macos_deployment_target"]])
|
||||
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/"
|
||||
env.Append(LIBS=[File(env["linux_openssl_static_ssl"]),
|
||||
File(env["linux_openssl_static_crypto"])])
|
||||
cpp_library += ".linux"
|
||||
env.Append(LIBS=["ssl", "crypto"])
|
||||
|
||||
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":
|
||||
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)
|
||||
|
||||
env.Append(LIBS=["advapi32", "winhttp", "rpcrt4", "crypt32",
|
||||
"ole32", "user32", "wsock32", "ws2_32", "bcrypt"])
|
||||
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"
|
||||
|
||||
if env['platform'] == 'osx' and env['macos_arch'] != 'universal':
|
||||
cpp_library += "." + env['macos_arch']
|
||||
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=["../thirdparty/bin/"])
|
||||
env.Prepend(LIBS=["git2", "ssh2"])
|
||||
env.Append(LIBPATH=[cpp_bindings_path + "bin/", "../thirdparty/bin/"])
|
||||
env.Prepend(LIBS=[cpp_library, "git2", "ssh2"])
|
||||
|
||||
library = env.SharedLibrary(
|
||||
target=env["target_path"] +
|
||||
"{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
|
||||
source=Glob("src/*.cpp")
|
||||
)
|
||||
target=env["target_path"] + env["target_name"],
|
||||
source=Glob("src/*.cpp"))
|
||||
Default(library)
|
||||
|
||||
7
godot-git-plugin/src/allocation_defs.h
Normal file
7
godot-git-plugin/src/allocation_defs.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef ALLOCATION_DEF_H
|
||||
#define ALLOCATION_DEF_H
|
||||
|
||||
#define memnew(klass) new klass()
|
||||
#define memdelete(pointer) pointer ? delete pointer : WARN_PRINT("GitAPI: Tried to delete a NULL object");
|
||||
|
||||
#endif // !ALLOCATION_DEF_H
|
||||
@@ -1,31 +1,20 @@
|
||||
#include "git_plugin.h"
|
||||
#include "git_api.h"
|
||||
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/godot.hpp"
|
||||
#include <Godot.hpp>
|
||||
|
||||
void initialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
|
||||
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
return;
|
||||
}
|
||||
|
||||
godot::ClassDB::register_class<GitPlugin>();
|
||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
||||
godot::Godot::gdnative_init(o);
|
||||
}
|
||||
|
||||
void uninitialize_git_plugin_module(godot::ModuleInitializationLevel p_level) {
|
||||
if (p_level != godot::MODULE_INITIALIZATION_LEVEL_EDITOR) {
|
||||
return;
|
||||
}
|
||||
extern "C" void GDN_EXPORT godot_gdnative_singleton(godot_gdnative_init_options *o) {
|
||||
}
|
||||
|
||||
extern "C" {
|
||||
|
||||
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);
|
||||
init_obj.register_terminator(uninitialize_git_plugin_module);
|
||||
init_obj.set_minimum_library_initialization_level(godot::MODULE_INITIALIZATION_LEVEL_EDITOR);
|
||||
|
||||
return init_obj.init();
|
||||
extern "C" void GDN_EXPORT godot_gdnative_terminate(godot_gdnative_terminate_options *o) {
|
||||
godot::Godot::gdnative_terminate(o);
|
||||
}
|
||||
|
||||
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
|
||||
godot::Godot::nativescript_init(handle);
|
||||
|
||||
godot::register_tool_class<godot::GitAPI>();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,4 @@
|
||||
#include "git_plugin.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#include <git2/tree.h>
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/classes/file_access.hpp"
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
#include "git_api.h"
|
||||
|
||||
#define GIT2_CALL(error, msg) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
|
||||
@@ -29,25 +22,35 @@
|
||||
|
||||
#define COMMA ,
|
||||
|
||||
void GitPlugin::_bind_methods() {
|
||||
// Doesn't seem to require binding functions for now
|
||||
namespace godot {
|
||||
|
||||
void GitAPI::_register_methods() {
|
||||
register_method("_commit", &GitAPI::_commit);
|
||||
register_method("_get_modified_files_data", &GitAPI::_get_modified_files_data);
|
||||
register_method("_get_remotes", &GitAPI::_get_remotes);
|
||||
register_method("_get_diff", &GitAPI::_get_diff);
|
||||
register_method("_get_vcs_name", &GitAPI::_get_vcs_name);
|
||||
register_method("_initialize", &GitAPI::_initialize);
|
||||
register_method("_shut_down", &GitAPI::_shut_down);
|
||||
register_method("_stage_file", &GitAPI::_stage_file);
|
||||
register_method("_discard_file", &GitAPI::_discard_file);
|
||||
register_method("_unstage_file", &GitAPI::_unstage_file);
|
||||
register_method("_get_previous_commits", &GitAPI::_get_previous_commits);
|
||||
register_method("_get_branch_list", &GitAPI::_get_branch_list);
|
||||
register_method("_create_branch", &GitAPI::_create_branch);
|
||||
register_method("_create_remote", &GitAPI::_create_remote);
|
||||
register_method("_remove_branch", &GitAPI::_remove_branch);
|
||||
register_method("_remove_remote", &GitAPI::_remove_remote);
|
||||
register_method("_get_current_branch_name", &GitAPI::_get_current_branch_name);
|
||||
register_method("_checkout_branch", &GitAPI::_checkout_branch);
|
||||
register_method("_fetch", &GitAPI::_fetch);
|
||||
register_method("_pull", &GitAPI::_pull);
|
||||
register_method("_push", &GitAPI::_push);
|
||||
register_method("_get_line_diff", &GitAPI::_get_line_diff);
|
||||
register_method("_set_credentials", &GitAPI::_set_credentials);
|
||||
}
|
||||
|
||||
GitPlugin::GitPlugin() {
|
||||
map_changes[GIT_STATUS_WT_NEW] = CHANGE_TYPE_NEW;
|
||||
map_changes[GIT_STATUS_INDEX_NEW] = CHANGE_TYPE_NEW;
|
||||
map_changes[GIT_STATUS_WT_MODIFIED] = CHANGE_TYPE_MODIFIED;
|
||||
map_changes[GIT_STATUS_INDEX_MODIFIED] = CHANGE_TYPE_MODIFIED;
|
||||
map_changes[GIT_STATUS_WT_RENAMED] = CHANGE_TYPE_RENAMED;
|
||||
map_changes[GIT_STATUS_INDEX_RENAMED] = CHANGE_TYPE_RENAMED;
|
||||
map_changes[GIT_STATUS_WT_DELETED] = CHANGE_TYPE_DELETED;
|
||||
map_changes[GIT_STATUS_INDEX_DELETED] = CHANGE_TYPE_DELETED;
|
||||
map_changes[GIT_STATUS_WT_TYPECHANGE] = CHANGE_TYPE_TYPECHANGE;
|
||||
map_changes[GIT_STATUS_INDEX_TYPECHANGE] = CHANGE_TYPE_TYPECHANGE;
|
||||
map_changes[GIT_STATUS_CONFLICTED] = CHANGE_TYPE_UNMERGED;
|
||||
}
|
||||
|
||||
bool GitPlugin::check_errors(int error, godot::String function, godot::String file, int line, godot::String message, const std::vector<git_error_code> &ignores) {
|
||||
bool GitAPI::check_errors(int error, String function, String file, int line, String message, const std::vector<git_error_code> &ignores) {
|
||||
const git_error *lg2err;
|
||||
|
||||
if (error == 0) {
|
||||
@@ -60,17 +63,18 @@ bool GitPlugin::check_errors(int error, godot::String function, godot::String fi
|
||||
}
|
||||
}
|
||||
|
||||
message = message + ".";
|
||||
message += ".";
|
||||
if ((lg2err = git_error_last()) != nullptr && lg2err->message != nullptr) {
|
||||
message = message + " Error " + godot::String::num_int64(error) + ": ";
|
||||
message = message + godot::String(lg2err->message);
|
||||
message += " Error " + String::num_int64(error) + ": ";
|
||||
message += String(lg2err->message);
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::push_error("GitPlugin: ", CString(message).data, " in ", CString(file).data, ":", CString(function).data, "#L", line);
|
||||
Godot::print_error("GitAPI: " + message, function, file, line);
|
||||
popup_error(message);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GitPlugin::_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) {
|
||||
void GitAPI::_set_credentials(const String username, const String password, const String ssh_public_key_path, const String ssh_private_key_path, const String ssh_passphrase) {
|
||||
creds.username = username;
|
||||
creds.password = password;
|
||||
creds.ssh_public_key_path = ssh_public_key_path;
|
||||
@@ -78,7 +82,7 @@ void GitPlugin::_set_credentials(const godot::String &username, const godot::Str
|
||||
creds.ssh_passphrase = ssh_passphrase;
|
||||
}
|
||||
|
||||
void GitPlugin::_discard_file(const godot::String &file_path) {
|
||||
void GitAPI::_discard_file(const String file_path) {
|
||||
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
@@ -88,7 +92,7 @@ void GitPlugin::_discard_file(const godot::String &file_path) {
|
||||
GIT2_CALL(git_checkout_index(repo.get(), nullptr, &opts), "Could not checkout index");
|
||||
}
|
||||
|
||||
void GitPlugin::_commit(const godot::String &msg) {
|
||||
void GitAPI::_commit(const String msg) {
|
||||
git_index_ptr repo_index;
|
||||
GIT2_CALL(git_repository_index(Capture(repo_index), repo.get()), "Could not get repository index");
|
||||
|
||||
@@ -148,7 +152,7 @@ void GitPlugin::_commit(const godot::String &msg) {
|
||||
}
|
||||
}
|
||||
|
||||
void GitPlugin::_stage_file(const godot::String &file_path) {
|
||||
void GitAPI::_stage_file(const String file_path) {
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
git_strarray array = { paths, 1 };
|
||||
@@ -159,7 +163,7 @@ void GitPlugin::_stage_file(const godot::String &file_path) {
|
||||
GIT2_CALL(git_index_write(index.get()), "Could not write changes to disk");
|
||||
}
|
||||
|
||||
void GitPlugin::_unstage_file(const godot::String &file_path) {
|
||||
void GitAPI::_unstage_file(const String file_path) {
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
git_strarray array = { paths, 1 };
|
||||
@@ -183,18 +187,28 @@ void GitPlugin::_unstage_file(const godot::String &file_path) {
|
||||
}
|
||||
}
|
||||
|
||||
void GitPlugin::create_gitignore_and_gitattributes() {
|
||||
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());
|
||||
void GitAPI::create_gitignore_and_gitattributes() {
|
||||
File *file = File::_new();
|
||||
|
||||
if (!file->file_exists("res://.gitignore")) {
|
||||
file->open("res://.gitignore", File::ModeFlags::WRITE);
|
||||
file->store_string(
|
||||
"# Godot 4+ specific ignores\n"
|
||||
".godot/\n");
|
||||
"# Godot-specific ignores\n"
|
||||
".import/\n"
|
||||
"export.cfg\n"
|
||||
"export_presets.cfg\n\n"
|
||||
|
||||
"# Imported translations (automatically generated from CSV files)\n"
|
||||
"*.translation\n\n"
|
||||
|
||||
"# Mono-specific ignores\n"
|
||||
".mono/\n"
|
||||
"data_*/\n");
|
||||
file->close();
|
||||
}
|
||||
|
||||
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());
|
||||
if (!file->file_exists("res://.gitattributes")) {
|
||||
file->open("res://.gitattributes", File::ModeFlags::WRITE);
|
||||
file->store_string(
|
||||
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
|
||||
"* text=auto\n\n"
|
||||
@@ -213,11 +227,14 @@ 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();
|
||||
}
|
||||
|
||||
file->free();
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
godot::TypedArray<godot::Dictionary> stats_files;
|
||||
Array GitAPI::_get_modified_files_data() {
|
||||
Array stats_files;
|
||||
|
||||
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
||||
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
||||
@@ -225,32 +242,45 @@ godot::TypedArray<godot::Dictionary> 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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_status_list_new(Capture(statuses), repo.get(), &opts), "Could not get status information from repository", Array());
|
||||
|
||||
size_t count = git_status_list_entrycount(statuses.get());
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
const git_status_entry *entry = git_status_byindex(statuses.get(), i);
|
||||
godot::String path;
|
||||
String path;
|
||||
if (entry->index_to_workdir) {
|
||||
path = entry->index_to_workdir->new_file.path;
|
||||
} else {
|
||||
path = entry->head_to_index->new_file.path;
|
||||
}
|
||||
|
||||
static Dictionary map_changes = Dictionary::make(
|
||||
GIT_STATUS_WT_NEW, CHANGE_TYPE_NEW,
|
||||
GIT_STATUS_INDEX_NEW, CHANGE_TYPE_NEW,
|
||||
GIT_STATUS_WT_MODIFIED, CHANGE_TYPE_MODIFIED,
|
||||
GIT_STATUS_INDEX_MODIFIED, CHANGE_TYPE_MODIFIED,
|
||||
GIT_STATUS_WT_RENAMED, CHANGE_TYPE_RENAMED,
|
||||
GIT_STATUS_INDEX_RENAMED, CHANGE_TYPE_RENAMED,
|
||||
GIT_STATUS_WT_DELETED, CHANGE_TYPE_DELETED,
|
||||
GIT_STATUS_INDEX_DELETED, CHANGE_TYPE_DELETED,
|
||||
GIT_STATUS_WT_TYPECHANGE, CHANGE_TYPE_TYPECHANGE,
|
||||
GIT_STATUS_INDEX_TYPECHANGE, CHANGE_TYPE_TYPECHANGE,
|
||||
GIT_STATUS_CONFLICTED, CHANGE_TYPE_UNMERGED);
|
||||
|
||||
const static int git_status_wt = GIT_STATUS_WT_NEW | GIT_STATUS_WT_MODIFIED | GIT_STATUS_WT_DELETED | GIT_STATUS_WT_TYPECHANGE | GIT_STATUS_WT_RENAMED | GIT_STATUS_CONFLICTED;
|
||||
const static int git_status_index = GIT_STATUS_INDEX_NEW | GIT_STATUS_INDEX_MODIFIED | GIT_STATUS_INDEX_DELETED | GIT_STATUS_INDEX_RENAMED | GIT_STATUS_INDEX_TYPECHANGE;
|
||||
|
||||
if (entry->status & git_status_wt) {
|
||||
stats_files.push_back(create_status_file(path, map_changes[git_status_t(entry->status & git_status_wt)], TREE_AREA_UNSTAGED));
|
||||
stats_files.push_back(create_status_file(path, map_changes[entry->status & git_status_wt], TREE_AREA_UNSTAGED));
|
||||
}
|
||||
|
||||
if (entry->status & git_status_index) {
|
||||
if (entry->status == GIT_STATUS_INDEX_RENAMED) {
|
||||
godot::String old_path = entry->head_to_index->old_file.path;
|
||||
stats_files.push_back(create_status_file(old_path, map_changes.at(GIT_STATUS_INDEX_DELETED), TREE_AREA_STAGED));
|
||||
stats_files.push_back(create_status_file(path, map_changes.at(GIT_STATUS_INDEX_NEW), TREE_AREA_STAGED));
|
||||
String old_path = entry->head_to_index->old_file.path;
|
||||
stats_files.push_back(create_status_file(old_path, map_changes[GIT_STATUS_INDEX_DELETED], TREE_AREA_STAGED));
|
||||
stats_files.push_back(create_status_file(path, map_changes[GIT_STATUS_INDEX_NEW], TREE_AREA_STAGED));
|
||||
} else {
|
||||
stats_files.push_back(create_status_file(path, map_changes.at(git_status_t(entry->status & git_status_index)), TREE_AREA_STAGED));
|
||||
stats_files.push_back(create_status_file(path, map_changes[entry->status & git_status_index], TREE_AREA_STAGED));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -258,31 +288,31 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
return stats_files;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::String> GitPlugin::_get_branch_list() {
|
||||
Array GitAPI::_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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_branch_iterator_new(Capture(it), repo.get(), GIT_BRANCH_LOCAL), "Could not create branch iterator", Array());
|
||||
|
||||
godot::TypedArray<godot::String> branch_names;
|
||||
Array 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::TypedArray<godot::String>());
|
||||
GIT2_CALL_R(git_branch_name(&name, ref.get()), "Could not get branch name", Array());
|
||||
|
||||
if (git_branch_is_head(ref.get())) {
|
||||
// Always send the current branch as the first branch in list
|
||||
branch_names.push_front(name);
|
||||
} else {
|
||||
branch_names.push_back(godot::String(name));
|
||||
branch_names.push_back(String(name));
|
||||
}
|
||||
}
|
||||
|
||||
return branch_names;
|
||||
}
|
||||
|
||||
void GitPlugin::_create_branch(const godot::String &branch_name) {
|
||||
void GitAPI::_create_branch(const String branch_name) {
|
||||
git_oid head_commit_id;
|
||||
GIT2_CALL(git_reference_name_to_id(&head_commit_id, repo.get(), "HEAD"), "Could not get HEAD commit ID");
|
||||
|
||||
@@ -293,51 +323,51 @@ void GitPlugin::_create_branch(const godot::String &branch_name) {
|
||||
GIT2_CALL(git_branch_create(Capture(branch_ref), repo.get(), CString(branch_name).data, head_commit.get(), 0), "Could not create branch from HEAD");
|
||||
}
|
||||
|
||||
void GitPlugin::_create_remote(const godot::String &remote_name, const godot::String &remote_url) {
|
||||
void GitAPI::_create_remote(const String remote_name, const String remote_url) {
|
||||
git_remote_ptr remote;
|
||||
GIT2_CALL(git_remote_create(Capture(remote), repo.get(), CString(remote_name).data, CString(remote_url).data), "Could not create remote");
|
||||
}
|
||||
|
||||
void GitPlugin::_remove_branch(const godot::String &branch_name) {
|
||||
void GitAPI::_remove_branch(const String branch_name) {
|
||||
git_reference_ptr branch;
|
||||
GIT2_CALL(git_branch_lookup(Capture(branch), repo.get(), CString(branch_name).data, GIT_BRANCH_LOCAL), "Could not find branch " + branch_name);
|
||||
GIT2_CALL(git_branch_delete(branch.get()), "Could not delete branch reference of " + branch_name);
|
||||
}
|
||||
|
||||
void GitPlugin::_remove_remote(const godot::String &remote_name) {
|
||||
void GitAPI::_remove_remote(const String remote_name) {
|
||||
GIT2_CALL(git_remote_delete(repo.get(), CString(remote_name).data), "Could not delete remote " + remote_name);
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_line_diff(const godot::String &file_path, const godot::String &text) {
|
||||
Array GitAPI::_get_line_diff(String file_path, 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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_index_read(index.get(), 0), "Failed to read index", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_repository_index(Capture(index), repo.get()), "Failed to get repository index", Array());
|
||||
GIT2_CALL_R(git_index_read(index.get(), 0), "Failed to read index", Array());
|
||||
|
||||
const git_index_entry *entry = git_index_get_bypath(index.get(), CString(file_path).data, GIT_INDEX_STAGE_NORMAL);
|
||||
if (!entry) {
|
||||
return godot::TypedArray<godot::Dictionary>();
|
||||
return Array();
|
||||
}
|
||||
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", Array());
|
||||
|
||||
git_blob_ptr blob;
|
||||
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", Array());
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
Array 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::TypedArray<godot::Dictionary>());
|
||||
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", Array());
|
||||
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::String GitPlugin::_get_current_branch_name() {
|
||||
String GitAPI::_get_current_branch_name() {
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_R_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not find repository HEAD", "", { GIT_ENOTFOUND COMMA GIT_EUNBORNBRANCH });
|
||||
|
||||
@@ -355,11 +385,11 @@ godot::String GitPlugin::_get_current_branch_name() {
|
||||
return name;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::String> GitPlugin::_get_remotes() {
|
||||
Array GitAPI::_get_remotes() {
|
||||
git_strarray remote_array;
|
||||
GIT2_CALL_R(git_remote_list(&remote_array, repo.get()), "Could not get list of remotes", godot::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_remote_list(&remote_array, repo.get()), "Could not get list of remotes", Array());
|
||||
|
||||
godot::TypedArray<godot::String> remotes;
|
||||
Array remotes;
|
||||
for (int i = 0; i < remote_array.count; i++) {
|
||||
remotes.push_back(remote_array.strings[i]);
|
||||
}
|
||||
@@ -367,25 +397,25 @@ godot::TypedArray<godot::String> GitPlugin::_get_remotes() {
|
||||
return remotes;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int64_t max_commits) {
|
||||
Array GitAPI::_get_previous_commits(const int64_t max_commits) {
|
||||
git_revwalk_ptr walker;
|
||||
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(git_revwalk_new(Capture(walker), repo.get()), "Could not create new revwalk", Array());
|
||||
GIT2_CALL_R(git_revwalk_sorting(walker.get(), GIT_SORT_TIME), "Could not sort revwalk by time", Array());
|
||||
|
||||
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 });
|
||||
GIT2_CALL_R_IGNORE(git_revwalk_push_head(walker.get()), "Could not push HEAD to revwalk", Array(), { GIT_ENOTFOUND COMMA GIT_ERROR });
|
||||
|
||||
git_oid oid;
|
||||
godot::TypedArray<godot::Dictionary> commits;
|
||||
Array 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;
|
||||
GIT2_CALL_R(git_commit_lookup(Capture(commit), repo.get(), &oid), "Failed to lookup the commit", commits);
|
||||
|
||||
git_oid_tostr(commit_id, GIT_OID_HEXSZ + 1, git_commit_id(commit.get()));
|
||||
godot::String msg = git_commit_message(commit.get());
|
||||
String msg = git_commit_message(commit.get());
|
||||
|
||||
const git_signature *sig = git_commit_author(commit.get());
|
||||
godot::String author = godot::String() + sig->name + " <" + sig->email + ">";
|
||||
String author = String() + sig->name + " <" + sig->email + ">";
|
||||
|
||||
commits.push_back(create_commit(msg, author, commit_id, sig->when.time, sig->when.offset));
|
||||
}
|
||||
@@ -393,8 +423,8 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int64_t ma
|
||||
return commits;
|
||||
}
|
||||
|
||||
void GitPlugin::_fetch(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing fetch from ", CString(remote).data);
|
||||
void GitAPI::_fetch(String remote) {
|
||||
Godot::print("GitAPI: Performing fetch from " + remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -414,11 +444,11 @@ void GitPlugin::_fetch(const godot::String &remote) {
|
||||
opts.callbacks = remote_cbs;
|
||||
GIT2_CALL(git_remote_fetch(remote_object.get(), nullptr, &opts, "fetch"), "Could not fetch data from remote");
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Fetch ended");
|
||||
Godot::print("GitAPI: Fetch ended");
|
||||
}
|
||||
|
||||
void GitPlugin::_pull(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing pull from ", CString(remote).data);
|
||||
void GitAPI::_pull(String remote) {
|
||||
Godot::print("GitAPI: Performing pull from " + remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -437,7 +467,7 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
|
||||
fetch_opts.callbacks = remote_cbs;
|
||||
|
||||
godot::String branch_name = _get_current_branch_name();
|
||||
String branch_name = _get_current_branch_name();
|
||||
|
||||
CString ref_spec_str("refs/heads/" + branch_name);
|
||||
|
||||
@@ -450,7 +480,7 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
GIT2_CALL(git_repository_fetchhead_foreach(repo.get(), fetchhead_foreach_cb, &pull_merge_oid), "Could not read \"FETCH_HEAD\" file");
|
||||
|
||||
if (git_oid_is_zero(&pull_merge_oid)) {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Could not find remote branch HEAD for " + branch_name + ". Try pushing the branch first.");
|
||||
popup_error("GitAPI: Could not find remote branch HEAD for " + branch_name + ". Try pushing the branch first.");
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -471,7 +501,7 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
GIT2_CALL(git_repository_head(Capture(target_ref), repo.get()), "Failed to get HEAD reference");
|
||||
|
||||
git_object_ptr target;
|
||||
GIT2_CALL(git_object_lookup(Capture(target), repo.get(), &pull_merge_oid, GIT_OBJECT_COMMIT), "Failed to lookup OID " + godot::String(git_oid_tostr_s(&pull_merge_oid)));
|
||||
GIT2_CALL(git_object_lookup(Capture(target), repo.get(), &pull_merge_oid, GIT_OBJECT_COMMIT), "Failed to lookup OID " + String(git_oid_tostr_s(&pull_merge_oid)));
|
||||
|
||||
ff_checkout_options.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
GIT2_CALL(git_checkout_tree(repo.get(), target.get(), &ff_checkout_options), "Failed to checkout HEAD reference");
|
||||
@@ -479,7 +509,7 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
git_reference_ptr new_target_ref;
|
||||
GIT2_CALL(git_reference_set_target(Capture(new_target_ref), target_ref.get(), &pull_merge_oid, nullptr), "Failed to move HEAD reference");
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Fast Forwarded");
|
||||
Godot::print("GitAPI: Fast Forwarded");
|
||||
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
|
||||
|
||||
} else if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL) {
|
||||
@@ -495,27 +525,27 @@ void GitPlugin::_pull(const godot::String &remote) {
|
||||
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
|
||||
|
||||
if (git_index_has_conflicts(index.get())) {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Index has conflicts. Solve conflicts and make a merge commit.");
|
||||
popup_error("GitAPI: Index has conflicts, Solve conflicts and make a merge commit.");
|
||||
} else {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Changes are staged. Make a merge commit.");
|
||||
popup_error("GitAPI: Change are staged, make a merge commit.");
|
||||
}
|
||||
|
||||
has_merge = true;
|
||||
|
||||
} else if (merge_analysis & GIT_MERGE_ANALYSIS_UP_TO_DATE) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Already up to date");
|
||||
Godot::print("GitAPI: Already up to date");
|
||||
|
||||
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
|
||||
|
||||
} else {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Can not merge");
|
||||
Godot::print("GitAPI: Can not merge");
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Pull ended");
|
||||
Godot::print("GitAPI: Pull ended");
|
||||
}
|
||||
|
||||
void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing push to ", CString(remote).data);
|
||||
void GitAPI::_push(const String remote, const bool force) {
|
||||
Godot::print("GitAPI: Performing push to " + remote);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
@@ -531,9 +561,9 @@ void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
|
||||
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_PUSH, &remote_cbs, nullptr, nullptr), "Could not connect to remote \"" + remote + "\". Are your credentials correct? Try using a PAT token (in case you are using Github) as your password");
|
||||
|
||||
godot::String branch_name = _get_current_branch_name();
|
||||
String branch_name = _get_current_branch_name();
|
||||
|
||||
CString pushspec(godot::String() + (force ? "+" : "") + "refs/heads/" + branch_name);
|
||||
CString pushspec(String() + (force ? "+" : "") + "refs/heads/" + branch_name);
|
||||
const git_strarray refspec = { &pushspec.data, 1 };
|
||||
|
||||
git_push_options push_options = GIT_PUSH_OPTIONS_INIT;
|
||||
@@ -541,10 +571,10 @@ void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
|
||||
GIT2_CALL(git_remote_push(remote_object.get(), &refspec, &push_options), "Failed to push");
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Push ended");
|
||||
Godot::print("GitAPI: Push ended");
|
||||
}
|
||||
|
||||
bool GitPlugin::_checkout_branch(const godot::String &branch_name) {
|
||||
bool GitAPI::_checkout_branch(String branch_name) {
|
||||
git_reference_ptr branch;
|
||||
GIT2_CALL_R(git_branch_lookup(Capture(branch), repo.get(), CString(branch_name).data, GIT_BRANCH_LOCAL), "Could not find branch", false);
|
||||
const char *branch_ref_name = git_reference_name(branch.get());
|
||||
@@ -560,9 +590,9 @@ bool GitPlugin::_checkout_branch(const godot::String &branch_name) {
|
||||
return true;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_diff(const godot::String &identifier, const int64_t area) {
|
||||
Array GitAPI::_get_diff(const String identifier, const int64_t area) {
|
||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
Array diff_contents;
|
||||
|
||||
opts.context_lines = 2;
|
||||
opts.interhunk_lines = 0;
|
||||
@@ -621,36 +651,34 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_get_diff(const godot::String &i
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
Array GitAPI::_parse_diff(git_diff *diff) {
|
||||
Array 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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", Array());
|
||||
|
||||
godot::Dictionary diff_file = create_diff_file(delta->new_file.path, delta->old_file.path);
|
||||
Dictionary diff_file = create_diff_file(delta->new_file.path, delta->old_file.path);
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_hunks;
|
||||
Array 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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_patch_get_hunk(&git_hunk, &line_count, patch.get(), j), "Could not get hunk from patch", Array());
|
||||
|
||||
godot::Dictionary diff_hunk = create_diff_hunk(git_hunk->old_start, git_hunk->new_start, git_hunk->old_lines, git_hunk->new_lines);
|
||||
Dictionary diff_hunk = create_diff_hunk(git_hunk->old_start, git_hunk->new_start, git_hunk->old_lines, git_hunk->new_lines);
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_lines;
|
||||
Array 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::TypedArray<godot::Dictionary>());
|
||||
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", Array());
|
||||
|
||||
char *content = new char[git_diff_line->content_len + 1];
|
||||
std::memcpy(content, git_diff_line->content, git_diff_line->content_len);
|
||||
memcpy(content, git_diff_line->content, git_diff_line->content_len);
|
||||
content[git_diff_line->content_len] = '\0';
|
||||
|
||||
godot::String status = " "; // We reserve 1 null terminated space to fill the + or the - character at git_diff_line->origin
|
||||
status[0] = git_diff_line->origin;
|
||||
diff_lines.push_back(create_diff_line(git_diff_line->new_lineno, git_diff_line->old_lineno, godot::String(content), status));
|
||||
diff_lines.push_back(create_diff_line(git_diff_line->new_lineno, git_diff_line->old_lineno, String(content), String(git_diff_line->origin)));
|
||||
|
||||
delete[] content;
|
||||
}
|
||||
@@ -664,13 +692,11 @@ godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::String GitPlugin::_get_vcs_name() {
|
||||
String GitAPI::_get_vcs_name() {
|
||||
return "Git";
|
||||
}
|
||||
|
||||
bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
using namespace godot;
|
||||
|
||||
bool GitAPI::_initialize(String project_path) {
|
||||
ERR_FAIL_COND_V(project_path == "", false);
|
||||
|
||||
int init = git_libgit2_init();
|
||||
@@ -678,20 +704,7 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
WARN_PRINT("Multiple libgit2 instances are running");
|
||||
}
|
||||
|
||||
git_buf discovered_repo_path = {};
|
||||
if (git_repository_discover(&discovered_repo_path, CString(project_path).data, 1, nullptr) == 0) {
|
||||
repo_project_path = godot::String(discovered_repo_path.ptr);
|
||||
|
||||
godot::UtilityFunctions::print("Found a repository at " + godot::String(discovered_repo_path.ptr) + ".");
|
||||
git_buf_dispose(&discovered_repo_path);
|
||||
} else {
|
||||
repo_project_path = project_path;
|
||||
|
||||
godot::UtilityFunctions::push_warning("Could not find any higher level repositories.");
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("Selected repository path: " + godot::String(repo_project_path) + ".");
|
||||
GIT2_CALL_R(git_repository_init(Capture(repo), CString(repo_project_path).data, 0), "Could not initialize repository", false);
|
||||
GIT2_CALL_R(git_repository_init(Capture(repo), CString(project_path).data, 0), "Could not initialize repository", false);
|
||||
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_R_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not get repository HEAD", false, { GIT_EUNBORNBRANCH COMMA GIT_ENOTFOUND });
|
||||
@@ -703,8 +716,13 @@ bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GitPlugin::_shut_down() {
|
||||
bool GitAPI::_shut_down() {
|
||||
repo.reset(); // Destroy repo object before libgit2 shuts down
|
||||
GIT2_CALL_R(git_libgit2_shutdown(), "Could not shutdown Git Plugin", false);
|
||||
return true;
|
||||
}
|
||||
|
||||
void GitAPI::_init() {
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
152
godot-git-plugin/src/git_api.h
Normal file
152
godot-git-plugin/src/git_api.h
Normal file
@@ -0,0 +1,152 @@
|
||||
#ifndef GIT_API_H
|
||||
#define GIT_API_H
|
||||
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
|
||||
#include <GodotGlobal.hpp>
|
||||
#include <AcceptDialog.hpp>
|
||||
#include <Button.hpp>
|
||||
#include <Control.hpp>
|
||||
#include <Directory.hpp>
|
||||
#include <EditorVCSInterface.hpp>
|
||||
#include <File.hpp>
|
||||
#include <Godot.hpp>
|
||||
#include <LineEdit.hpp>
|
||||
#include <OS.hpp>
|
||||
|
||||
#include <allocation_defs.h>
|
||||
#include <git_common.h>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class GitAPI;
|
||||
|
||||
struct DiffHelper {
|
||||
Array *diff_hunks;
|
||||
GitAPI *git_api;
|
||||
};
|
||||
|
||||
struct CString {
|
||||
char *data = nullptr;
|
||||
|
||||
CString() = delete;
|
||||
CString(const String &string) :
|
||||
data(string.alloc_c_string()) {}
|
||||
CString(CString &&) = delete;
|
||||
CString &operator=(const CString &) = delete;
|
||||
CString &operator=(CString &&) = delete;
|
||||
|
||||
~CString() {
|
||||
if (data) {
|
||||
godot::api->godot_free(data);
|
||||
data = nullptr;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Capture {
|
||||
T &smart_ptr = nullptr;
|
||||
|
||||
using Raw = decltype(smart_ptr.get());
|
||||
|
||||
Raw raw = nullptr;
|
||||
|
||||
public:
|
||||
Capture() = delete;
|
||||
Capture(T &ptr) :
|
||||
smart_ptr(ptr) {}
|
||||
Capture(Capture &&) = delete;
|
||||
Capture &operator=(const Capture &) = delete;
|
||||
Capture &operator=(Capture &&) = delete;
|
||||
|
||||
operator Raw *() {
|
||||
return &raw;
|
||||
}
|
||||
|
||||
~Capture() {
|
||||
if (raw) {
|
||||
smart_ptr.reset(raw);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <auto DeleteFn>
|
||||
struct FunctionDeleter {
|
||||
template <class T>
|
||||
void operator()(T *ptr) {
|
||||
DeleteFn(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, auto DeleteFn>
|
||||
using unique_ptr_deleter = std::unique_ptr<T, FunctionDeleter<DeleteFn>>;
|
||||
|
||||
using git_annotated_commit_ptr = unique_ptr_deleter<git_annotated_commit, git_annotated_commit_free>;
|
||||
using git_blob_ptr = unique_ptr_deleter<git_blob, git_blob_free>;
|
||||
using git_branch_iterator_ptr = unique_ptr_deleter<git_branch_iterator, git_branch_iterator_free>;
|
||||
using git_commit_ptr = unique_ptr_deleter<git_commit, git_commit_free>;
|
||||
using git_diff_ptr = unique_ptr_deleter<git_diff, git_diff_free>;
|
||||
using git_index_ptr = unique_ptr_deleter<git_index, git_index_free>;
|
||||
using git_object_ptr = unique_ptr_deleter<git_object, git_object_free>;
|
||||
using git_patch_ptr = unique_ptr_deleter<git_patch, git_patch_free>;
|
||||
using git_reference_ptr = unique_ptr_deleter<git_reference, git_reference_free>;
|
||||
using git_remote_ptr = unique_ptr_deleter<git_remote, git_remote_free>;
|
||||
using git_repository_ptr = unique_ptr_deleter<git_repository, git_repository_free>;
|
||||
using git_revwalk_ptr = unique_ptr_deleter<git_revwalk, git_revwalk_free>;
|
||||
using git_signature_ptr = unique_ptr_deleter<git_signature, git_signature_free>;
|
||||
using git_status_list_ptr = unique_ptr_deleter<git_status_list, git_status_list_free>;
|
||||
using git_tree_ptr = unique_ptr_deleter<git_tree, git_tree_free>;
|
||||
|
||||
class GitAPI : public EditorVCSInterface {
|
||||
GODOT_CLASS(GitAPI, EditorVCSInterface)
|
||||
|
||||
Credentials creds;
|
||||
bool has_merge = false;
|
||||
git_repository_ptr repo;
|
||||
git_oid pull_merge_oid = {};
|
||||
|
||||
// Endpoints
|
||||
bool _checkout_branch(const String branch_name);
|
||||
void _commit(const String msg);
|
||||
void _create_branch(const String branch_name);
|
||||
void _create_remote(const String remote_name, const String remote_url);
|
||||
void _discard_file(const String file_path);
|
||||
void _fetch(const String remote);
|
||||
Array _get_branch_list();
|
||||
String _get_current_branch_name();
|
||||
Array _get_diff(const String identifier, const int64_t area);
|
||||
Array _get_line_diff(const String file_path, const String text);
|
||||
Array _get_modified_files_data();
|
||||
Array _get_previous_commits(const int64_t max_commits);
|
||||
Array _get_remotes();
|
||||
String _get_vcs_name();
|
||||
bool _initialize(const String project_path);
|
||||
void _pull(const String remote);
|
||||
void _push(const String remote, const bool force);
|
||||
void _remove_branch(const String branch_name);
|
||||
void _remove_remote(const String remote_name);
|
||||
void _set_credentials(const String username, const String password, const String ssh_public_key_path, const String ssh_private_key_path, const String ssh_passphrase);
|
||||
bool _shut_down();
|
||||
void _stage_file(const String file_path);
|
||||
void _unstage_file(const String file_path);
|
||||
|
||||
// Helpers
|
||||
Array _parse_diff(git_diff *p_diff);
|
||||
|
||||
public:
|
||||
static void _register_methods();
|
||||
|
||||
bool check_errors(int error, String function, String file, int line, String message, const std::vector<git_error_code> &ignores = {});
|
||||
void create_gitignore_and_gitattributes();
|
||||
bool create_initial_commit();
|
||||
|
||||
void _init();
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // !GIT_API_H
|
||||
@@ -1,19 +1,14 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
#include <git_common.h>
|
||||
|
||||
#include "git_callbacks.h"
|
||||
#include "git_plugin.h"
|
||||
|
||||
#include "godot_cpp/godot.hpp"
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
#include <git_api.h>
|
||||
|
||||
extern "C" int progress_cb(const char *str, int len, void *data) {
|
||||
(void)data;
|
||||
|
||||
char *progress_str = new char[len + 1];
|
||||
std::memcpy(progress_str, str, len);
|
||||
memcpy(progress_str, str, len);
|
||||
progress_str[len] = '\0';
|
||||
godot::UtilityFunctions::push_warning("remote: ", CString(godot::String(progress_str).strip_edges()).data);
|
||||
godot::Godot::print("remote: " + godot::String(progress_str).strip_edges());
|
||||
delete[] progress_str;
|
||||
|
||||
return 0;
|
||||
@@ -27,10 +22,10 @@ extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b
|
||||
|
||||
git_oid_tostr(b_str, short_commit_length, b);
|
||||
if (git_oid_is_zero(a)) {
|
||||
godot::UtilityFunctions::print("* [new] ", CString(godot::String(b_str)).data, " ", CString(godot::String(refname)).data);
|
||||
godot::Godot::print("* [new] " + godot::String(b_str) + " " + godot::String(refname));
|
||||
} else {
|
||||
git_oid_tostr(a_str, short_commit_length, a);
|
||||
godot::UtilityFunctions::print("[updated] ", CString(godot::String(a_str)).data, "...", CString(godot::String(b_str)).data, " ", CString(godot::String(refname)).data);
|
||||
godot::Godot::print("[updated] " + godot::String(a_str) + "..." + godot::String(b_str) + " " + godot::String(refname));
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -40,11 +35,9 @@ extern "C" int transfer_progress_cb(const git_indexer_progress *stats, void *pay
|
||||
(void)payload;
|
||||
|
||||
if (stats->received_objects == stats->total_objects) {
|
||||
godot::UtilityFunctions::print("Resolving deltas ", uint32_t(stats->indexed_deltas), "/", uint32_t(stats->total_deltas));
|
||||
godot::Godot::print("Resolving deltas " + godot::String::num_int64(stats->indexed_deltas) + "/" + godot::String::num_int64(stats->total_deltas));
|
||||
} else if (stats->total_objects > 0) {
|
||||
godot::UtilityFunctions::print(
|
||||
"Received ", uint32_t(stats->received_objects), "/", uint32_t(stats->total_objects),
|
||||
" objects (", uint32_t(stats->indexed_objects), ") in ", uint32_t(stats->received_bytes), " bytes");
|
||||
godot::Godot::print("Received " + godot::String::num_int64(stats->received_objects) + "/" + godot::String::num_int64(stats->total_objects) + " objects (" + godot::String::num_int64(stats->indexed_objects) + ") in " + godot::String::num_int64(static_cast<int>(stats->received_bytes)) + " bytes");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -63,16 +56,18 @@ extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int tota
|
||||
progress = (current * 100) / total;
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("Writing Objects: ", uint32_t(progress), "% (", uint32_t(current), "/", uint32_t(total), ", ", uint32_t(bytes), " bytes done.");
|
||||
godot::Godot::print("Writing Objects: " +
|
||||
godot::String::num_int64(progress) + "% (" +
|
||||
godot::String::num_int64((int)current) + "/" + godot::String::num_int64((int)total) + "), " + godot::String::num_int64(bytes) + " bytes, done.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int push_update_reference_cb(const char *refname, const char *status, void *data) {
|
||||
godot::String status_str = status;
|
||||
if (status_str == "") {
|
||||
godot::UtilityFunctions::print("[rejected] ", CString(godot::String(refname)).data, " ", CString(status_str).data);
|
||||
godot::Godot::print("[rejected] " + godot::String(refname) + " " + status_str);
|
||||
} else {
|
||||
godot::UtilityFunctions::print("[updated] ", CString(godot::String(refname)).data);
|
||||
godot::Godot::print("[updated] " + godot::String(refname));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -83,29 +78,29 @@ extern "C" int credentials_cb(git_cred **out, const char *url, const char *usern
|
||||
godot::String proper_username = username_from_url ? username_from_url : creds->username;
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT) {
|
||||
return git_cred_userpass_plaintext_new(out, CString(proper_username).data, CString(creds->password).data);
|
||||
return git_cred_userpass_plaintext_new(out, godot::CString(proper_username).data, godot::CString(creds->password).data);
|
||||
}
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_SSH_KEY) {
|
||||
return git_credential_ssh_key_new(out,
|
||||
CString(proper_username).data,
|
||||
CString(creds->ssh_public_key_path).data,
|
||||
CString(creds->ssh_private_key_path).data,
|
||||
CString(creds->ssh_passphrase).data);
|
||||
godot::CString(proper_username).data,
|
||||
godot::CString(creds->ssh_public_key_path).data,
|
||||
godot::CString(creds->ssh_private_key_path).data,
|
||||
godot::CString(creds->ssh_passphrase).data);
|
||||
}
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
|
||||
return git_credential_username_new(out, CString(proper_username).data);
|
||||
return git_credential_username_new(out, godot::CString(proper_username).data);
|
||||
}
|
||||
|
||||
return GIT_EUSER;
|
||||
}
|
||||
|
||||
extern "C" int diff_hunk_cb(const git_diff_delta *delta, const git_diff_hunk *range, void *payload) {
|
||||
DiffHelper *diff_helper = (DiffHelper *)payload;
|
||||
godot::DiffHelper *diff_helper = (godot::DiffHelper *)payload;
|
||||
|
||||
godot::Dictionary hunk = diff_helper->git_plugin->create_diff_hunk(range->old_start, range->new_start, range->old_lines, range->new_lines);
|
||||
godot::Dictionary hunk = diff_helper->git_api->create_diff_hunk(range->old_start, range->new_start, range->old_lines, range->new_lines);
|
||||
diff_helper->diff_hunks->push_back(hunk);
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,18 @@
|
||||
#pragma once
|
||||
#ifndef GIT_COMMON_H
|
||||
#define GIT_COMMON_H
|
||||
|
||||
#include "godot_cpp/variant/array.hpp"
|
||||
#include "git2.h"
|
||||
#include <cstdio>
|
||||
|
||||
class GitPlugin;
|
||||
#include <Godot.hpp>
|
||||
|
||||
struct DiffHelper {
|
||||
godot::Array *diff_hunks;
|
||||
GitPlugin *git_plugin;
|
||||
#include <git2.h>
|
||||
|
||||
struct Credentials {
|
||||
godot::String username;
|
||||
godot::String password;
|
||||
godot::String ssh_public_key_path;
|
||||
godot::String ssh_private_key_path;
|
||||
godot::String ssh_passphrase;
|
||||
};
|
||||
|
||||
extern "C" int progress_cb(const char *str, int len, void *data);
|
||||
@@ -18,3 +23,5 @@ extern "C" int credentials_cb(git_cred **out, const char *url, const char *usern
|
||||
extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void *payload);
|
||||
extern "C" int push_update_reference_cb(const char *refname, const char *status, void *data);
|
||||
extern "C" int diff_hunk_cb(const git_diff_delta *delta, const git_diff_hunk *range, void *payload);
|
||||
|
||||
#endif // !GIT_COMMON_H
|
||||
@@ -1,65 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <unordered_map>
|
||||
|
||||
#include "git_callbacks.h"
|
||||
#include "git_wrappers.h"
|
||||
|
||||
#include "godot_cpp/classes/editor_vcs_interface.hpp"
|
||||
#include "git2.h"
|
||||
|
||||
struct Credentials {
|
||||
godot::String username;
|
||||
godot::String password;
|
||||
godot::String ssh_public_key_path;
|
||||
godot::String ssh_private_key_path;
|
||||
godot::String ssh_passphrase;
|
||||
};
|
||||
|
||||
class GitPlugin : public godot::EditorVCSInterface {
|
||||
GDCLASS(GitPlugin, godot::EditorVCSInterface);
|
||||
|
||||
protected:
|
||||
static void _bind_methods();
|
||||
|
||||
public:
|
||||
Credentials creds;
|
||||
bool has_merge = false;
|
||||
git_repository_ptr repo;
|
||||
git_oid pull_merge_oid = {};
|
||||
godot::String repo_project_path;
|
||||
std::unordered_map<git_status_t, ChangeType> map_changes;
|
||||
|
||||
GitPlugin();
|
||||
|
||||
// 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::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::TypedArray<godot::Dictionary> _get_diff(const godot::String &identifier, int64_t area) override;
|
||||
bool _shut_down() override;
|
||||
godot::String _get_vcs_name() override;
|
||||
godot::TypedArray<godot::Dictionary> _get_previous_commits(int64_t max_commits) override;
|
||||
godot::TypedArray<godot::String> _get_branch_list() override;
|
||||
godot::TypedArray<godot::String> _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;
|
||||
void _remove_remote(const godot::String &remote_name) override;
|
||||
godot::String _get_current_branch_name() override;
|
||||
bool _checkout_branch(const godot::String &branch_name) override;
|
||||
void _pull(const godot::String &remote) override;
|
||||
void _push(const godot::String &remote, bool force) override;
|
||||
void _fetch(const godot::String &remote) override;
|
||||
godot::TypedArray<godot::Dictionary> _get_line_diff(const godot::String &file_path, const godot::String &text) override;
|
||||
|
||||
// Helpers
|
||||
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();
|
||||
};
|
||||
@@ -1,18 +0,0 @@
|
||||
#include "git_wrappers.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
CString::CString(const godot::String &string) {
|
||||
godot::CharString godot_char_str = string.utf8();
|
||||
|
||||
data = new char[godot_char_str.length() + 1];
|
||||
std::memcpy(data, (void *)godot_char_str.get_data(), godot_char_str.length());
|
||||
data[godot_char_str.length()] = '\0';
|
||||
}
|
||||
|
||||
CString::~CString() {
|
||||
if (data) {
|
||||
delete[] data;
|
||||
data = nullptr;
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "godot_cpp/variant/string.hpp"
|
||||
#include "git2.h"
|
||||
|
||||
class GitPlugin;
|
||||
|
||||
struct CString {
|
||||
char *data = nullptr;
|
||||
|
||||
CString(const godot::String &string);
|
||||
~CString();
|
||||
CString() = delete;
|
||||
CString(CString &&) = delete;
|
||||
CString &operator=(const CString &) = delete;
|
||||
CString &operator=(CString &&) = delete;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
class Capture {
|
||||
T &smart_ptr = nullptr;
|
||||
|
||||
using Raw = decltype(smart_ptr.get());
|
||||
|
||||
Raw raw = nullptr;
|
||||
|
||||
public:
|
||||
Capture() = delete;
|
||||
Capture(T &ptr) :
|
||||
smart_ptr(ptr) {}
|
||||
Capture(Capture &&) = delete;
|
||||
Capture &operator=(const Capture &) = delete;
|
||||
Capture &operator=(Capture &&) = delete;
|
||||
|
||||
operator Raw *() {
|
||||
return &raw;
|
||||
}
|
||||
|
||||
~Capture() {
|
||||
if (raw) {
|
||||
smart_ptr.reset(raw);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
template <auto DeleteFn>
|
||||
struct FunctionDeleter {
|
||||
template <class T>
|
||||
void operator()(T *ptr) {
|
||||
DeleteFn(ptr);
|
||||
}
|
||||
};
|
||||
|
||||
template <class T, auto DeleteFn>
|
||||
using unique_ptr_deleter = std::unique_ptr<T, FunctionDeleter<DeleteFn>>;
|
||||
|
||||
using git_annotated_commit_ptr = unique_ptr_deleter<git_annotated_commit, git_annotated_commit_free>;
|
||||
using git_blob_ptr = unique_ptr_deleter<git_blob, git_blob_free>;
|
||||
using git_branch_iterator_ptr = unique_ptr_deleter<git_branch_iterator, git_branch_iterator_free>;
|
||||
using git_commit_ptr = unique_ptr_deleter<git_commit, git_commit_free>;
|
||||
using git_diff_ptr = unique_ptr_deleter<git_diff, git_diff_free>;
|
||||
using git_index_ptr = unique_ptr_deleter<git_index, git_index_free>;
|
||||
using git_object_ptr = unique_ptr_deleter<git_object, git_object_free>;
|
||||
using git_patch_ptr = unique_ptr_deleter<git_patch, git_patch_free>;
|
||||
using git_reference_ptr = unique_ptr_deleter<git_reference, git_reference_free>;
|
||||
using git_remote_ptr = unique_ptr_deleter<git_remote, git_remote_free>;
|
||||
using git_repository_ptr = unique_ptr_deleter<git_repository, git_repository_free>;
|
||||
using git_revwalk_ptr = unique_ptr_deleter<git_revwalk, git_revwalk_free>;
|
||||
using git_signature_ptr = unique_ptr_deleter<git_signature, git_signature_free>;
|
||||
using git_status_list_ptr = unique_ptr_deleter<git_status_list, git_status_list_free>;
|
||||
using git_tree_ptr = unique_ptr_deleter<git_tree, git_tree_free>;
|
||||
using git_tree_entry_ptr = unique_ptr_deleter<git_tree_entry, git_tree_entry_free>;
|
||||
4
release.sh
Normal file → Executable file
4
release.sh
Normal file → Executable file
@@ -35,9 +35,9 @@ addonsPath=$releasePath/addons
|
||||
pluginPath=$addonsPath/godot-git-plugin
|
||||
|
||||
mkdir $pluginPath/linux
|
||||
mkdir $pluginPath/macos
|
||||
mkdir $pluginPath/osx
|
||||
cp -r linux/addons/godot-git-plugin/linux/ $pluginPath/
|
||||
cp -r mac/addons/godot-git-plugin/macos/ $pluginPath/
|
||||
cp -r mac/addons/godot-git-plugin/osx/ $pluginPath/
|
||||
|
||||
sed -i "s/version=\"[^\"]*\"/version=\"v${version}\"/g" $pluginPath/plugin.cfg
|
||||
cp LICENSE $pluginPath/LICENSE
|
||||
|
||||
2
thirdparty/SCsub
vendored
2
thirdparty/SCsub
vendored
@@ -1,6 +1,4 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
Import("env")
|
||||
|
||||
SConscript("ssh2/SCsub")
|
||||
SConscript("git2/SCsub")
|
||||
|
||||
10
thirdparty/git2/SCsub
vendored
10
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 "32" in env["arch"]:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_32"])
|
||||
else:
|
||||
if env_git["bits"] == 64:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_64"])
|
||||
elif env_git["bits"] == 32:
|
||||
env_git.Prepend(CPPDEFINES=["GIT_ARCH_32"])
|
||||
|
||||
env_git.Prepend(
|
||||
CPPPATH=[
|
||||
@@ -85,7 +85,7 @@ if env_git["platform"] == "windows":
|
||||
]
|
||||
)
|
||||
|
||||
if env_git["platform"] in ["linux", "macos"]:
|
||||
if env_git["platform"] in ["linux", "osx"]:
|
||||
env_git.Append(CCFLAGS="-fPIC")
|
||||
libgit2_sources += Glob("libgit2/src/unix/" + "*.c")
|
||||
libgit2_sources += [
|
||||
@@ -126,7 +126,7 @@ if env_git["platform"] in ["linux", "macos"]:
|
||||
]
|
||||
)
|
||||
|
||||
if env_git["platform"] == "macos":
|
||||
if env_git["platform"] == "osx":
|
||||
env_git.Prepend(CPPPATH=[env_git["macos_openssl"] + "include/"])
|
||||
static_ssl = File(env_git["macos_openssl_static_ssl"])
|
||||
static_crypto = File(env_git["macos_openssl_static_crypto"])
|
||||
|
||||
BIN
thirdparty/openssl/libcrypto.a
vendored
BIN
thirdparty/openssl/libcrypto.a
vendored
Binary file not shown.
BIN
thirdparty/openssl/libssl.a
vendored
BIN
thirdparty/openssl/libssl.a
vendored
Binary file not shown.
4
thirdparty/ssh2/SCsub
vendored
4
thirdparty/ssh2/SCsub
vendored
@@ -57,7 +57,7 @@ if env_ssh2["platform"] == "windows":
|
||||
)
|
||||
env_ssh2.Append(LIBS=["crypt32", "user32"])
|
||||
|
||||
if env_ssh2["platform"] in ["linux", "macos"]:
|
||||
if env_ssh2["platform"] in ["linux", "osx"]:
|
||||
env_ssh2.Append(CCFLAGS="-fPIC")
|
||||
env_ssh2.Append(
|
||||
CPPPATH=[
|
||||
@@ -104,7 +104,7 @@ if env_ssh2["platform"] in ["linux", "macos"]:
|
||||
]
|
||||
)
|
||||
|
||||
if env_ssh2["platform"] == "macos":
|
||||
if env_ssh2["platform"] == "osx":
|
||||
env_ssh2.Append(CPPPATH=[env_ssh2["macos_openssl"] + "include/"])
|
||||
static_ssl = File(env_ssh2["macos_openssl_static_ssl"])
|
||||
static_crypto = File(env_ssh2["macos_openssl_static_crypto"])
|
||||
|
||||
Reference in New Issue
Block a user