44 Commits

Author SHA1 Message Date
Twarit Waikar
9e0415dd14 Merge pull request #104 from ChronicallySerious/v1-release-automation 2022-02-01 19:30:34 +05:30
ChronicallySerious
242d72e5b6 Change release.sh to compress 1 level deeper 2022-02-01 19:26:41 +05:30
ChronicallySerious
0378e78572 Ignore remaining linux binaries 2022-02-01 18:28:47 +05:30
ChronicallySerious
fab7b595e1 Automate v1.x release creation 2022-02-01 18:21:01 +05:30
Twarit Waikar
d821a882c3 Update licensing date 2022-01-31 22:44:15 +05:30
Twarit Waikar
f85fef24b7 Merge pull request #103 from ChronicallySerious/fix-pcre-undefined 2022-01-31 22:32:42 +05:30
ChronicallySerious
7fd33bec6f Fix pcre not being included in static libgit2 build
Fixes #94

This backports a fix from v2.x which adds the builtin version of pcre as
a static dependency, rather than relying on the OS to provide pcre
2022-01-31 22:15:03 +05:30
Twarit Waikar
95e909bc6b Mention compatible Godot versions for v1.0 2022-01-10 20:27:27 +05:30
Twarit Waikar
3abcf57b6a Fix typo in README.md
`featured` -> `features`
2021-11-29 12:31:05 +05:30
Twarit Waikar
2d938a85a3 Merge pull request #93 from VinegarLove/patch-1 2021-11-29 12:13:26 +05:30
Twarit Waikar
2c7f341285 Trigger clang-format workflow on PRs too 2021-11-29 12:12:04 +05:30
VinegarLove
9cefa91f58 linux build script updated for other shells
fixed the way the CORES variable assignment  to be compliant with other shells other than bash
2021-11-28 23:38:54 +01:00
Twarit Waikar
89d5532b1b Add bleeding edge build instructions 2021-10-02 20:29:42 +05:30
Twarit Waikar
c952c57bd9 Update clang-format.yml 2021-10-02 05:29:07 +05:30
Twarit Waikar
09ec512ea7 Fix version tag in plugin.cfg to use "v" prefix 2021-10-02 04:59:05 +05:30
Twarit Waikar
f90cbe3b0a Merge pull request #80 from ChronicallySerious/addons-dir
Shift plugin binaries and build process to use addons/ directory
2021-10-02 04:50:39 +05:30
Twarit Waikar
24a0a14ef3 Add plugin build binaries to demo 2021-10-02 04:43:20 +05:30
Twarit Waikar
4f914d15ac Shift plugin binaries and build process to use addons/ directory 2021-10-02 04:21:39 +05:30
Twarit Waikar
ea15d7a5f1 Merge pull request #79 from ChronicallySerious/add-artifact-upload-ci
Add build artifact uploads in Github Actions
2021-10-02 02:29:40 +05:30
Twarit Waikar
7aa4d02193 Merge branch 'master' into add-artifact-upload-ci 2021-10-02 01:52:03 +05:30
Twarit Waikar
957e633c2a Merge pull request #78 from ChronicallySerious/add-clang-format-ci
Add clang-format Github Action
2021-10-02 01:50:06 +05:30
Twarit Waikar
243b03aa33 Add build artifact uploads in Github Actions 2021-10-02 01:49:30 +05:30
Twarit Waikar
a480cf4b16 Add clang-format Github Action 2021-10-02 01:25:42 +05:30
Twarit Waikar
e9f0844485 Merge pull request #60 from bruvzg/macos_m1
Add macOS ARM64 (Apple Silicon) support.
2021-09-28 11:28:32 +05:30
bruvzg
094424ce50 Add macOS ARM64 (Apple Silicon) support. 2021-09-28 08:28:37 +03:00
Twarit Waikar
d598850795 Merge pull request #69 from Calinou/readme-add-apple-silicon-notice
Document that building for Apple Silicon isn't supported yet
2021-05-09 14:39:07 +05:30
Hugo Locurcio
68e48e47c9 Document that building for Apple Silicon isn't supported yet 2021-05-09 11:04:44 +02:00
Twarit Waikar
9ed3b5128d Merge pull request #65 from ChronicallySerious/add-godot-version-readme
Add comment in README on nature of master targeting upcoming Godot
2021-04-19 23:56:12 +05:30
Twarit Waikar
abe4799600 Add comment in README on nature of master targeting upcoming Godot 2021-04-19 23:51:33 +05:30
Twarit Waikar
82ba804255 Merge pull request #64 from ChronicallySerious/small-appveyor-test 2021-04-19 22:13:24 +05:30
Twarit Waikar
58a5f956c0 Check if Appveyor build statuses are gone 2021-04-19 21:47:16 +05:30
Twarit Waikar
707937da12 Minor readme change 2021-04-19 21:34:30 +05:30
Twarit Waikar
95e7b29088 Merge pull request #63 from ChronicallySerious/add-ci-badge
Add CI badge to README
2021-04-19 21:20:54 +05:30
Twarit Waikar
2d2bbb0704 Add C/C++ CI badge to README 2021-04-19 19:20:42 +05:30
Twarit Waikar
4f1604d4f1 Merge pull request #62 from ChronicallySerious/build-workflow 2021-04-19 19:13:23 +05:30
Twarit Waikar
34bdbcdc50 Remove Travis CI and AppVeyor configs 2021-04-19 19:11:48 +05:30
Twarit Waikar
d6f3bdbab6 Load msvc developer cmd for windows CI 2021-04-19 18:38:19 +05:30
Twarit Waikar
57cd5cc068 Enforce C++17 in some left out build configs on mac 2021-04-19 18:11:31 +05:30
Twarit Waikar
0c6017066f Change godot_headers to godot-headers in include path 2021-04-19 17:02:00 +05:30
Twarit Waikar
0afdf18596 Speed up godot-cpp build by multithreaded build 2021-04-19 16:55:25 +05:30
Twarit Waikar
a41e4040d0 Update godot-cpp submodule url and update to latest commit 2021-04-19 16:41:38 +05:30
Twarit Waikar
6ec481671b Add SCons install to CI build scripts 2021-04-19 16:15:40 +05:30
Twarit Waikar
9da28eed5a Treat CMakeCache.txt not found while deletion as non-error 2021-04-19 15:00:42 +05:30
Twarit Waikar
24931cf07a Add C/C++ CI build workflows 2021-04-19 14:55:54 +05:30
30 changed files with 1379 additions and 218 deletions

110
.github/workflows/build.yml vendored Normal file
View File

@@ -0,0 +1,110 @@
name: C/C++ CI
on: [push, pull_request]
jobs:
ubuntu-debug:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build-ubuntu-debug
run: |
pip3 install --user scons
. ./build_libs.sh Debug
scons platform=x11 target=debug
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-ubuntu-debug-${{ github.sha }}
if-no-files-found: error
path: |
demo/
ubuntu-release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build-ubuntu-release
run: |
pip3 install --user scons
. ./build_libs.sh Release
scons platform=x11 target=release
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-ubuntu-release-${{ github.sha }}
if-no-files-found: error
path: |
demo/
windows-debug:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.x"
architecture: "x64"
- uses: ilammy/msvc-dev-cmd@v1
- name: build-windows-debug
run: |
pip3 install --user scons
./build_libs.bat Debug
scons platform=windows target=debug
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-windows-debug-${{ github.sha }}
if-no-files-found: error
path: |
demo/
windows-release:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-python@v2
with:
python-version: "3.x"
architecture: "x64"
- uses: ilammy/msvc-dev-cmd@v1
- name: build-windows-release
run: |
pip3 install --user scons
./build_libs.bat Release
scons platform=windows target=release
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-windows-release-${{ github.sha }}
if-no-files-found: error
path: |
demo/
macos-debug:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: build-macos-debug
run: |
brew install scons
. ./build_libs_mac.sh Debug
scons platform=osx target=debug use_llvm=yes
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-macos-debug-${{ github.sha }}
if-no-files-found: error
path: |
demo/
macos-release:
runs-on: macos-11
steps:
- uses: actions/checkout@v2
- name: build-macos-release
run: |
brew install scons
. ./build_libs_mac.sh Release
scons platform=osx target=release use_llvm=yes
- uses: actions/upload-artifact@v2
with:
name: godot-git-plugin-macos-release-${{ github.sha }}
if-no-files-found: error
path: |
demo/

15
.github/workflows/clang-format.yml vendored Normal file
View File

@@ -0,0 +1,15 @@
name: clang-format
on: [push, pull_request]
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: DoozyX/clang-format-lint-action@v0.11
with:
source: "godot-git-plugin/src"
extensions: "h,cpp"
clangFormatVersion: 11

17
.gitignore vendored
View File

@@ -14,17 +14,12 @@ api.json
.DS_Store
# Binaries
bin/
intermediate/
build/
*.dll
*.obj
*.so
*.dylib
*.pdb
*.ilk
*.exe
*.os
*.out
.import/
*.so
*.dll
*.exp
*.lib
*.a
*.dylib

3
.gitmodules vendored
View File

@@ -1,3 +1,4 @@
[submodule "godot-cpp"]
path = godot-cpp
url = https://github.com/GodotNativeTools/godot-cpp
url = https://github.com/godotengine/godot-cpp
branch = 3.x

View File

@@ -1,57 +0,0 @@
language: cpp
dist: xenial
osx_image: xcode10.1
env:
global:
- SCONS_CACHE="$HOME/.scons_cache"
- SCONS_CACHE_LIMIT=1024
cache:
directories:
- $SCONS_CACHE
matrix:
include:
- name: Linux Debug
os: linux
compiler: gcc
env: TARGET=debug PLATFORM=x11
addons:
apt:
sources:
- llvm-toolchain-xenial-6.0
packages:
[scons, pkg-config, build-essential, p7zip-full]
- name: Linux Release
os: linux
compiler: gcc
addons:
apt:
packages:
[scons, pkg-config, build-essential, p7zip-full]
env: TARGET=release PLATFORM=x11
install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
brew update;
brew install scons p7zip;
fi
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.0.5/scons-local-3.0.5.zip;
unzip scons-local-3.0.5.zip;
fi
script:
- if [[ "$TRAVIS_OS_NAME" == "windows" ]]; then
export SCONS="./scons.bat";
/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/Common7/Tools/VsDevCmd.bat;
./build_libs.bat $TARGET;
else
export SCONS="scons";
./build_libs.sh $TARGET;
fi
- $SCONS platform=$PLATFORM target=$TARGET $SCONS_FLAGS;

View File

@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2016-2019 The Godot Engine community
Copyright (c) 2016-2022 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

View File

@@ -1,8 +1,10 @@
[![C/C++ CI](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml/badge.svg)](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml)
# GDNative Based Git Plugin for Godot Version Control Editor 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.
> Planned for Godot 4.0 since Godot 3.2+. Look for other branches for support in other Godot releases.
**Works only for the Godot 3.2.x-3.4.x releases**
## Installation Instructions
@@ -42,6 +44,18 @@ Required build tools:
2. Run ```. ./build_libs_mac.sh Release```.
3. Run ```scons platform=osx target=release```.
#### Debug build
### Debug build
Replace `Release` with `Debug` and `release` with `debug` in the above instructions for a debug build. You will also have to do the same in the paths mentioned in `demo/git_api.gdnlib` before opening the demo project in Godot.
### Bleeding Edge Builds
> This section onwards is only meant to be used by developers.
Most of the times when new features are being worked on for the Godot VCS Integration, this requires us to make changes in Godot along with this plugin. Thus, this means we need to manually generate the GDNative API from these newer Godot builds and then use them with godot-cpp.
1. Generate `api.json` from Godot executable: `godot --gdnative-generate-json-api api.json`
2. Change directory to `godot-cpp`: `cd godot-cpp`
3. Build the C++ bindings: `scons platform=<platform> target=<target> generate_bindings=yes bits=64 use_custom_api_file=yes custom_api_file=<path/to/api.json> -j <number of CPUs>`
4. Change directory up one level: `cd ..`
5. Build the plugin as usual: `scons platform=<windows> target=<target>`

View File

@@ -11,14 +11,14 @@ opts.Add(EnumVariable('target', "Compilation target", 'debug', ['d', 'debug', 'r
opts.Add(EnumVariable('platform', "Compilation platform", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(EnumVariable('p', "Compilation target, alias for 'platform'", '', ['', 'windows', 'x11', 'linux', 'osx']))
opts.Add(BoolVariable('use_llvm', "Use the LLVM / Clang compiler", 'no'))
opts.Add(PathVariable('target_path', 'The path where the lib is installed.', 'demo/bin/'))
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.', 'libgitapi', PathVariable.PathAccept))
# Local dependency paths, adapt them to your setup
godot_headers_path = "godot-cpp/godot_headers/"
godot_headers_path = "godot-cpp/godot-headers/"
cpp_bindings_path = "godot-cpp/"
cpp_library = "libgodot-cpp"
libgit2_lib_path = "demo/bin/"
libgit2_lib_path = "demo/addons/godot-git-plugin/"
libgit2_include_path = "godot-git-plugin/thirdparty/libgit2/include/"
# only support 64 at this time..
@@ -45,11 +45,11 @@ if env['platform'] == "osx":
cpp_library += '.osx'
libgit2_lib_path += 'osx/'
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
env.Append(CCFLAGS = ['-g','-O2', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
else:
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64'])
env.Append(CCFLAGS = ['-g','-O3', '-arch', 'x86_64', '-arch', 'arm64', '-std=c++17'])
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
elif env['platform'] in ('x11', 'linux'):
env['target_path'] += 'x11/'
@@ -68,7 +68,7 @@ elif env['platform'] == "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(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS'])
env.Append(CCFLAGS = ['-DWIN32', '-D_WIN32', '-D_WINDOWS', '-W3', '-GR', '-D_CRT_SECURE_NO_WARNINGS', '/std:c++17'])
env.Append(LIBS=['Advapi32'])
if env['target'] in ('debug', 'd'):
env.Append(CCFLAGS = ['-EHsc', '-D_DEBUG', '-MDd'])
@@ -82,7 +82,10 @@ else:
cpp_library += '.release'
env['target_path'] += 'release/'
cpp_library += '.' + str(bits)
if env['platform'] == 'osx':
cpp_library += '.universal'
else:
cpp_library += '.' + str(bits)
# make sure our binding library properly includes
env.Append(CPPPATH=['.', godot_headers_path, cpp_bindings_path + 'include/', cpp_bindings_path + 'include/core/', cpp_bindings_path + 'include/gen/'])

1062
THIRDPARTY.md Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +0,0 @@
environment:
matrix:
- vs_version: 16
os: Visual Studio 2019
build: off
configuration:
- release
- debug
platform:
- x64
install:
- call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvars64.bat"
- curl -LO https://downloads.sourceforge.net/project/scons/scons-local/3.1.2/scons-local-3.1.2.zip
- unzip scons-local-3.1.2.zip
- .\build_libs.bat %configuration%
- cd ..
- .\scons.bat platform=windows target=%configuration% -j2

View File

@@ -8,17 +8,15 @@ del /F CMakeCache.txt
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DWINHTTP=OFF
cmake --build . --config %1
cd ../../../../
mkdir "demo/bin/win64/"
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\bin\win64\
mkdir "demo/addons/godot-git-plugin/win64/"
copy godot-git-plugin\thirdparty\libgit2\build\%1\git2.lib demo\addons\godot-git-plugin\win64\git2.lib
if "%CI%"=="" (
echo Non-CI build detected
set SCONS=scons
) else (
echo CI build detected
set SCONS=..\scons.bat
)
cd godot-cpp\
%SCONS% platform=windows target=%1 generate_bindings=yes bits=64
scons platform=windows target=%1 generate_bindings=yes bits=64 -j%NUMBER_OF_PROCESSORS%
cd ..

View File

@@ -4,20 +4,21 @@ git submodule update --init --recursive;
cd godot-git-plugin/thirdparty/libgit2/
mkdir build
cd build/
rm CMakeCache.txt
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON
rm -f CMakeCache.txt
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DREGEX_BACKEND=builtin
cmake --build . --config $1
cd ../../../../
mkdir -p "demo/bin/x11/"
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/bin/x11/libgit2.a"
mkdir -p "demo/addons/godot-git-plugin/x11/"
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/addons/godot-git-plugin/x11/libgit2.a"
if [ -z "$CI" ]
then
echo "Non-CI run was detected"
echo "Non-CI run was detected"
else
echo "CI run was detected"
fi
cd godot-cpp/;
scons platform=linux target=$1 generate_bindings=yes bits=64;
CORES=$(grep -c \^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
scons platform=linux target=$1 generate_bindings=yes bits=64 -j$CORES;
cd ..

View File

@@ -1,23 +1,31 @@
#!/bin/sh
git submodule init;
git submodule update --init --recursive;
cd godot-git-plugin/thirdparty/libgit2/
mkdir build
cd build/
rm CMakeCache.txt
cmake .. -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
rm -f CMakeCache.txt
cmake .. -DCMAKE_C_FLAGS="-arch arm64 -arch x86_64" -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DBUILD_CLAR=OFF -DBUILD_EXAMPLES=OFF -DUSE_SSH=OFF -DUSE_HTTPS=OFF -DUSE_BUNDLED_ZLIB=ON -DUSE_ICONV=OFF
cmake --build . --config $1
cd ../../../../
mkdir -p "demo/bin/osx/"
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/bin/osx/libgit2.a"
mkdir -p "demo/addons/godot-git-plugin/osx/"
cp "godot-git-plugin/thirdparty/libgit2/build/libgit2.a" "demo/addons/godot-git-plugin/osx/libgit2.a"
if [ -z "$CI" ]
then
echo "Non-CI run was detected"
echo "Non-CI run was detected"
else
echo "CI run was detected"
fi
cd godot-cpp/;
scons platform=osx target=$1 generate_bindings=yes bits=64;
CORES=$(grep -c ^processor /proc/cpuinfo 2>/dev/null || sysctl -n hw.ncpu)
scons platform=osx target=$1 generate_bindings=yes macos_arch=x86_64 -j$CORES;
scons platform=osx target=$1 generate_bindings=yes macos_arch=arm64 -j$CORES;
shopt -s nocasematch; if [[ "release" =~ "$1" ]]; then
lipo -create ./bin/libgodot-cpp.osx.release.64.a ./bin/libgodot-cpp.osx.release.arm64.a -output ./bin/libgodot-cpp.osx.release.universal.a
else
lipo -create ./bin/libgodot-cpp.osx.debug.64.a ./bin/libgodot-cpp.osx.debug.arm64.a -output ./bin/libgodot-cpp.osx.debug.universal.a
fi
cd ..

View File

@@ -0,0 +1,18 @@
[general]
singleton=true
load_once=true
symbol_prefix="godot_"
reloadable=false
[entry]
OSX.64="res://addons/godot-git-plugin/osx/release/libgitapi.dylib"
Windows.64="res://addons/godot-git-plugin/win64/release/libgitapi.dll"
X11.64="res://addons/godot-git-plugin/x11/release/libgitapi.so"
[dependencies]
OSX.64=[ ]
Windows.64=[ ]
X11.64=[ ]

View File

@@ -1,6 +1,6 @@
[gd_resource type="NativeScript" load_steps=2 format=2]
[ext_resource path="res://git_api.gdnlib" type="GDNativeLibrary" id=1]
[ext_resource path="res://addons/godot-git-plugin/git_api.gdnlib" type="GDNativeLibrary" id=1]
[resource]
resource_name = "GitAPI"

View File

@@ -0,0 +1,7 @@
[plugin]
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="ChronicallySerious"
version="v1.2.2"
script="git_api.gdns"

Binary file not shown.

View File

@@ -1,18 +0,0 @@
[general]
singleton=true
load_once=true
symbol_prefix="godot_"
reloadable=false
[entry]
OSX.64="res://bin/osx/release/libgitapi.dylib"
Windows.64="res://bin/win64/release/libgitapi.dll"
X11.64="res://bin/x11/release/libgitapi.so"
[dependencies]
OSX.64=[ ]
Windows.64=[ ]
X11.64=[ ]

View File

@@ -12,7 +12,7 @@ _global_script_classes=[ {
"base": "",
"class": "GitAPI",
"language": "NativeScript",
"path": "res://git_api.gdns"
"path": "res://addons/godot-git-plugin/git_api.gdns"
} ]
_global_script_class_icons={
"GitAPI": ""
@@ -26,7 +26,7 @@ config/icon="res://icon.png"
[gdnative]
singletons=[ "res://git_api.gdnlib" ]
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
[rendering]

View File

@@ -3,7 +3,7 @@
# chosen value in case the base style changes (last sync: Clang 6.0.1).
---
### General config, applies to all languages ###
BasedOnStyle: LLVM
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: DontAlign
# AlignConsecutiveAssignments: false
@@ -13,9 +13,9 @@ AlignAfterOpenBracket: DontAlign
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
# AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: true
# AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: true
# AllowShortIfStatementsOnASingleLine: false
# AllowShortLoopsOnASingleLine: false
# AlwaysBreakAfterDefinitionReturnType: None
# AlwaysBreakAfterReturnType: None
@@ -46,7 +46,7 @@ BreakBeforeTernaryOperators: false
# BreakConstructorInitializersBeforeComma: false
BreakConstructorInitializers: AfterColon
# BreakStringLiterals: true
ColumnLimit: 0
ColumnLimit: 0
# CommentPragmas: '^ IWYU pragma:'
# CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: true
@@ -63,20 +63,20 @@ Cpp11BracedListStyle: false
# - BOOST_FOREACH
# IncludeBlocks: Preserve
IncludeCategories:
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: '^<.*'
Priority: 3
- Regex: '".*"'
Priority: 1
- Regex: '^<.*\.h>'
Priority: 2
- Regex: "^<.*"
Priority: 3
# IncludeIsMainRegex: '(Test)?$'
IndentCaseLabels: true
# IndentPPDirectives: None
IndentWidth: 4
IndentWidth: 4
# IndentWrappedFunctionNames: false
# JavaScriptQuotes: Leave
# JavaScriptWrapImports: true
# KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: false
# MacroBlockBegin: ''
# MacroBlockEnd: ''
# MaxEmptyLinesToKeep: 1
@@ -107,21 +107,30 @@ IndentWidth: 4
# SpacesInCStyleCastParentheses: false
# SpacesInParentheses: false
# SpacesInSquareBrackets: false
TabWidth: 4
UseTab: Always
TabWidth: 4
UseTab: Always
---
### C++ specific config ###
Language: Cpp
Standard: Cpp03
Language: Cpp
Standard: Cpp11
---
### ObjC specific config ###
Language: ObjC
Standard: Cpp03
Language: ObjC
Standard: Cpp11
ObjCBlockIndentWidth: 4
# ObjCSpaceAfterProperty: false
# ObjCSpaceBeforeProtocolList: true
---
### Java specific config ###
Language: Java
Language: Java
# BreakAfterJavaFieldAnnotations: false
...
JavaImportGroups:
[
"org.godotengine",
"android",
"androidx",
"com.android",
"com.google",
"java",
"javax",
]

View File

@@ -3,7 +3,6 @@
#include <Godot.hpp>
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
godot::Godot::gdnative_init(o);
}
@@ -11,12 +10,10 @@ extern "C" void GDN_EXPORT godot_gdnative_singleton(godot_gdnative_init_options
}
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>();

View File

@@ -5,7 +5,6 @@ namespace godot {
GitAPI *GitAPI::singleton = NULL;
void GitAPI::_register_methods() {
register_method("_process", &GitAPI::_process);
register_method("_commit", &GitAPI::_commit);
@@ -21,9 +20,7 @@ void GitAPI::_register_methods() {
}
void GitAPI::_commit(const String p_msg) {
if (!can_commit) {
godot::Godot::print("Git API cannot commit. Check previous errors.");
return;
}
@@ -36,14 +33,11 @@ void GitAPI::_commit(const String p_msg) {
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
for (int i = 0; i < staged_files.size(); i++) {
String file_path = staged_files[i];
File *file = File::_new();
if (file->file_exists(file_path)) {
GIT2_CALL(git_index_add_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
} else {
GIT2_CALL(git_index_remove_bypath(repo_index, file_path.alloc_c_string()), "Could not add file by path", NULL);
}
}
@@ -79,27 +73,21 @@ void GitAPI::_commit(const String p_msg) {
}
void GitAPI::_stage_file(const String p_file_path) {
if (staged_files.find(p_file_path) == -1) {
staged_files.push_back(p_file_path);
}
}
void GitAPI::_unstage_file(const String p_file_path) {
if (staged_files.find(p_file_path) != -1) {
staged_files.erase(p_file_path);
}
}
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(
"# Import cache\n"
@@ -113,7 +101,6 @@ void GitAPI::create_gitignore_and_gitattributes() {
}
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"
@@ -138,14 +125,12 @@ void GitAPI::create_gitignore_and_gitattributes() {
}
bool GitAPI::create_initial_commit() {
git_signature *sig;
git_oid tree_id, commit_id;
git_index *repo_index;
git_tree *tree;
if (git_signature_default(&sig, repo) != 0) {
godot::Godot::print_error("Unable to create a commit signature. Perhaps 'user.name' and 'user.email' are not set. Set default user name and user email by `git config` and initialize again", __func__, __FILE__, __LINE__);
return false;
}
@@ -176,12 +161,10 @@ bool GitAPI::create_initial_commit() {
}
bool GitAPI::_is_vcs_initialized() {
return is_initialized;
}
Dictionary GitAPI::_get_modified_files_data() {
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES;
@@ -193,41 +176,32 @@ Dictionary GitAPI::_get_modified_files_data() {
Dictionary diff; // Schema is <file_path, status>
size_t count = git_status_list_entrycount(statuses);
for (size_t i = 0; i < count; ++i) {
const git_status_entry *entry = git_status_byindex(statuses, i);
String path;
if (entry->index_to_workdir) {
path = entry->index_to_workdir->new_file.path;
} else {
path = entry->head_to_index->new_file.path;
}
switch (entry->status) {
case GIT_STATUS_INDEX_NEW:
case GIT_STATUS_WT_NEW: {
diff[path] = 0;
} break;
case GIT_STATUS_INDEX_MODIFIED:
case GIT_STATUS_WT_MODIFIED: {
diff[path] = 1;
} break;
case GIT_STATUS_INDEX_RENAMED:
case GIT_STATUS_WT_RENAMED: {
diff[path] = 2;
} break;
case GIT_STATUS_INDEX_DELETED:
case GIT_STATUS_WT_DELETED: {
diff[path] = 3;
} break;
case GIT_STATUS_INDEX_TYPECHANGE:
case GIT_STATUS_WT_TYPECHANGE: {
diff[path] = 4;
} break;
}
@@ -239,7 +213,6 @@ Dictionary GitAPI::_get_modified_files_data() {
}
Array GitAPI::_get_file_diff(const String file_path) {
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff;
char *pathspec = file_path.alloc_c_string();
@@ -261,39 +234,32 @@ Array GitAPI::_get_file_diff(const String file_path) {
}
String GitAPI::_get_project_name() {
return String("project");
}
String GitAPI::_get_vcs_name() {
return "Git";
}
bool GitAPI::_initialize(const String p_project_root_path) {
ERR_FAIL_COND_V(p_project_root_path == "", false);
singleton = this;
int init = git_libgit2_init();
if (init > 1) {
WARN_PRINT("Multiple libgit2 instances are running");
}
if (repo) {
return true;
}
can_commit = true;
GIT2_CALL(git_repository_init(&repo, p_project_root_path.alloc_c_string(), 0), "Could not initialize repository", NULL);
if (git_repository_head_unborn(repo) == 1) {
create_gitignore_and_gitattributes();
if (!create_initial_commit()) {
godot::Godot::print_error("Initial commit could not be created. Commit functionality will not work.", __func__, __FILE__, __LINE__);
can_commit = false;
}
@@ -306,7 +272,6 @@ bool GitAPI::_initialize(const String p_project_root_path) {
}
bool GitAPI::_shut_down() {
git_repository_free(repo);
GIT2_CALL(git_libgit2_shutdown(), "Could not shutdown Git Addon", NULL);

View File

@@ -1,23 +1,22 @@
#ifndef GIT_API_H
#define GIT_API_H
#include <Godot.hpp>
#include <Button.hpp>
#include <Control.hpp>
#include <EditorVCSInterface.hpp>
#include <PanelContainer.hpp>
#include <Directory.hpp>
#include <EditorVCSInterface.hpp>
#include <File.hpp>
#include <Godot.hpp>
#include <PanelContainer.hpp>
#include <git_common.h>
#include <allocation_defs.h>
#include <git_common.h>
#include <git2.h>
namespace godot {
class GitAPI : public EditorVCSInterface {
GODOT_CLASS(GitAPI, EditorVCSInterface)
static GitAPI *singleton;

View File

@@ -1,33 +1,27 @@
#include <git_common.h>
#include <git_api.h>
#include <git_common.h>
void check_git2_errors(int error, const char *message, const char *extra) {
const git_error *lg2err;
const char *lg2msg = "", *lg2spacer = "";
if (!error) {
return;
}
if ((lg2err = git_error_last()) != NULL && lg2err->message != NULL) {
lg2msg = lg2err->message;
lg2spacer = " - ";
}
if (extra) {
printf("Git API: %s '%s' [%d]%s%s\n", message, extra, error, lg2spacer, lg2msg);
} else {
printf("Git API: %s [%d]%s%s\n", message, error, lg2spacer, lg2msg);
}
}
extern "C" int diff_line_callback_function(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload) {
// First we NULL terminate the line text incoming
char *content = new char[line->content_len + 1];
memcpy(content, line->content, line->content_len);
@@ -36,14 +30,15 @@ extern "C" int diff_line_callback_function(const git_diff_delta *delta, const gi
godot::String prefix = "";
switch (line->origin) {
case GIT_DIFF_LINE_DEL_EOFNL:
case GIT_DIFF_LINE_DELETION:
prefix = "-"; break;
prefix = "-";
break;
case GIT_DIFF_LINE_ADD_EOFNL:
case GIT_DIFF_LINE_ADDITION:
prefix = "+"; break;
prefix = "+";
break;
}
godot::String content_str = content;

View File

@@ -1,6 +1,8 @@
#ifndef GIT_COMMON_H
#define GIT_COMMON_H
#include <cstdio>
#include <Godot.hpp>
#include <git2.h>

View File

@@ -1,3 +0,0 @@
# This file lists all thirdparty libraries used in this plugin with the latest master commit link of when source was picked up
libgit2 v1.0: https://github.com/libgit2/libgit2/commit/7d3c7057f0e774aecd6fc4ef8333e69e5c4873e0

62
release.sh Executable file
View File

@@ -0,0 +1,62 @@
#!/bin/bash
# This script is used to create releases for this plugin. This is mostly a helper script for the maintainer.
echo "Enter the new version number (e.g. 1.2.1):"
read version
echo "Enter the Windows x64 release ZIP URL:"
read windowsZIPURL
echo "Enter the Linux x64 release ZIP URL:"
read linuxZIPURL
echo "Enter the MacOS universal release ZIP URL:"
read macZIPURL
# wget-ing the github.com URL gives a 404, so we use the method proposed here - https://github.com/actions/upload-artifact/issues/51#issuecomment-735989475
windowsZIPURL=${windowsZIPURL/github.com/nightly.link}
linuxZIPURL=${linuxZIPURL/github.com/nightly.link}
macZIPURL=${macZIPURL/github.com/nightly.link}
wget -O windows.zip $windowsZIPURL
wget -O x11.zip $linuxZIPURL
wget -O mac.zip $macZIPURL
unzip windows.zip -d windows/
unzip x11.zip -d x11/
unzip mac.zip -d mac/
releasePath=godot-git-plugin-v$version
mkdir $releasePath
cp -r windows/addons/ $releasePath
addonsPath=$releasePath/addons
pluginPath=$addonsPath/godot-git-plugin
mkdir $pluginPath/x11
mkdir $pluginPath/osx
cp -r x11/addons/godot-git-plugin/x11/ $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
cp THIRDPARTY.md $pluginPath/THIRDPARTY.md
rm -f $pluginPath/x11/libgit2.a
rm -f $pluginPath/osx/libgit2.a
rm -f $pluginPath/win64/git2.lib
pushd $releasePath
zip -r $releasePath.zip addons/
popd
mv $releasePath/$releasePath.zip ./
rm -rf $releasePath
rm -rf windows
rm -rf x11
rm -rf mac
rm windows.zip
rm x11.zip
rm mac.zip