mirror of
https://github.com/godotengine/godot-git-plugin.git
synced 2026-01-01 01:48:28 +03:00
Compare commits
111 Commits
v1.2.3
...
v3.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
63d72ffc21 | ||
|
|
6a6f7d1810 | ||
|
|
820c623912 | ||
|
|
1aea2dd13f | ||
|
|
982cee2d85 | ||
|
|
5f100fb6e4 | ||
|
|
b7d0cfda02 | ||
|
|
9ccf7e98a3 | ||
|
|
fb772f3623 | ||
|
|
8fcf6e434d | ||
|
|
67b0cdf976 | ||
|
|
ccac80bb0e | ||
|
|
dc88f7a585 | ||
|
|
0e8de32587 | ||
|
|
35443ecfaa | ||
|
|
a1b0c41c72 | ||
|
|
893bcd922b | ||
|
|
1cdc05e9e0 | ||
|
|
91344c5e68 | ||
|
|
20cb08003e | ||
|
|
df5b0139d9 | ||
|
|
084c7fcfe2 | ||
|
|
9acff81056 | ||
|
|
a2ecf96e04 | ||
|
|
34a785dc72 | ||
|
|
6e94df54df | ||
|
|
424cc61657 | ||
|
|
51b068f043 | ||
|
|
b603dcadaa | ||
|
|
acece95267 | ||
|
|
2296d3e393 | ||
|
|
ff40154485 | ||
|
|
93c175cd1d | ||
|
|
f029aa555c | ||
|
|
0029af37eb | ||
|
|
521341e7bf | ||
|
|
d0c59416d1 | ||
|
|
4b5bf09fd0 | ||
|
|
8b930f1218 | ||
|
|
6c53f46d8f | ||
|
|
616c26c2c9 | ||
|
|
2e3afd8379 | ||
|
|
18e18fe3f8 | ||
|
|
27a10c7029 | ||
|
|
7a08c914fe | ||
|
|
acc0901a66 | ||
|
|
97db5d73e6 | ||
|
|
ad9a38716b | ||
|
|
ceb66815c9 | ||
|
|
a63ee9d415 | ||
|
|
43b189a8ee | ||
|
|
c48f2efadc | ||
|
|
af8149ffa9 | ||
|
|
2463cc8c7e | ||
|
|
4620542c13 | ||
|
|
78caec5a51 | ||
|
|
0b09051fc3 | ||
|
|
3e955b9022 | ||
|
|
abeb17532b | ||
|
|
2095757996 | ||
|
|
b914319c20 | ||
|
|
a6772e0d3f | ||
|
|
4119ad2c74 | ||
|
|
76dfd5a143 | ||
|
|
8d21ddc183 | ||
|
|
14100de179 | ||
|
|
140dd2675a | ||
|
|
0d7f68c6c6 | ||
|
|
770cb4ca72 | ||
|
|
5cd4ac47fd | ||
|
|
84fa17720c | ||
|
|
b0b3eba3ee | ||
|
|
a21e028cde | ||
|
|
03d8f02c3d | ||
|
|
0967424cb0 | ||
|
|
f73f6fb4b5 | ||
|
|
2c12788337 | ||
|
|
fe69fa2de7 | ||
|
|
41b76d18a7 | ||
|
|
6c3aaad5fb | ||
|
|
753ffce0c8 | ||
|
|
055c9c387a | ||
|
|
569dc7df0c | ||
|
|
a9756150eb | ||
|
|
e6eb3aaddf | ||
|
|
5aa5343d53 | ||
|
|
ac32fcc708 | ||
|
|
15c3bd0ad8 | ||
|
|
d9d92f816b | ||
|
|
eea6826d5e | ||
|
|
3190180025 | ||
|
|
521c70b7f9 | ||
|
|
417084afde | ||
|
|
3ccbc17d6e | ||
|
|
c3ba5b237c | ||
|
|
6cd5a35ed2 | ||
|
|
9ffee64156 | ||
|
|
df3b519cfc | ||
|
|
4a37c872ac | ||
|
|
ee2a7607fa | ||
|
|
b34311b10e | ||
|
|
16fa788ee8 | ||
|
|
9c0b7ee0ec | ||
|
|
4b054772ef | ||
|
|
9d837bde6a | ||
|
|
bcdff66014 | ||
|
|
ff2177c071 | ||
|
|
1780549b7b | ||
|
|
91c50d8f68 | ||
|
|
595d679ca1 | ||
|
|
ec20d82eca |
14
.gitattributes
vendored
Normal file
14
.gitattributes
vendored
Normal file
@@ -0,0 +1,14 @@
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
|
||||
# Ignore some files when exporting to a ZIP.
|
||||
/.github/ export-ignore
|
||||
/godot-cpp/ export-ignore
|
||||
/godot-git-plugin/ export-ignore
|
||||
/thirdparty/ export-ignore
|
||||
/.gitattributes export-ignore
|
||||
/.gitignore export-ignore
|
||||
/.gitmodules export-ignore
|
||||
/api.ci.json export-ignore
|
||||
/build_openssl_universal_oxs.sh export-ignore
|
||||
/SConstruct export-ignore
|
||||
90
.github/workflows/build.yml
vendored
90
.github/workflows/build.yml
vendored
@@ -3,40 +3,25 @@ name: C/C++ CI
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
ubuntu-debug:
|
||||
runs-on: ubuntu-latest
|
||||
linux-x64:
|
||||
runs-on: ubuntu-18.04
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-ubuntu-debug
|
||||
- name: build-linux-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
. ./build_libs.sh Debug
|
||||
scons platform=x11 target=debug
|
||||
scons platform=linux target=editor generate_bindings=yes -j $(nproc)
|
||||
ldd demo/addons/godot-git-plugin/linux/*.so
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-ubuntu-debug-${{ github.sha }}
|
||||
name: libgit_plugin.linux.x86_64.editor.so-${{ 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
|
||||
windows-x64:
|
||||
runs-on: windows-2019
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v2
|
||||
@@ -44,67 +29,32 @@ jobs:
|
||||
python-version: "3.x"
|
||||
architecture: "x64"
|
||||
- uses: ilammy/msvc-dev-cmd@v1
|
||||
- name: build-windows-debug
|
||||
- name: build-windows-editor-x64
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
pip3 install --user scons
|
||||
./build_libs.bat Debug
|
||||
scons platform=windows target=debug
|
||||
scons platform=windows target=editor generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
|
||||
dumpbin /dependents .\demo\addons\godot-git-plugin\win64\*.dll
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: godot-git-plugin-windows-debug-${{ github.sha }}
|
||||
name: libgit_plugin.windows.x86_64.editor.dll-${{ 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:
|
||||
macos-universal:
|
||||
runs-on: macos-11
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: build-macos-debug
|
||||
- name: build-macos-editor-universal
|
||||
run: |
|
||||
git submodule update --init --recursive
|
||||
brew install scons
|
||||
. ./build_libs_mac.sh Debug
|
||||
scons platform=osx target=debug use_llvm=yes
|
||||
scons platform=macos target=editor generate_bindings=yes 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
|
||||
- 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 }}
|
||||
name: libgit_plugin.macos.universal.editor.dylib-${{ github.sha }}
|
||||
if-no-files-found: error
|
||||
path: |
|
||||
demo/
|
||||
|
||||
21
.gitignore
vendored
21
.gitignore
vendored
@@ -1,8 +1,12 @@
|
||||
# SConstruct db
|
||||
*.dblite
|
||||
|
||||
# Godot ignores
|
||||
demo/.godot/
|
||||
|
||||
# Godot Serialisations
|
||||
api.json
|
||||
extension_api.json
|
||||
!/ci/extension_api.json
|
||||
|
||||
# Visual Studio Cache
|
||||
.vs/
|
||||
@@ -15,11 +19,14 @@ api.json
|
||||
|
||||
# Binaries
|
||||
build/
|
||||
*.obj
|
||||
*.os
|
||||
*.so
|
||||
*.dll
|
||||
*.exp
|
||||
bin/
|
||||
macos/
|
||||
linux/
|
||||
win64/
|
||||
*.lib
|
||||
*.a
|
||||
*.dylib
|
||||
*.obj
|
||||
*.os
|
||||
*.ilk
|
||||
*.pdb
|
||||
!thirdparty/openssl/*
|
||||
|
||||
6
.gitmodules
vendored
6
.gitmodules
vendored
@@ -2,3 +2,9 @@
|
||||
path = godot-cpp
|
||||
url = https://github.com/godotengine/godot-cpp
|
||||
branch = 3.x
|
||||
[submodule "libgit2"]
|
||||
path = thirdparty/git2/libgit2
|
||||
url = https://github.com/libgit2/libgit2
|
||||
[submodule "thirdparty/ssh2/libssh2"]
|
||||
path = thirdparty/ssh2/libssh2
|
||||
url = https://github.com/libssh2/libssh2
|
||||
|
||||
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
|
||||
|
||||
79
README.md
79
README.md
@@ -1,61 +1,74 @@
|
||||
[](https://github.com/godotengine/godot-git-plugin/actions/workflows/build.yml)
|
||||
|
||||
# GDNative Based Git Plugin for Godot Version Control Editor Plugin
|
||||
<img src="/icon.png" width="25%" />
|
||||
|
||||
# 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.
|
||||
|
||||
**Works only for the Godot 3.2.x-3.4.x releases**
|
||||
> Planned for the upcoming version of Godot. Look for other branches for support in other Godot releases.
|
||||
|
||||
## Installation Instructions
|
||||
|
||||
1. Grab the platform binaries here: <https://github.com/godotengine/godot-git-plugin/releases>
|
||||
2. Then read the installation instructions: https://github.com/godotengine/godot-git-plugin/wiki
|
||||
1. Grab the platform binaries here: <https://github.com/godotengine/godot-git-plugin/releases>
|
||||
2. Then read the installation instructions: https://github.com/godotengine/godot-git-plugin/wiki
|
||||
|
||||
## Build Instructions
|
||||
|
||||
### Pre-requisites
|
||||
This section onwards is only meant to be used if you intend to compile the plugin from source.
|
||||
|
||||
Required build tools:
|
||||
### Required Tools
|
||||
|
||||
* [CMake](https://cmake.org/download/) (v3.5.1+)
|
||||
* [SCons](https://scons.org/pages/download.html) (v3.0.1+)
|
||||
- Full copy of the source code. Remember to use `git clone --recursive`.
|
||||
- [SCons](https://scons.org/pages/download.html) (v3.0.1+)
|
||||
- C++17 and C90 compilers detectable by SCons and present in `PATH`.
|
||||
- Platforms Specific Setup
|
||||
- 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.
|
||||
- Linux
|
||||
- Run `sudo apt-get install libssl-dev`, or your local package manager's equivalent.
|
||||
|
||||
### Windows
|
||||
### Release Build
|
||||
|
||||
> MSVC is our recommended compiler for Windows
|
||||
```
|
||||
scons platform=<platform> target=editor -j 6
|
||||
```
|
||||
|
||||
1. Load the x64 command prompt: `x64 Native Tools Command Prompt for VS 20XX`.
|
||||
2. Run ```build_libs.bat Release```.
|
||||
3. Run ```scons platform=windows target=release```
|
||||
> 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/`.
|
||||
|
||||
### Linux
|
||||
For more build options, run `scons platform=<platform> -h`
|
||||
|
||||
> G++ is our recommended compiler for Linux
|
||||
## Dev builds
|
||||
|
||||
1. Prepare script for execution: ```chmod 755 build_libs.sh```
|
||||
2. Run ```. ./build_libs.sh Release```.
|
||||
3. Run ```scons platform=x11 target=release```.
|
||||
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.
|
||||
|
||||
### MacOS
|
||||
If you need to use a custom GDExtension API:
|
||||
|
||||
> G++ and Clang++ are our recommended compilers for MacOS
|
||||
1. Dump the new bindings from the custom Godot build.
|
||||
|
||||
1. Prepare script for execution: ```chmod 755 build_libs_mac.sh```
|
||||
2. Run ```. ./build_libs_mac.sh Release```.
|
||||
3. Run ```scons platform=osx target=release```.
|
||||
```shell
|
||||
cd local/copy/of/godot/source
|
||||
.\bin\godot.xxx --headless --dump-gdextension-interface --dump-extension-api
|
||||
```
|
||||
|
||||
### Debug build
|
||||
2. Build the plugin along with the godot-cpp library.
|
||||
|
||||
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.
|
||||
```
|
||||
scons platform=<platform> target=editor generate_bindings=yes dev_build=yes -j 6
|
||||
```
|
||||
|
||||
### Bleeding Edge Builds
|
||||
> 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.
|
||||
|
||||
> This section onwards is only meant to be used by developers.
|
||||
3. Open the project provided inside `demo/` in the custom Godot build.
|
||||
|
||||
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.
|
||||
To view more options available while recompiling godot-git-plugin, run `scons platform=<platform> -h`.
|
||||
|
||||
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>`
|
||||
---
|
||||
|
||||
## License
|
||||
|
||||
This plugin is under the MIT License. Third-party notices are present in [THIRDPARTY.md](THIRDPARTY.md).
|
||||
|
||||
OpenSSL License Attributions - This product includes software developed by the OpenSSL Project for use in the OpenSSL Toolkit. (http://www.openssl.org/). This product includes cryptographic software written by Eric Young (eay@cryptsoft.com)
|
||||
|
||||
117
SConstruct
117
SConstruct
@@ -1,104 +1,45 @@
|
||||
#!python
|
||||
import os, subprocess
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
|
||||
EnsureSConsVersion(3, 0, 0)
|
||||
EnsurePythonVersion(3, 5)
|
||||
|
||||
opts = Variables([], ARGUMENTS)
|
||||
|
||||
# Gets the standard flags CC, CCX, etc.
|
||||
env = DefaultEnvironment()
|
||||
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', '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/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/"
|
||||
cpp_bindings_path = "godot-cpp/"
|
||||
cpp_library = "libgodot-cpp"
|
||||
libgit2_lib_path = "demo/addons/godot-git-plugin/"
|
||||
libgit2_include_path = "godot-git-plugin/thirdparty/libgit2/include/"
|
||||
|
||||
# only support 64 at this time..
|
||||
bits = 64
|
||||
opts.Add(PathVariable("target_path",
|
||||
"The path where the lib is installed.", "demo/addons/godot-git-plugin/"))
|
||||
opts.Add(PathVariable("target_name", "The library name.",
|
||||
"libgit_plugin", PathVariable.PathAccept))
|
||||
opts.Add(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))
|
||||
|
||||
# Updates the environment with the option variables.
|
||||
opts.Update(env)
|
||||
|
||||
# Process some arguments
|
||||
if env['use_llvm']:
|
||||
env['CC'] = 'clang'
|
||||
env['CXX'] = 'clang++'
|
||||
if ARGUMENTS.get("custom_api_file", "") != "":
|
||||
ARGUMENTS["custom_api_file"] = "../" + ARGUMENTS["custom_api_file"]
|
||||
|
||||
if env['p'] != '':
|
||||
env['platform'] = env['p']
|
||||
ARGUMENTS["target"] = "editor"
|
||||
env = SConscript("godot-cpp/SConstruct").Clone()
|
||||
opts.Update(env)
|
||||
|
||||
if env['platform'] == '':
|
||||
print("No valid target platform selected.")
|
||||
quit();
|
||||
Export("env")
|
||||
|
||||
# Check our platform specifics
|
||||
if env['platform'] == "osx":
|
||||
env['target_path'] += 'osx/'
|
||||
cpp_library += '.osx'
|
||||
libgit2_lib_path += 'osx/'
|
||||
if env['target'] in ('debug', 'd'):
|
||||
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', '-arch', 'arm64', '-std=c++17'])
|
||||
env.Append(LINKFLAGS = ['-arch', 'x86_64', '-arch', 'arm64'])
|
||||
SConscript("thirdparty/SCsub")
|
||||
|
||||
elif env['platform'] in ('x11', 'linux'):
|
||||
env['target_path'] += 'x11/'
|
||||
cpp_library += '.linux'
|
||||
libgit2_lib_path += 'x11/'
|
||||
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'
|
||||
libgit2_lib_path += 'win64/'
|
||||
# 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(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'])
|
||||
else:
|
||||
env.Append(CCFLAGS = ['-O2', '-EHsc', '-DNDEBUG', '-MD'])
|
||||
|
||||
if env['target'] in ('debug', 'd'):
|
||||
cpp_library += '.debug'
|
||||
env['target_path'] += 'debug/'
|
||||
else:
|
||||
cpp_library += '.release'
|
||||
env['target_path'] += 'release/'
|
||||
|
||||
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/'])
|
||||
env.Append(LIBPATH=[cpp_bindings_path + 'bin/', libgit2_lib_path])
|
||||
env.Append(LIBS=[cpp_library, 'git2'])
|
||||
|
||||
# tweak this if you want to use different folders, or more folders, to store your source code in.
|
||||
env.Append(CPPPATH=['godot-git-plugin/src/', libgit2_include_path])
|
||||
sources = Glob('godot-git-plugin/src/*.cpp')
|
||||
|
||||
library = env.SharedLibrary(target=env['target_path'] + env['target_name'] , source=sources)
|
||||
|
||||
Default(library)
|
||||
SConscript("godot-git-plugin/SCsub")
|
||||
|
||||
# Generates help for the -h scons option.
|
||||
Help(opts.GenerateHelpText(env))
|
||||
|
||||
297
THIRDPARTY.md
297
THIRDPARTY.md
@@ -2,8 +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/99e9dd1d9396ed3af40678263b509078e5265ffc
|
||||
2. libgit2/libgit2 - GPLv2 with a special Linking Exception - https://github.com/libgit2/libgit2/commit/7d3c7057f0e774aecd6fc4ef8333e69e5c4873e0
|
||||
1. godotengine/godot-cpp - MIT License - https://github.com/godotengine/godot-cpp/tree/02336831735fd6affbe0a6fa252ec98d3e78120c
|
||||
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
|
||||
|
||||
## License Texts
|
||||
|
||||
@@ -12,7 +17,7 @@ The Godot Git Plugin source code uses the following third-party source code:
|
||||
```
|
||||
# MIT License
|
||||
|
||||
Copyright (c) 2017-2021 Godot Engine contributors.
|
||||
Copyright (c) 2017-2022 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
|
||||
@@ -31,7 +36,6 @@ 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.
|
||||
|
||||
```
|
||||
|
||||
### libgit2/libgit2
|
||||
@@ -459,7 +463,7 @@ The GNU C Library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
|
||||
The GNU C Library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
@@ -1059,4 +1063,287 @@ THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED
|
||||
WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
Portions of the OpenSSL headers are included under the OpenSSL license:
|
||||
|
||||
Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
All rights reserved.
|
||||
|
||||
This package is an SSL implementation written
|
||||
by Eric Young (eay@cryptsoft.com).
|
||||
The implementation was written so as to conform with Netscapes SSL.
|
||||
|
||||
This library is free for commercial and non-commercial use as long as
|
||||
the following conditions are aheared to. The following conditions
|
||||
apply to all code found in this distribution, be it the RC4, RSA,
|
||||
lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
included with this distribution is covered by the same copyright terms
|
||||
except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
|
||||
Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
the code are not to be removed.
|
||||
If this package is used in a product, Eric Young should be given attribution
|
||||
as the author of the parts of the library used.
|
||||
This can be in the form of a textual message at program startup or
|
||||
in documentation (online or textual) provided with the package.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
1. Redistributions of source code must retain the copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
3. All advertising materials mentioning features or use of this software
|
||||
must display the following acknowledgement:
|
||||
"This product includes cryptographic software written by
|
||||
Eric Young (eay@cryptsoft.com)"
|
||||
The word 'cryptographic' can be left out if the rouines from the library
|
||||
being used are not cryptographic related :-).
|
||||
4. If you include any Windows specific code (or a derivative thereof) from
|
||||
the apps directory (application code) you must include an acknowledgement:
|
||||
"This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
The licence and distribution terms for any publically available version or
|
||||
derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
copied and put under another distribution licence
|
||||
[including the GNU Public Licence.]
|
||||
|
||||
====================================================================
|
||||
Copyright (c) 1998-2007 The OpenSSL Project. All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
3. All advertising materials mentioning features or use of this
|
||||
software must display the following acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
|
||||
4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
endorse or promote products derived from this software without
|
||||
prior written permission. For written permission, please contact
|
||||
openssl-core@openssl.org.
|
||||
|
||||
5. Products derived from this software may not be called "OpenSSL"
|
||||
nor may "OpenSSL" appear in their names without prior written
|
||||
permission of the OpenSSL Project.
|
||||
|
||||
6. Redistributions of any form whatsoever must retain the following
|
||||
acknowledgment:
|
||||
"This product includes software developed by the OpenSSL Project
|
||||
for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
```
|
||||
|
||||
### libssh2/libssh2
|
||||
|
||||
```
|
||||
/* Copyright (c) 2004-2007 Sara Golemon <sarag@libssh2.org>
|
||||
* Copyright (c) 2005,2006 Mikhail Gusarov <dottedmag@dottedmag.net>
|
||||
* Copyright (c) 2006-2007 The Written Word, Inc.
|
||||
* Copyright (c) 2007 Eli Fant <elifantu@mail.ru>
|
||||
* Copyright (c) 2009-2021 Daniel Stenberg
|
||||
* Copyright (C) 2008, 2009 Simon Josefsson
|
||||
* Copyright (c) 2000 Markus Friedl
|
||||
* Copyright (c) 2015 Microsoft Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms,
|
||||
* with or without modification, are permitted provided
|
||||
* that the following conditions are met:
|
||||
*
|
||||
* Redistributions of source code must retain the above
|
||||
* copyright notice, this list of conditions and the
|
||||
* following disclaimer.
|
||||
*
|
||||
* Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following
|
||||
* disclaimer in the documentation and/or other materials
|
||||
* provided with the distribution.
|
||||
*
|
||||
* Neither the name of the copyright holder nor the names
|
||||
* of any other contributors may be used to endorse or
|
||||
* promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND
|
||||
* CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
|
||||
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
|
||||
* OF SUCH DAMAGE.
|
||||
*/
|
||||
```
|
||||
|
||||
### OpenSSL
|
||||
|
||||
```
|
||||
|
||||
LICENSE ISSUES
|
||||
==============
|
||||
|
||||
The OpenSSL toolkit stays under a double license, i.e. both the conditions of
|
||||
the OpenSSL License and the original SSLeay license apply to the toolkit.
|
||||
See below for the actual license texts.
|
||||
|
||||
OpenSSL License
|
||||
---------------
|
||||
|
||||
/* ====================================================================
|
||||
* Copyright (c) 1998-2019 The OpenSSL Project. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
*
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* 3. All advertising materials mentioning features or use of this
|
||||
* software must display the following acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
|
||||
*
|
||||
* 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
|
||||
* endorse or promote products derived from this software without
|
||||
* prior written permission. For written permission, please contact
|
||||
* openssl-core@openssl.org.
|
||||
*
|
||||
* 5. Products derived from this software may not be called "OpenSSL"
|
||||
* nor may "OpenSSL" appear in their names without prior written
|
||||
* permission of the OpenSSL Project.
|
||||
*
|
||||
* 6. Redistributions of any form whatsoever must retain the following
|
||||
* acknowledgment:
|
||||
* "This product includes software developed by the OpenSSL Project
|
||||
* for use in the OpenSSL Toolkit (http://www.openssl.org/)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
|
||||
* EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
|
||||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
||||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
||||
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
|
||||
* OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
* ====================================================================
|
||||
*
|
||||
* This product includes cryptographic software written by Eric Young
|
||||
* (eay@cryptsoft.com). This product includes software written by Tim
|
||||
* Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
*/
|
||||
|
||||
Original SSLeay License
|
||||
-----------------------
|
||||
|
||||
/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
|
||||
* All rights reserved.
|
||||
*
|
||||
* This package is an SSL implementation written
|
||||
* by Eric Young (eay@cryptsoft.com).
|
||||
* The implementation was written so as to conform with Netscapes SSL.
|
||||
*
|
||||
* This library is free for commercial and non-commercial use as long as
|
||||
* the following conditions are aheared to. The following conditions
|
||||
* apply to all code found in this distribution, be it the RC4, RSA,
|
||||
* lhash, DES, etc., code; not just the SSL code. The SSL documentation
|
||||
* included with this distribution is covered by the same copyright terms
|
||||
* except that the holder is Tim Hudson (tjh@cryptsoft.com).
|
||||
*
|
||||
* Copyright remains Eric Young's, and as such any Copyright notices in
|
||||
* the code are not to be removed.
|
||||
* If this package is used in a product, Eric Young should be given attribution
|
||||
* as the author of the parts of the library used.
|
||||
* This can be in the form of a textual message at program startup or
|
||||
* in documentation (online or textual) provided with the package.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* "This product includes cryptographic software written by
|
||||
* Eric Young (eay@cryptsoft.com)"
|
||||
* The word 'cryptographic' can be left out if the rouines from the library
|
||||
* being used are not cryptographic related :-).
|
||||
* 4. If you include any Windows specific code (or a derivative thereof) from
|
||||
* the apps directory (application code) you must include an acknowledgement:
|
||||
* "This product includes software written by Tim Hudson (tjh@cryptsoft.com)"
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY ERIC YOUNG ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
|
||||
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
||||
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* The licence and distribution terms for any publically available version or
|
||||
* derivative of this code cannot be changed. i.e. this code cannot simply be
|
||||
* copied and put under another distribution licence
|
||||
* [including the GNU Public Licence.]
|
||||
*/
|
||||
```
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
git submodule init
|
||||
git submodule update --init --recursive
|
||||
|
||||
cd godot-git-plugin\thirdparty\libgit2\
|
||||
mkdir build
|
||||
cd build\
|
||||
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/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
|
||||
) else (
|
||||
echo CI build detected
|
||||
)
|
||||
|
||||
cd godot-cpp\
|
||||
scons platform=windows target=%1 generate_bindings=yes bits=64 -j%NUMBER_OF_PROCESSORS%
|
||||
cd ..
|
||||
@@ -1,24 +0,0 @@
|
||||
git submodule init;
|
||||
git submodule update --init --recursive;
|
||||
|
||||
cd godot-git-plugin/thirdparty/libgit2/
|
||||
mkdir build
|
||||
cd build/
|
||||
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/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"
|
||||
else
|
||||
echo "CI run was detected"
|
||||
fi
|
||||
|
||||
cd godot-cpp/;
|
||||
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 ..
|
||||
@@ -1,31 +0,0 @@
|
||||
#!/bin/sh
|
||||
git submodule init;
|
||||
git submodule update --init --recursive;
|
||||
|
||||
cd godot-git-plugin/thirdparty/libgit2/
|
||||
mkdir build
|
||||
cd build/
|
||||
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/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"
|
||||
else
|
||||
echo "CI run was detected"
|
||||
fi
|
||||
|
||||
cd godot-cpp/;
|
||||
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 ..
|
||||
20
build_openssl_universal_macos.sh
Normal file
20
build_openssl_universal_macos.sh
Normal file
@@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
OPENSSL_VERSION="1.1.1s"
|
||||
|
||||
curl -OL http://www.openssl.org/source/openssl-$OPENSSL_VERSION.tar.gz
|
||||
tar -xzvf openssl-$OPENSSL_VERSION.tar.gz
|
||||
mv openssl-$OPENSSL_VERSION openssl_arm64
|
||||
tar -xzvf openssl-$OPENSSL_VERSION.tar.gz
|
||||
mv openssl-$OPENSSL_VERSION openssl_x86_64
|
||||
cd openssl_arm64
|
||||
./Configure darwin64-arm64-cc
|
||||
make
|
||||
cd ../
|
||||
cd openssl_x86_64
|
||||
./Configure darwin64-x86_64-cc -mmacosx-version-min=10.13
|
||||
make
|
||||
cd ../
|
||||
lipo -create openssl_arm64/libcrypto.a openssl_x86_64/libcrypto.a -output thirdparty/openssl/libcrypto.a
|
||||
lipo -create openssl_arm64/libssl.a openssl_x86_64/libssl.a -output thirdparty/openssl/libssl.a
|
||||
rm openssl-$OPENSSL_VERSION.tar.gz
|
||||
19
demo/.gitattributes
vendored
19
demo/.gitattributes
vendored
@@ -1,17 +1,2 @@
|
||||
# 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
|
||||
# Normalize EOL for all files that Git considers text files.
|
||||
* text=auto eol=lf
|
||||
|
||||
9
demo/.gitignore
vendored
9
demo/.gitignore
vendored
@@ -1,7 +1,2 @@
|
||||
# Import cache
|
||||
.import/
|
||||
|
||||
# Binaries
|
||||
bin/
|
||||
build/
|
||||
lib/
|
||||
# Godot 4+ specific ignores
|
||||
.godot/
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
[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=[ ]
|
||||
@@ -1,9 +0,0 @@
|
||||
[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"
|
||||
11
demo/addons/godot-git-plugin/git_plugin.gdextension
Normal file
11
demo/addons/godot-git-plugin/git_plugin.gdextension
Normal file
@@ -0,0 +1,11 @@
|
||||
[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 = ""
|
||||
Binary file not shown.
@@ -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="ChronicallySerious"
|
||||
version="v1.2.2"
|
||||
script="git_api.gdns"
|
||||
author="twaritwaikar"
|
||||
version="v3.0.0-beta1"
|
||||
script="godot-git-plugin.gd"
|
||||
|
||||
Binary file not shown.
Binary file not shown.
@@ -1,7 +0,0 @@
|
||||
[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=2]
|
||||
[gd_scene format=3 uid="uid://cr5ci1iwmxnlb"]
|
||||
|
||||
[node name="Node2D" type="Node2D"]
|
||||
[node name="Node3D" type="Node3D"]
|
||||
|
||||
BIN
demo/icon.png
BIN
demo/icon.png
Binary file not shown.
|
Before Width: | Height: | Size: 3.4 KiB |
@@ -1,34 +0,0 @@
|
||||
[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
|
||||
stream=false
|
||||
size_limit=0
|
||||
detect_3d=true
|
||||
svg/scale=1.0
|
||||
@@ -1,12 +1,12 @@
|
||||
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!")
|
||||
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,28 +6,17 @@
|
||||
; [section] ; section goes between []
|
||||
; param=value ; assign values to parameters
|
||||
|
||||
config_version=4
|
||||
|
||||
_global_script_classes=[ {
|
||||
"base": "",
|
||||
"class": "GitAPI",
|
||||
"language": "NativeScript",
|
||||
"path": "res://addons/godot-git-plugin/git_api.gdns"
|
||||
} ]
|
||||
_global_script_class_icons={
|
||||
"GitAPI": ""
|
||||
}
|
||||
config_version=5
|
||||
|
||||
[application]
|
||||
|
||||
config/name="demo"
|
||||
run/main_scene="res://demo.tscn"
|
||||
config/icon="res://icon.png"
|
||||
config/features=PackedStringArray("4.0")
|
||||
|
||||
[gdnative]
|
||||
[editor]
|
||||
|
||||
singletons=[ "res://addons/godot-git-plugin/git_api.gdnlib" ]
|
||||
version_control/plugin_name="GitPlugin"
|
||||
version_control/autoload_on_startup=true
|
||||
|
||||
[rendering]
|
||||
[editor_plugins]
|
||||
|
||||
environment/default_environment="res://default_env.tres"
|
||||
enabled=PackedStringArray()
|
||||
|
||||
Submodule godot-cpp updated: 99e9dd1d93...c1ff169bf3
58
godot-git-plugin/SCsub
Normal file
58
godot-git-plugin/SCsub
Normal file
@@ -0,0 +1,58 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
|
||||
env = {}
|
||||
Import("env")
|
||||
|
||||
# Process some arguments
|
||||
if env["use_llvm"]:
|
||||
env["CC"] = "clang"
|
||||
env["CXX"] = "clang++"
|
||||
|
||||
if env["platform"] == "":
|
||||
print("No valid target platform selected.")
|
||||
quit()
|
||||
|
||||
env["target_path"] = "../" + env["target_path"]
|
||||
|
||||
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/"
|
||||
|
||||
# Force static linkage (https://stackoverflow.com/a/2995999/7370948)
|
||||
env.Append(LIBS=[File(env["macos_openssl_static_ssl"]),
|
||||
File(env["macos_openssl_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"]])
|
||||
|
||||
elif env["platform"] == "linux":
|
||||
env["target_path"] += "linux/"
|
||||
env.Append(LIBS=[File(env["linux_openssl_static_ssl"]),
|
||||
File(env["linux_openssl_static_crypto"])])
|
||||
|
||||
elif env["platform"] == "windows":
|
||||
env["target_path"] += "win64/"
|
||||
|
||||
env.Append(LIBS=["advapi32", "winhttp", "rpcrt4", "crypt32",
|
||||
"ole32", "user32", "wsock32", "ws2_32", "bcrypt"])
|
||||
|
||||
env.Append(CPPPATH=[".", "src/"])
|
||||
|
||||
env.Append(CPPPATH=["../thirdparty/git2/libgit2/include/"])
|
||||
env.Append(LIBPATH=["../thirdparty/bin/"])
|
||||
env.Prepend(LIBS=["git2", "ssh2"])
|
||||
|
||||
library = env.SharedLibrary(
|
||||
target=env["target_path"] +
|
||||
"{}{}{}".format(env["target_name"], env["suffix"], env["SHLIBSUFFIX"]),
|
||||
source=Glob("src/*.cpp")
|
||||
)
|
||||
Default(library)
|
||||
@@ -94,7 +94,7 @@ KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
# Language: TextProto
|
||||
# BasedOnStyle: google
|
||||
# ReflowComments: true
|
||||
# SortIncludes: true
|
||||
SortIncludes: false
|
||||
# SortUsingDeclarations: true
|
||||
# SpaceAfterCStyleCast: false
|
||||
# SpaceAfterTemplateKeyword: true
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
#ifndef ALLOCATION_DEF_H
|
||||
#define ALLOCATION_DEF_H
|
||||
|
||||
#define memnew(m_Class) new m_Class()
|
||||
|
||||
// NULL objects are not being handled to discourage lazy destruction of objects
|
||||
#define memdelete(m_pointer) m_pointer ? WARN_PRINT("Git API tried to delete a NULL object") : delete m_pointer;
|
||||
|
||||
#endif // !ALLOCATION_DEF_H
|
||||
@@ -1,20 +1,31 @@
|
||||
#include "git_api.h"
|
||||
#include "git_plugin.h"
|
||||
|
||||
#include <Godot.hpp>
|
||||
#include "godot_cpp/core/class_db.hpp"
|
||||
#include "godot_cpp/godot.hpp"
|
||||
|
||||
extern "C" void GDN_EXPORT godot_gdnative_init(godot_gdnative_init_options *o) {
|
||||
godot::Godot::gdnative_init(o);
|
||||
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_singleton(godot_gdnative_init_options *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_terminate(godot_gdnative_terminate_options *o) {
|
||||
godot::Godot::gdnative_terminate(o);
|
||||
}
|
||||
extern "C" {
|
||||
|
||||
extern "C" void GDN_EXPORT godot_nativescript_init(void *handle) {
|
||||
godot::Godot::nativescript_init(handle);
|
||||
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);
|
||||
|
||||
godot::register_tool_class<godot::GitAPI>();
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,294 +0,0 @@
|
||||
#include "git_api.h"
|
||||
|
||||
namespace godot {
|
||||
|
||||
GitAPI *GitAPI::singleton = NULL;
|
||||
|
||||
void GitAPI::_register_methods() {
|
||||
register_method("_process", &GitAPI::_process);
|
||||
|
||||
register_method("_commit", &GitAPI::_commit);
|
||||
register_method("_is_vcs_initialized", &GitAPI::_is_vcs_initialized);
|
||||
register_method("_get_modified_files_data", &GitAPI::_get_modified_files_data);
|
||||
register_method("_get_file_diff", &GitAPI::_get_file_diff);
|
||||
register_method("_get_project_name", &GitAPI::_get_project_name);
|
||||
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("_unstage_file", &GitAPI::_unstage_file);
|
||||
}
|
||||
|
||||
void GitAPI::_commit(const String p_msg) {
|
||||
if (!can_commit) {
|
||||
godot::Godot::print("Git API cannot commit. Check previous errors.");
|
||||
return;
|
||||
}
|
||||
|
||||
git_signature *default_sign;
|
||||
git_oid tree_id, parent_commit_id, new_commit_id;
|
||||
git_tree *tree;
|
||||
git_index *repo_index;
|
||||
git_commit *parent_commit;
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
GIT2_CALL(git_index_write_tree(&tree_id, repo_index), "Could not write index to tree", NULL);
|
||||
GIT2_CALL(git_index_write(repo_index), "Could not write index to disk", NULL);
|
||||
GIT2_CALL(git_signature_default(&default_sign, repo), "Could not get default signature", NULL);
|
||||
GIT2_CALL(git_tree_lookup(&tree, repo, &tree_id), "Could not lookup tree from ID", NULL);
|
||||
|
||||
GIT2_CALL(git_reference_name_to_id(&parent_commit_id, repo, "HEAD"), "Could not get parent ID", NULL);
|
||||
GIT2_CALL(git_commit_lookup(&parent_commit, repo, &parent_commit_id), "Could not lookup parent commit data", NULL);
|
||||
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&new_commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
default_sign,
|
||||
default_sign,
|
||||
"UTF-8",
|
||||
p_msg.alloc_c_string(),
|
||||
tree,
|
||||
1,
|
||||
parent_commit),
|
||||
"Could not create commit",
|
||||
NULL);
|
||||
|
||||
staged_files.clear();
|
||||
|
||||
git_index_free(repo_index);
|
||||
git_signature_free(default_sign);
|
||||
git_commit_free(parent_commit);
|
||||
git_tree_free(tree);
|
||||
}
|
||||
|
||||
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"
|
||||
".import/\n\n"
|
||||
|
||||
"# Binaries\n"
|
||||
"bin/\n"
|
||||
"build/\n"
|
||||
"lib/\n");
|
||||
file->close();
|
||||
}
|
||||
|
||||
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"
|
||||
|
||||
"# Explicitly declare text files you want to always be normalized and converted\n"
|
||||
"# to native line endings on checkout.\n"
|
||||
"*.cpp text\n"
|
||||
"*.c text\n"
|
||||
"*.h text\n"
|
||||
"*.gd text\n"
|
||||
"*.cs text\n\n"
|
||||
|
||||
"# Declare files that will always have CRLF line endings on checkout.\n"
|
||||
"*.sln text eol=crlf\n\n"
|
||||
|
||||
"# Denote all files that are truly binary and should not be modified.\n"
|
||||
"*.png binary\n"
|
||||
"*.jpg binary\n");
|
||||
file->close();
|
||||
}
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
GIT2_CALL(git_repository_index(&repo_index, repo), "Could not get repository index", NULL);
|
||||
GIT2_CALL(git_index_write_tree(&tree_id, repo_index), "Could not create intial commit", NULL);
|
||||
|
||||
GIT2_CALL(git_tree_lookup(&tree, repo, &tree_id), "Could not create intial commit", NULL);
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&commit_id,
|
||||
repo,
|
||||
"HEAD",
|
||||
sig,
|
||||
sig,
|
||||
NULL,
|
||||
"Initial commit",
|
||||
tree,
|
||||
0),
|
||||
"Could not create the initial commit",
|
||||
NULL);
|
||||
|
||||
GIT2_CALL(git_index_write(repo_index), "Could not write index to disk", NULL);
|
||||
git_index_free(repo_index);
|
||||
git_tree_free(tree);
|
||||
git_signature_free(sig);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
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 *statuses = NULL;
|
||||
GIT2_CALL(git_status_list_new(&statuses, repo, &opts), "Could not get status information from repository", NULL);
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
git_status_list_free(statuses);
|
||||
|
||||
return diff;
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
opts.context_lines = 3;
|
||||
opts.interhunk_lines = 0;
|
||||
opts.flags = GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED;
|
||||
opts.pathspec.strings = &pathspec;
|
||||
opts.pathspec.count = 1;
|
||||
|
||||
GIT2_CALL(git_diff_index_to_workdir(&diff, repo, NULL, &opts), "Could not create diff for index from working directory", NULL);
|
||||
|
||||
diff_contents.clear();
|
||||
GIT2_CALL(git_diff_print(diff, GIT_DIFF_FORMAT_PATCH, diff_line_callback_function, NULL), "Call to diff handler provided unsuccessful", NULL);
|
||||
|
||||
git_diff_free(diff);
|
||||
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
GIT2_CALL(git_repository_open(&repo, p_project_root_path.alloc_c_string()), "Could not open repository", NULL);
|
||||
is_initialized = true;
|
||||
|
||||
return is_initialized;
|
||||
}
|
||||
|
||||
bool GitAPI::_shut_down() {
|
||||
git_repository_free(repo);
|
||||
|
||||
GIT2_CALL(git_libgit2_shutdown(), "Could not shutdown Git Addon", NULL);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void GitAPI::_init() {
|
||||
}
|
||||
|
||||
void GitAPI::_process() {
|
||||
}
|
||||
|
||||
GitAPI::GitAPI() {
|
||||
}
|
||||
|
||||
GitAPI::~GitAPI() {
|
||||
}
|
||||
|
||||
} // namespace godot
|
||||
@@ -1,64 +0,0 @@
|
||||
#ifndef GIT_API_H
|
||||
#define GIT_API_H
|
||||
|
||||
#include <Button.hpp>
|
||||
#include <Control.hpp>
|
||||
#include <Directory.hpp>
|
||||
#include <EditorVCSInterface.hpp>
|
||||
#include <File.hpp>
|
||||
#include <Godot.hpp>
|
||||
#include <PanelContainer.hpp>
|
||||
|
||||
#include <allocation_defs.h>
|
||||
#include <git_common.h>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
namespace godot {
|
||||
|
||||
class GitAPI : public EditorVCSInterface {
|
||||
GODOT_CLASS(GitAPI, EditorVCSInterface)
|
||||
|
||||
static GitAPI *singleton;
|
||||
|
||||
bool is_initialized;
|
||||
bool can_commit;
|
||||
|
||||
Array staged_files;
|
||||
|
||||
PanelContainer *init_settings_panel_container;
|
||||
Button *init_settings_button;
|
||||
|
||||
git_repository *repo = nullptr;
|
||||
|
||||
void _commit(const String p_msg);
|
||||
bool _is_vcs_initialized();
|
||||
Dictionary _get_modified_files_data();
|
||||
Array _get_file_diff(const String file_path);
|
||||
String _get_project_name();
|
||||
String _get_vcs_name();
|
||||
bool _initialize(const String p_project_root_path);
|
||||
bool _shut_down();
|
||||
void _stage_file(const String p_file_path);
|
||||
void _unstage_file(const String p_file_path);
|
||||
|
||||
public:
|
||||
static void _register_methods();
|
||||
|
||||
static GitAPI *get_singleton() { return singleton; }
|
||||
|
||||
Array diff_contents;
|
||||
|
||||
void create_gitignore_and_gitattributes();
|
||||
bool create_initial_commit();
|
||||
|
||||
void _init();
|
||||
void _process();
|
||||
|
||||
GitAPI();
|
||||
~GitAPI();
|
||||
};
|
||||
|
||||
} // namespace godot
|
||||
|
||||
#endif // !GIT_API_H
|
||||
111
godot-git-plugin/src/git_callbacks.cpp
Normal file
111
godot-git-plugin/src/git_callbacks.cpp
Normal file
@@ -0,0 +1,111 @@
|
||||
#include <iostream>
|
||||
#include <cstring>
|
||||
|
||||
#include "git_callbacks.h"
|
||||
#include "git_plugin.h"
|
||||
|
||||
#include "godot_cpp/godot.hpp"
|
||||
#include "godot_cpp/variant/utility_functions.hpp"
|
||||
|
||||
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);
|
||||
progress_str[len] = '\0';
|
||||
godot::UtilityFunctions::push_warning("remote: ", CString(godot::String(progress_str).strip_edges()).data);
|
||||
delete[] progress_str;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data) {
|
||||
constexpr int short_commit_length = 8;
|
||||
char a_str[short_commit_length + 1];
|
||||
char b_str[short_commit_length + 1];
|
||||
(void)data;
|
||||
|
||||
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);
|
||||
} 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);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int transfer_progress_cb(const git_indexer_progress *stats, void *payload) {
|
||||
(void)payload;
|
||||
|
||||
if (stats->received_objects == stats->total_objects) {
|
||||
godot::UtilityFunctions::print("Resolving deltas ", uint32_t(stats->indexed_deltas), "/", uint32_t(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");
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int fetchhead_foreach_cb(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload) {
|
||||
if (is_merge) {
|
||||
git_oid_cpy((git_oid *)payload, oid);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int push_transfer_progress_cb(unsigned int current, unsigned int total, size_t bytes, void *payload) {
|
||||
int64_t progress = 100;
|
||||
|
||||
if (total != 0) {
|
||||
progress = (current * 100) / total;
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("Writing Objects: ", uint32_t(progress), "% (", uint32_t(current), "/", uint32_t(total), ", ", uint32_t(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);
|
||||
} else {
|
||||
godot::UtilityFunctions::print("[updated] ", CString(godot::String(refname)).data);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int credentials_cb(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload) {
|
||||
Credentials *creds = (Credentials *)payload;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (allowed_types & GIT_CREDENTIAL_USERNAME) {
|
||||
return git_credential_username_new(out, 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::Dictionary hunk = diff_helper->git_plugin->create_diff_hunk(range->old_start, range->new_start, range->old_lines, range->new_lines);
|
||||
diff_helper->diff_hunks->push_back(hunk);
|
||||
|
||||
return 1;
|
||||
}
|
||||
20
godot-git-plugin/src/git_callbacks.h
Normal file
20
godot-git-plugin/src/git_callbacks.h
Normal file
@@ -0,0 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include "godot_cpp/variant/array.hpp"
|
||||
#include "git2.h"
|
||||
|
||||
class GitPlugin;
|
||||
|
||||
struct DiffHelper {
|
||||
godot::Array *diff_hunks;
|
||||
GitPlugin *git_plugin;
|
||||
};
|
||||
|
||||
extern "C" int progress_cb(const char *str, int len, void *data);
|
||||
extern "C" int update_cb(const char *refname, const git_oid *a, const git_oid *b, void *data);
|
||||
extern "C" int transfer_progress_cb(const git_indexer_progress *stats, void *payload);
|
||||
extern "C" int fetchhead_foreach_cb(const char *ref_name, const char *remote_url, const git_oid *oid, unsigned int is_merge, void *payload);
|
||||
extern "C" int credentials_cb(git_cred **out, const char *url, const char *username_from_url, unsigned int allowed_types, void *payload);
|
||||
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);
|
||||
@@ -1,57 +0,0 @@
|
||||
#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);
|
||||
static int i = 0;
|
||||
content[line->content_len] = '\0';
|
||||
|
||||
godot::String prefix = "";
|
||||
switch (line->origin) {
|
||||
case GIT_DIFF_LINE_DEL_EOFNL:
|
||||
case GIT_DIFF_LINE_DELETION:
|
||||
prefix = "-";
|
||||
break;
|
||||
|
||||
case GIT_DIFF_LINE_ADD_EOFNL:
|
||||
case GIT_DIFF_LINE_ADDITION:
|
||||
prefix = "+";
|
||||
break;
|
||||
}
|
||||
|
||||
godot::String content_str = content;
|
||||
|
||||
godot::Dictionary result;
|
||||
result["content"] = prefix + content_str;
|
||||
result["status"] = prefix;
|
||||
result["new_line_number"] = line->new_lineno;
|
||||
result["line_count"] = line->num_lines;
|
||||
result["old_line_number"] = line->old_lineno;
|
||||
result["offset"] = line->content_offset;
|
||||
|
||||
godot::GitAPI::get_singleton()->diff_contents.push_back(result);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
#ifndef GIT_COMMON_H
|
||||
#define GIT_COMMON_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <Godot.hpp>
|
||||
|
||||
#include <git2.h>
|
||||
|
||||
void check_git2_errors(int error, const char *message, const char *extra);
|
||||
|
||||
extern "C" int diff_line_callback_function(const git_diff_delta *delta, const git_diff_hunk *hunk, const git_diff_line *line, void *payload);
|
||||
|
||||
#define GIT2_CALL(function_call, m_error_msg, m_additional_msg) check_git2_errors(function_call, m_error_msg, m_additional_msg);
|
||||
|
||||
#endif // !GIT_COMMON_H
|
||||
710
godot-git-plugin/src/git_plugin.cpp
Normal file
710
godot-git-plugin/src/git_plugin.cpp
Normal file
@@ -0,0 +1,710 @@
|
||||
#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"
|
||||
|
||||
#define GIT2_CALL(error, msg) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define GIT2_CALL_R(error, msg, return_value) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg)) { \
|
||||
return return_value; \
|
||||
}
|
||||
|
||||
#define GIT2_CALL_IGNORE(error, msg, ignores) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg, ignores)) { \
|
||||
return; \
|
||||
}
|
||||
|
||||
#define GIT2_CALL_R_IGNORE(error, msg, return_value, ignores) \
|
||||
if (check_errors(error, __FUNCTION__, __FILE__, __LINE__, msg, ignores)) { \
|
||||
return return_value; \
|
||||
}
|
||||
|
||||
#define COMMA ,
|
||||
|
||||
void GitPlugin::_bind_methods() {
|
||||
// Doesn't seem to require binding functions for now
|
||||
}
|
||||
|
||||
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) {
|
||||
const git_error *lg2err;
|
||||
|
||||
if (error == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto &ig : ignores) {
|
||||
if (error == ig) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::push_error("GitPlugin: ", CString(message).data, " in ", CString(file).data, ":", CString(function).data, "#L", line);
|
||||
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) {
|
||||
creds.username = username;
|
||||
creds.password = password;
|
||||
creds.ssh_public_key_path = ssh_public_key_path;
|
||||
creds.ssh_private_key_path = ssh_private_key_path;
|
||||
creds.ssh_passphrase = ssh_passphrase;
|
||||
}
|
||||
|
||||
void GitPlugin::_discard_file(const godot::String &file_path) {
|
||||
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
opts.paths = { paths, 1 };
|
||||
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
|
||||
GIT2_CALL(git_checkout_index(repo.get(), nullptr, &opts), "Could not checkout index");
|
||||
}
|
||||
|
||||
void GitPlugin::_commit(const godot::String &msg) {
|
||||
git_index_ptr repo_index;
|
||||
GIT2_CALL(git_repository_index(Capture(repo_index), repo.get()), "Could not get repository index");
|
||||
|
||||
git_oid tree_id;
|
||||
GIT2_CALL(git_index_write_tree(&tree_id, repo_index.get()), "Could not write index to tree");
|
||||
GIT2_CALL(git_index_write(repo_index.get()), "Could not write index to disk");
|
||||
|
||||
git_tree_ptr tree;
|
||||
GIT2_CALL(git_tree_lookup(Capture(tree), repo.get(), &tree_id), "Could not lookup tree from ID");
|
||||
|
||||
git_signature_ptr default_sign;
|
||||
GIT2_CALL(git_signature_default(Capture(default_sign), repo.get()), "Could not get default signature");
|
||||
|
||||
git_oid parent_commit_id = {};
|
||||
GIT2_CALL_IGNORE(git_reference_name_to_id(&parent_commit_id, repo.get(), "HEAD"), "Could not get repository HEAD", { GIT_ENOTFOUND });
|
||||
|
||||
git_commit_ptr parent_commit;
|
||||
if (!git_oid_is_zero(&parent_commit_id)) {
|
||||
GIT2_CALL(git_commit_lookup(Capture(parent_commit), repo.get(), &parent_commit_id), "Could not lookup parent commit data");
|
||||
}
|
||||
|
||||
git_oid new_commit_id;
|
||||
if (!has_merge) {
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&new_commit_id,
|
||||
repo.get(),
|
||||
"HEAD",
|
||||
default_sign.get(),
|
||||
default_sign.get(),
|
||||
"UTF-8",
|
||||
CString(msg).data,
|
||||
tree.get(),
|
||||
parent_commit.get() ? 1 : 0,
|
||||
parent_commit.get()),
|
||||
"Could not create commit");
|
||||
} else {
|
||||
git_commit_ptr fetchhead_commit;
|
||||
GIT2_CALL(git_commit_lookup(Capture(fetchhead_commit), repo.get(), &pull_merge_oid), "Could not lookup commit pointed to by HEAD");
|
||||
|
||||
GIT2_CALL(
|
||||
git_commit_create_v(
|
||||
&new_commit_id,
|
||||
repo.get(),
|
||||
"HEAD",
|
||||
default_sign.get(),
|
||||
default_sign.get(),
|
||||
"UTF-8",
|
||||
CString(msg).data,
|
||||
tree.get(),
|
||||
2,
|
||||
parent_commit.get(),
|
||||
fetchhead_commit.get()),
|
||||
"Could not create merge commit");
|
||||
has_merge = false;
|
||||
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
|
||||
}
|
||||
}
|
||||
|
||||
void GitPlugin::_stage_file(const godot::String &file_path) {
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
git_strarray array = { paths, 1 };
|
||||
|
||||
git_index_ptr index;
|
||||
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
|
||||
GIT2_CALL(git_index_add_all(index.get(), &array, GIT_INDEX_ADD_DEFAULT | GIT_INDEX_ADD_DISABLE_PATHSPEC_MATCH, nullptr, nullptr), "Could not add " + file_path + " to index");
|
||||
GIT2_CALL(git_index_write(index.get()), "Could not write changes to disk");
|
||||
}
|
||||
|
||||
void GitPlugin::_unstage_file(const godot::String &file_path) {
|
||||
CString c_path(file_path);
|
||||
char *paths[] = { c_path.data };
|
||||
git_strarray array = { paths, 1 };
|
||||
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_IGNORE(git_repository_head(Capture(head), repo.get()), "Could not find repository HEAD", { GIT_ENOTFOUND COMMA GIT_EUNBORNBRANCH });
|
||||
|
||||
if (head) {
|
||||
git_object_ptr head_commit;
|
||||
GIT2_CALL(git_reference_peel(Capture(head_commit), head.get(), GIT_OBJ_COMMIT), "Could not peel HEAD reference");
|
||||
GIT2_CALL(git_reset_default(repo.get(), head_commit.get(), &array), "Could not reset " + file_path + " to state at HEAD");
|
||||
} else {
|
||||
// If there is no HEAD commit, we should just remove the file from the index.
|
||||
|
||||
CString c_path(file_path);
|
||||
|
||||
git_index_ptr index;
|
||||
GIT2_CALL(git_repository_index(Capture(index), repo.get()), "Could not get repository index");
|
||||
GIT2_CALL(git_index_remove_bypath(index.get(), c_path.data), "Could not add " + file_path + " to index");
|
||||
GIT2_CALL(git_index_write(index.get()), "Could not write changes to disk");
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
file->store_string(
|
||||
"# Godot 4+ specific ignores\n"
|
||||
".godot/\n");
|
||||
}
|
||||
|
||||
if (!godot::FileAccess::file_exists(repo_project_path + "/.gitattributes")) {
|
||||
godot::Ref<godot::FileAccess> file = godot::FileAccess::open(repo_project_path + "/.gitattributes", godot::FileAccess::ModeFlags::WRITE);
|
||||
ERR_FAIL_COND(file.is_null());
|
||||
file->store_string(
|
||||
"# Set the default behavior, in case people don't have core.autocrlf set.\n"
|
||||
"* text=auto\n\n"
|
||||
|
||||
"# Explicitly declare text files you want to always be normalized and converted\n"
|
||||
"# to native line endings on checkout.\n"
|
||||
"*.cpp text\n"
|
||||
"*.c text\n"
|
||||
"*.h text\n"
|
||||
"*.gd text\n"
|
||||
"*.cs text\n\n"
|
||||
|
||||
"# Declare files that will always have CRLF line endings on checkout.\n"
|
||||
"*.sln text eol=crlf\n\n"
|
||||
|
||||
"# Denote all files that are truly binary and should not be modified.\n"
|
||||
"*.png binary\n"
|
||||
"*.jpg binary\n");
|
||||
}
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_modified_files_data() {
|
||||
godot::TypedArray<godot::Dictionary> stats_files;
|
||||
|
||||
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
|
||||
opts.show = GIT_STATUS_SHOW_INDEX_AND_WORKDIR;
|
||||
opts.flags = GIT_STATUS_OPT_EXCLUDE_SUBMODULES;
|
||||
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>());
|
||||
|
||||
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;
|
||||
if (entry->index_to_workdir) {
|
||||
path = entry->index_to_workdir->new_file.path;
|
||||
} else {
|
||||
path = entry->head_to_index->new_file.path;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
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));
|
||||
} else {
|
||||
stats_files.push_back(create_status_file(path, map_changes.at(git_status_t(entry->status & git_status_index)), TREE_AREA_STAGED));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return stats_files;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::String> GitPlugin::_get_branch_list() {
|
||||
git_branch_iterator_ptr it;
|
||||
GIT2_CALL_R(git_branch_iterator_new(Capture(it), repo.get(), GIT_BRANCH_LOCAL), "Could not create branch iterator", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::TypedArray<godot::String> 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>());
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
return branch_names;
|
||||
}
|
||||
|
||||
void GitPlugin::_create_branch(const godot::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");
|
||||
|
||||
git_commit_ptr head_commit;
|
||||
GIT2_CALL(git_commit_lookup(Capture(head_commit), repo.get(), &head_commit_id), "Could not lookup HEAD commit");
|
||||
|
||||
git_reference_ptr branch_ref;
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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) {
|
||||
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>());
|
||||
|
||||
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>();
|
||||
}
|
||||
|
||||
git_reference_ptr head;
|
||||
GIT2_CALL_R(git_repository_head(Capture(head), repo.get()), "Failed to load repository head", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
git_blob_ptr blob;
|
||||
GIT2_CALL_R(git_blob_lookup(Capture(blob), repo.get(), &entry->id), "Failed to load head blob", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
|
||||
DiffHelper diff_helper = { &diff_contents, this };
|
||||
GIT2_CALL_R(git_diff_blob_to_buffer(blob.get(), nullptr, CString(text).data, text.length(), nullptr, &opts, nullptr, nullptr, diff_hunk_cb, nullptr, &diff_helper), "Failed to make diff", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::String GitPlugin::_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 });
|
||||
|
||||
if (!head) {
|
||||
// We are likely at a state where the initial commit hasn't been made yet.
|
||||
return "";
|
||||
}
|
||||
|
||||
git_reference_ptr branch;
|
||||
GIT2_CALL_R(git_reference_resolve(Capture(branch), head.get()), "Could not resolve HEAD reference", "");
|
||||
|
||||
const char *name = "";
|
||||
GIT2_CALL_R(git_branch_name(&name, branch.get()), "Could not get branch name from current branch reference", "");
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::String> GitPlugin::_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>());
|
||||
|
||||
godot::TypedArray<godot::String> remotes;
|
||||
for (int i = 0; i < remote_array.count; i++) {
|
||||
remotes.push_back(remote_array.strings[i]);
|
||||
}
|
||||
|
||||
return remotes;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_previous_commits(int32_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_IGNORE(git_revwalk_push_head(walker.get()), "Could not push HEAD to revwalk", godot::TypedArray<godot::Dictionary>(), { GIT_ENOTFOUND COMMA GIT_ERROR });
|
||||
|
||||
git_oid oid;
|
||||
godot::TypedArray<godot::Dictionary> commits;
|
||||
char commit_id[GIT_OID_HEXSZ + 1];
|
||||
for (int i = 0; !git_revwalk_next(&oid, walker.get()) && i <= max_commits; i++) {
|
||||
git_commit_ptr commit;
|
||||
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());
|
||||
|
||||
const git_signature *sig = git_commit_author(commit.get());
|
||||
godot::String author = godot::String() + sig->name + " <" + sig->email + ">";
|
||||
|
||||
commits.push_back(create_commit(msg, author, commit_id, sig->when.time, sig->when.offset));
|
||||
}
|
||||
|
||||
return commits;
|
||||
}
|
||||
|
||||
void GitPlugin::_fetch(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing fetch from ", CString(remote).data);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
|
||||
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
|
||||
remote_cbs.credentials = &credentials_cb;
|
||||
remote_cbs.update_tips = &update_cb;
|
||||
remote_cbs.sideband_progress = &progress_cb;
|
||||
remote_cbs.transfer_progress = &transfer_progress_cb;
|
||||
remote_cbs.payload = &creds;
|
||||
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
|
||||
remote_cbs.push_update_reference = &push_update_reference_cb;
|
||||
|
||||
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_FETCH, &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");
|
||||
|
||||
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
|
||||
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");
|
||||
}
|
||||
|
||||
void GitPlugin::_pull(const godot::String &remote) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing pull from ", CString(remote).data);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
|
||||
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
|
||||
remote_cbs.credentials = &credentials_cb;
|
||||
remote_cbs.update_tips = &update_cb;
|
||||
remote_cbs.sideband_progress = &progress_cb;
|
||||
remote_cbs.transfer_progress = &transfer_progress_cb;
|
||||
remote_cbs.payload = &creds;
|
||||
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
|
||||
remote_cbs.push_update_reference = &push_update_reference_cb;
|
||||
|
||||
GIT2_CALL(git_remote_connect(remote_object.get(), GIT_DIRECTION_FETCH, &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");
|
||||
|
||||
git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
|
||||
fetch_opts.callbacks = remote_cbs;
|
||||
|
||||
godot::String branch_name = _get_current_branch_name();
|
||||
|
||||
CString ref_spec_str("refs/heads/" + branch_name);
|
||||
|
||||
char *ref[] = { ref_spec_str.data };
|
||||
git_strarray refspec = { ref, 1 };
|
||||
|
||||
GIT2_CALL(git_remote_fetch(remote_object.get(), &refspec, &fetch_opts, "pull"), "Could not fetch data from remote");
|
||||
|
||||
pull_merge_oid = {};
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
|
||||
git_annotated_commit_ptr fetchhead_annotated_commit;
|
||||
GIT2_CALL(git_annotated_commit_lookup(Capture(fetchhead_annotated_commit), repo.get(), &pull_merge_oid), "Could not get merge commit");
|
||||
|
||||
const git_annotated_commit *merge_heads[] = { fetchhead_annotated_commit.get() };
|
||||
|
||||
git_merge_analysis_t merge_analysis;
|
||||
git_merge_preference_t preference = GIT_MERGE_PREFERENCE_NONE;
|
||||
GIT2_CALL(git_merge_analysis(&merge_analysis, &preference, repo.get(), merge_heads, 1), "Merge analysis failed");
|
||||
|
||||
if (merge_analysis & GIT_MERGE_ANALYSIS_FASTFORWARD) {
|
||||
git_checkout_options ff_checkout_options = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
int err = 0;
|
||||
|
||||
git_reference_ptr target_ref;
|
||||
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)));
|
||||
|
||||
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");
|
||||
|
||||
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");
|
||||
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
|
||||
|
||||
} else if (merge_analysis & GIT_MERGE_ANALYSIS_NORMAL) {
|
||||
git_merge_options merge_opts = GIT_MERGE_OPTIONS_INIT;
|
||||
git_checkout_options checkout_opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
|
||||
merge_opts.file_favor = GIT_MERGE_FILE_FAVOR_NORMAL;
|
||||
merge_opts.file_flags = (GIT_MERGE_FILE_STYLE_DIFF3 | GIT_MERGE_FILE_DIFF_MINIMAL);
|
||||
checkout_opts.checkout_strategy = (GIT_CHECKOUT_SAFE | GIT_CHECKOUT_ALLOW_CONFLICTS | GIT_CHECKOUT_CONFLICT_STYLE_MERGE);
|
||||
GIT2_CALL(git_merge(repo.get(), merge_heads, 1, &merge_opts, &checkout_opts), "Merge Failed");
|
||||
|
||||
git_index_ptr index;
|
||||
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.");
|
||||
} else {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Changes 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");
|
||||
|
||||
GIT2_CALL(git_repository_state_cleanup(repo.get()), "Could not clean repository state");
|
||||
|
||||
} else {
|
||||
godot::UtilityFunctions::push_error("GitPlugin: Can not merge");
|
||||
}
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Pull ended");
|
||||
}
|
||||
|
||||
void GitPlugin::_push(const godot::String &remote, bool force) {
|
||||
godot::UtilityFunctions::print("GitPlugin: Performing push to ", CString(remote).data);
|
||||
|
||||
git_remote_ptr remote_object;
|
||||
GIT2_CALL(git_remote_lookup(Capture(remote_object), repo.get(), CString(remote).data), "Could not lookup remote \"" + remote + "\"");
|
||||
|
||||
git_remote_callbacks remote_cbs = GIT_REMOTE_CALLBACKS_INIT;
|
||||
remote_cbs.credentials = &credentials_cb;
|
||||
remote_cbs.update_tips = &update_cb;
|
||||
remote_cbs.sideband_progress = &progress_cb;
|
||||
remote_cbs.transfer_progress = &transfer_progress_cb;
|
||||
remote_cbs.payload = &creds;
|
||||
remote_cbs.push_transfer_progress = &push_transfer_progress_cb;
|
||||
remote_cbs.push_update_reference = &push_update_reference_cb;
|
||||
|
||||
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();
|
||||
|
||||
CString pushspec(godot::String() + (force ? "+" : "") + "refs/heads/" + branch_name);
|
||||
const git_strarray refspec = { &pushspec.data, 1 };
|
||||
|
||||
git_push_options push_options = GIT_PUSH_OPTIONS_INIT;
|
||||
push_options.callbacks = remote_cbs;
|
||||
|
||||
GIT2_CALL(git_remote_push(remote_object.get(), &refspec, &push_options), "Failed to push");
|
||||
|
||||
godot::UtilityFunctions::print("GitPlugin: Push ended");
|
||||
}
|
||||
|
||||
bool GitPlugin::_checkout_branch(const godot::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());
|
||||
|
||||
git_object_ptr treeish;
|
||||
GIT2_CALL_R(git_revparse_single(Capture(treeish), repo.get(), CString(branch_name).data), "Could not find branch head", false);
|
||||
|
||||
git_checkout_options opts = GIT_CHECKOUT_OPTIONS_INIT;
|
||||
opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
GIT2_CALL_R(git_checkout_tree(repo.get(), treeish.get(), &opts), "Could not checkout branch tree", false);
|
||||
GIT2_CALL_R(git_repository_set_head(repo.get(), branch_ref_name), "Could not set head", false);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_get_diff(const godot::String &identifier, const int32_t area) {
|
||||
git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
|
||||
opts.context_lines = 2;
|
||||
opts.interhunk_lines = 0;
|
||||
opts.flags = GIT_DIFF_RECURSE_UNTRACKED_DIRS | GIT_DIFF_DISABLE_PATHSPEC_MATCH | GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_SHOW_UNTRACKED_CONTENT | GIT_DIFF_INCLUDE_TYPECHANGE;
|
||||
|
||||
CString pathspec(identifier);
|
||||
opts.pathspec.strings = &pathspec.data;
|
||||
opts.pathspec.count = 1;
|
||||
|
||||
git_diff_ptr diff;
|
||||
switch ((TreeArea)area) {
|
||||
case TREE_AREA_UNSTAGED: {
|
||||
GIT2_CALL_R(git_diff_index_to_workdir(Capture(diff), repo.get(), nullptr, &opts), "Could not create diff for index from working directory", diff_contents);
|
||||
} break;
|
||||
case TREE_AREA_STAGED: {
|
||||
git_object_ptr obj;
|
||||
|
||||
// Ignore the case when HEAD is not found. We need to compare with a null tree in the case where the HEAD reference object is empty.
|
||||
GIT2_CALL_R_IGNORE(git_revparse_single(Capture(obj), repo.get(), "HEAD^{tree}"), "Could not get HEAD^{tree} object", diff_contents, { GIT_ENOTFOUND });
|
||||
|
||||
git_tree_ptr tree;
|
||||
if (obj) {
|
||||
GIT2_CALL_R_IGNORE(git_tree_lookup(Capture(tree), repo.get(), git_object_id(obj.get())), "Could not lookup HEAD^{tree}", diff_contents, { GIT_ENOTFOUND });
|
||||
}
|
||||
|
||||
GIT2_CALL_R(git_diff_tree_to_index(Capture(diff), repo.get(), tree.get(), nullptr, &opts), "Could not create diff for tree from index directory", diff_contents);
|
||||
} break;
|
||||
case TREE_AREA_COMMIT: {
|
||||
opts.pathspec = {};
|
||||
|
||||
git_object_ptr obj;
|
||||
GIT2_CALL_R(git_revparse_single(Capture(obj), repo.get(), pathspec.data), "Could not get object at " + identifier, diff_contents);
|
||||
|
||||
git_commit_ptr commit;
|
||||
GIT2_CALL_R(git_commit_lookup(Capture(commit), repo.get(), git_object_id(obj.get())), "Could not get commit " + identifier, diff_contents);
|
||||
|
||||
git_commit_ptr parent;
|
||||
|
||||
// We ignore the case when the parent is not found to handle the case when this commit is the root commit. We only need to diff against a null tree in that case.
|
||||
GIT2_CALL_R_IGNORE(git_commit_parent(Capture(parent), commit.get(), 0), "Could not get parent commit of " + identifier, diff_contents, { GIT_ENOTFOUND });
|
||||
|
||||
git_tree_ptr commit_tree;
|
||||
GIT2_CALL_R(git_commit_tree(Capture(commit_tree), commit.get()), "Could not get commit tree of " + identifier, diff_contents);
|
||||
|
||||
git_tree_ptr parent_tree;
|
||||
if (parent) {
|
||||
GIT2_CALL_R(git_commit_tree(Capture(parent_tree), parent.get()), "Could not get commit tree of " + identifier, diff_contents);
|
||||
}
|
||||
|
||||
GIT2_CALL_R(git_diff_tree_to_tree(Capture(diff), repo.get(), parent_tree.get(), commit_tree.get(), &opts), "Could not generate diff for commit " + identifier, diff_contents);
|
||||
} break;
|
||||
}
|
||||
|
||||
diff_contents = _parse_diff(diff.get());
|
||||
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::TypedArray<godot::Dictionary> GitPlugin::_parse_diff(git_diff *diff) {
|
||||
godot::TypedArray<godot::Dictionary> diff_contents;
|
||||
for (int i = 0; i < git_diff_num_deltas(diff); i++) {
|
||||
const git_diff_delta *delta = git_diff_get_delta(diff, i);
|
||||
|
||||
git_patch_ptr patch;
|
||||
GIT2_CALL_R(git_patch_from_diff(Capture(patch), diff, i), "Could not create patch from diff", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Dictionary diff_file = create_diff_file(delta->new_file.path, delta->old_file.path);
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_hunks;
|
||||
for (int j = 0; j < git_patch_num_hunks(patch.get()); j++) {
|
||||
const git_diff_hunk *git_hunk;
|
||||
size_t line_count;
|
||||
GIT2_CALL_R(git_patch_get_hunk(&git_hunk, &line_count, patch.get(), j), "Could not get hunk from patch", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
godot::Dictionary diff_hunk = create_diff_hunk(git_hunk->old_start, git_hunk->new_start, git_hunk->old_lines, git_hunk->new_lines);
|
||||
|
||||
godot::TypedArray<godot::Dictionary> diff_lines;
|
||||
for (int k = 0; k < line_count; k++) {
|
||||
const git_diff_line *git_diff_line;
|
||||
GIT2_CALL_R(git_patch_get_line_in_hunk(&git_diff_line, patch.get(), j, k), "Could not get line from hunk in patch", godot::TypedArray<godot::Dictionary>());
|
||||
|
||||
char *content = new char[git_diff_line->content_len + 1];
|
||||
std::memcpy(content, git_diff_line->content, git_diff_line->content_len);
|
||||
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));
|
||||
|
||||
delete[] content;
|
||||
}
|
||||
|
||||
diff_hunk = add_line_diffs_into_diff_hunk(diff_hunk, diff_lines);
|
||||
diff_hunks.push_back(diff_hunk);
|
||||
}
|
||||
diff_file = add_diff_hunks_into_diff_file(diff_file, diff_hunks);
|
||||
diff_contents.push_back(diff_file);
|
||||
}
|
||||
return diff_contents;
|
||||
}
|
||||
|
||||
godot::String GitPlugin::_get_vcs_name() {
|
||||
return "Git";
|
||||
}
|
||||
|
||||
bool GitPlugin::_initialize(const godot::String &project_path) {
|
||||
using namespace godot;
|
||||
|
||||
ERR_FAIL_COND_V(project_path == "", false);
|
||||
|
||||
int init = git_libgit2_init();
|
||||
if (init > 1) {
|
||||
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);
|
||||
|
||||
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 });
|
||||
|
||||
if (!head) {
|
||||
create_gitignore_and_gitattributes();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool GitPlugin::_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;
|
||||
}
|
||||
65
godot-git-plugin/src/git_plugin.h
Normal file
65
godot-git-plugin/src/git_plugin.h
Normal file
@@ -0,0 +1,65 @@
|
||||
#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, int32_t area) override;
|
||||
bool _shut_down() override;
|
||||
godot::String _get_vcs_name() override;
|
||||
godot::TypedArray<godot::Dictionary> _get_previous_commits(int32_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();
|
||||
};
|
||||
18
godot-git-plugin/src/git_wrappers.cpp
Normal file
18
godot-git-plugin/src/git_wrappers.cpp
Normal file
@@ -0,0 +1,18 @@
|
||||
#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;
|
||||
}
|
||||
}
|
||||
74
godot-git-plugin/src/git_wrappers.h
Normal file
74
godot-git-plugin/src/git_wrappers.h
Normal file
@@ -0,0 +1,74 @@
|
||||
#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>;
|
||||
24
godot-git-plugin/thirdparty/libgit2/.HEADER
vendored
24
godot-git-plugin/thirdparty/libgit2/.HEADER
vendored
@@ -1,24 +0,0 @@
|
||||
/*
|
||||
* This file is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License, version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* In addition to the permissions in the GNU General Public License,
|
||||
* the authors give you unlimited permission to link the compiled
|
||||
* version of this file into combinations with other programs,
|
||||
* and to distribute those combinations without any restriction
|
||||
* coming from the use of this file. (The General Public License
|
||||
* restrictions do apply in other respects; for example, they cover
|
||||
* modification of the file, and distribution when not linked into
|
||||
* a combined executable.)
|
||||
*
|
||||
* This file is distributed in the hope that it will be useful, but
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
@@ -1,21 +0,0 @@
|
||||
; Check http://editorconfig.org/ for more informations
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
tab_width = 8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
|
||||
[*.yml]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
trim_trailing_whitespace = false
|
||||
|
||||
[*.py]
|
||||
indent_style = space
|
||||
indent_size = 4
|
||||
@@ -1 +0,0 @@
|
||||
* text=auto
|
||||
@@ -1,19 +0,0 @@
|
||||
You are opening a _bug report_ against the libgit2 project: we use
|
||||
GitHub Issues for tracking bug reports and feature requests. If you
|
||||
have a question about an API or usage, please ask on StackOverflow:
|
||||
http://stackoverflow.com/questions/tagged/libgit2. If you want to
|
||||
have high-level discussions about the libgit2 project itself, visit
|
||||
https://github.com/libgit2/discussions.
|
||||
|
||||
Otherwise, to report a bug, please fill out the reproduction steps
|
||||
(below) and delete these introductory paragraphs. Thanks!
|
||||
|
||||
### Reproduction steps
|
||||
|
||||
### Expected behavior
|
||||
|
||||
### Actual behavior
|
||||
|
||||
### Version of libgit2 (release number or SHA1)
|
||||
|
||||
### Operating system(s) tested
|
||||
37
godot-git-plugin/thirdparty/libgit2/.gitignore
vendored
37
godot-git-plugin/thirdparty/libgit2/.gitignore
vendored
@@ -1,37 +0,0 @@
|
||||
/tests/clar.suite
|
||||
/tests/clar.suite.rule
|
||||
/tests/.clarcache
|
||||
/apidocs
|
||||
/trash-*.exe
|
||||
/libgit2.pc
|
||||
/config.mak
|
||||
*.o
|
||||
*.a
|
||||
*.exe
|
||||
*.gcda
|
||||
*.gcno
|
||||
*.gcov
|
||||
.lock-wafbuild
|
||||
.waf*
|
||||
build/
|
||||
build-amiga/
|
||||
tests/tmp/
|
||||
msvc/Debug/
|
||||
msvc/Release/
|
||||
*.sln
|
||||
*.suo
|
||||
*.vc*proj*
|
||||
*.sdf
|
||||
*.opensdf
|
||||
*.aps
|
||||
*.cmake
|
||||
!cmake/Modules/*.cmake
|
||||
.DS_Store
|
||||
*~
|
||||
.*.swp
|
||||
tags
|
||||
mkmf.log
|
||||
*.profdata
|
||||
*.profraw
|
||||
CMakeSettings.json
|
||||
.vs
|
||||
22
godot-git-plugin/thirdparty/libgit2/.mailmap
vendored
22
godot-git-plugin/thirdparty/libgit2/.mailmap
vendored
@@ -1,22 +0,0 @@
|
||||
Vicent Martí <vicent@github.com> Vicent Marti <tanoku@gmail.com>
|
||||
Vicent Martí <vicent@github.com> Vicent Martí <tanoku@gmail.com>
|
||||
Michael Schubert <schu@schu.io> schu <schu-github@schulog.org>
|
||||
Ben Straub <bs@github.com> Ben Straub <ben@straubnet.net>
|
||||
Ben Straub <bs@github.com> Ben Straub <bstraub@github.com>
|
||||
Carlos Martín Nieto <cmn@dwim.me> <carlos@cmartin.tk>
|
||||
Carlos Martín Nieto <cmn@dwim.me> <cmn@elego.de>
|
||||
nulltoken <emeric.fermas@gmail.com> <emeric.fermas@gmail.com>
|
||||
Scott J. Goldman <scottjg@github.com> <scottjgo@gmail.com>
|
||||
Martin Woodward <martin.woodward@microsoft.com> <martinwo@microsoft.com>
|
||||
Peter Drahoš <drahosp@gmail.com> <drahosp@gmail.com>
|
||||
Adam Roben <adam@github.com> <adam@roben.org>
|
||||
Adam Roben <adam@github.com> <adam@github.com>
|
||||
Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.ca>
|
||||
Xavier L. <xavier.l@afrosoft.tk> <xavier.l@afrosoft.tk>
|
||||
Sascha Cunz <sascha@babbelbox.org> <Sascha@BabbelBox.org>
|
||||
Authmillenon <authmillenon@googlemail.com> <martin@ucsmail.de>
|
||||
Authmillenon <authmillenon@googlemail.com> <authmillenon@googlemail.com>
|
||||
Edward Thomson <ethomson@edwardthomson.com> <ethomson@microsoft.com>
|
||||
Edward Thomson <ethomson@edwardthomson.com> <ethomson@github.com>
|
||||
J. David Ibáñez <jdavid.ibp@gmail.com> <jdavid@itaapy.com>
|
||||
Russell Belfer <rb@github.com> <arrbee@arrbee.com>
|
||||
78
godot-git-plugin/thirdparty/libgit2/AUTHORS
vendored
78
godot-git-plugin/thirdparty/libgit2/AUTHORS
vendored
@@ -1,78 +0,0 @@
|
||||
The following people contribute or have contributed
|
||||
to the libgit2 project (sorted alphabetically):
|
||||
|
||||
Alex Budovski
|
||||
Alexei Sholik
|
||||
Andreas Ericsson
|
||||
Anton "antong" Gyllenberg
|
||||
Ankur Sethi
|
||||
Arthur Schreiber
|
||||
Ben Noordhuis
|
||||
Ben Straub
|
||||
Benjamin C Meyer
|
||||
Brian Downing
|
||||
Brian Lopez
|
||||
Carlos Martín Nieto
|
||||
Colin Timmermans
|
||||
Daniel Huckstep
|
||||
Dave Borowitz
|
||||
David Boyce
|
||||
David Glesser
|
||||
Dmitry Kakurin
|
||||
Dmitry Kovega
|
||||
Emeric Fermas
|
||||
Emmanuel Rodriguez
|
||||
Eric Myhre
|
||||
Erik Aigner
|
||||
Florian Forster
|
||||
Holger Weiss
|
||||
Ingmar Vanhassel
|
||||
J. David Ibáñez
|
||||
Jacques Germishuys
|
||||
Jakob Pfender
|
||||
Jason Penny
|
||||
Jason R. McNeil
|
||||
Jerome Lambourg
|
||||
Johan 't Hart
|
||||
John Wiegley
|
||||
Jonathan "Duke" Leto
|
||||
Julien Miotte
|
||||
Julio Espinoza-Sokal
|
||||
Justin Love
|
||||
Kelly "kelly.leahy" Leahy
|
||||
Kirill A. Shutemov
|
||||
Lambert CLARA
|
||||
Luc Bertrand
|
||||
Marc Pegon
|
||||
Marcel Groothuis
|
||||
Marco Villegas
|
||||
Michael "schu" Schubert
|
||||
Microsoft Corporation
|
||||
Olivier Ramonat
|
||||
Peter Drahoš
|
||||
Pierre Habouzit
|
||||
Pierre-Olivier Latour
|
||||
Przemyslaw Pawelczyk
|
||||
Ramsay Jones
|
||||
Robert G. Jakabosky
|
||||
Romain Geissler
|
||||
Romain Muller
|
||||
Russell Belfer
|
||||
Sakari Jokinen
|
||||
Samuel Charles "Sam" Day
|
||||
Sarath Lakshman
|
||||
Sascha Cunz
|
||||
Sascha Peilicke
|
||||
Scott Chacon
|
||||
Sebastian Schuberth
|
||||
Sergey Nikishin
|
||||
Shawn O. Pearce
|
||||
Shuhei Tanuma
|
||||
Steve Frécinaux
|
||||
Sven Strickroth
|
||||
Tim Branyen
|
||||
Tim Clem
|
||||
Tim Harder
|
||||
Torsten Bögershausen
|
||||
Trent Mick
|
||||
Vicent Marti
|
||||
340
godot-git-plugin/thirdparty/libgit2/CMakeLists.txt
vendored
340
godot-git-plugin/thirdparty/libgit2/CMakeLists.txt
vendored
@@ -1,340 +0,0 @@
|
||||
# CMake build script for the libgit2 project
|
||||
#
|
||||
# Building (out of source build):
|
||||
# > mkdir build && cd build
|
||||
# > cmake .. [-DSETTINGS=VALUE]
|
||||
# > cmake --build .
|
||||
#
|
||||
# Testing:
|
||||
# > ctest -V
|
||||
#
|
||||
# Install:
|
||||
# > cmake --build . --target install
|
||||
|
||||
PROJECT(libgit2 C)
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
|
||||
CMAKE_POLICY(SET CMP0015 NEW)
|
||||
IF(POLICY CMP0051)
|
||||
CMAKE_POLICY(SET CMP0051 NEW)
|
||||
ENDIF()
|
||||
IF(POLICY CMP0042)
|
||||
CMAKE_POLICY(SET CMP0042 NEW)
|
||||
ENDIF()
|
||||
IF(POLICY CMP0054)
|
||||
CMAKE_POLICY(SET CMP0054 NEW)
|
||||
ENDIF()
|
||||
|
||||
# Add find modules to the path
|
||||
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/Modules/")
|
||||
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckSymbolExists)
|
||||
INCLUDE(CheckStructHasMember)
|
||||
INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0
|
||||
INCLUDE(AddCFlagIfSupported)
|
||||
INCLUDE(FindPkgLibraries)
|
||||
INCLUDE(FindThreads)
|
||||
INCLUDE(FindStatNsec)
|
||||
INCLUDE(GNUInstallDirs)
|
||||
INCLUDE(IdeSplitSources)
|
||||
INCLUDE(FeatureSummary)
|
||||
INCLUDE(EnableWarnings)
|
||||
|
||||
# Build options
|
||||
#
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
OPTION(SONAME "Set the (SO)VERSION of the target" ON)
|
||||
OPTION(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
|
||||
OPTION(THREADSAFE "Build libgit2 as threadsafe" ON)
|
||||
OPTION(BUILD_CLAR "Build Tests using the Clar suite" ON)
|
||||
OPTION(BUILD_EXAMPLES "Build library usage example apps" OFF)
|
||||
OPTION(BUILD_FUZZERS "Build the fuzz targets" OFF)
|
||||
OPTION(TAGS "Generate tags" OFF)
|
||||
OPTION(PROFILE "Generate profiling information" OFF)
|
||||
OPTION(ENABLE_TRACE "Enables tracing support" ON)
|
||||
OPTION(LIBGIT2_FILENAME "Name of the produced binary" OFF)
|
||||
OPTION(USE_SSH "Link with libssh2 to enable SSH support" ON)
|
||||
OPTION(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
|
||||
OPTION(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS/Generic" ON)
|
||||
OPTION(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
|
||||
OPTION(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
|
||||
OPTION(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
|
||||
OPTION(DEBUG_POOL "Enable debug pool allocator" OFF)
|
||||
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF)
|
||||
SET(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
|
||||
OPTION(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
|
||||
SET(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
|
||||
|
||||
IF (UNIX)
|
||||
IF (NOT USE_HTTPS)
|
||||
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF )
|
||||
ELSE()
|
||||
OPTION(USE_NTLMCLIENT "Enable NTLM support on Unix." ON )
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF (UNIX AND NOT APPLE)
|
||||
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
|
||||
ENDIF()
|
||||
|
||||
IF (APPLE)
|
||||
OPTION(USE_ICONV "Link with and use iconv library" ON)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# This option must match the settings used in your program, in particular if you
|
||||
# are linking statically
|
||||
OPTION(STATIC_CRT "Link the static CRT libraries" ON)
|
||||
|
||||
# If you want to embed a copy of libssh2 into libgit2, pass a
|
||||
# path to libssh2
|
||||
OPTION(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
|
||||
ENDIF()
|
||||
|
||||
|
||||
IF(WIN32)
|
||||
# By default, libgit2 is built with WinHTTP. To use the built-in
|
||||
# HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
|
||||
OPTION(WINHTTP "Use Win32 WinHTTP routines" ON)
|
||||
ENDIF()
|
||||
|
||||
IF(MSVC)
|
||||
# Enable MSVC CRTDBG memory leak reporting when in debug mode.
|
||||
OPTION(MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF)
|
||||
ENDIF()
|
||||
|
||||
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \"[^\"]*\"$")
|
||||
|
||||
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"([0-9]+).*$" "\\1" LIBGIT2_VERSION_MAJOR "${GIT2_HEADER}")
|
||||
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_MINOR "${GIT2_HEADER}")
|
||||
STRING(REGEX REPLACE "^.*LIBGIT2_VERSION \"[0-9]+\\.[0-9]+\\.([0-9]+).*$" "\\1" LIBGIT2_VERSION_REV "${GIT2_HEADER}")
|
||||
SET(LIBGIT2_VERSION_STRING "${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}.${LIBGIT2_VERSION_REV}")
|
||||
|
||||
FILE(STRINGS "${libgit2_SOURCE_DIR}/include/git2/version.h" GIT2_HEADER_SOVERSION REGEX "^#define LIBGIT2_SOVERSION \"([0-9.]+)\"$")
|
||||
STRING(REGEX REPLACE "^.*LIBGIT2_SOVERSION \"([0-9.]+)\"$" "\\1" LIBGIT2_SOVERSION "${GIT2_HEADER_SOVERSION}")
|
||||
|
||||
IF (DEPRECATE_HARD)
|
||||
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
|
||||
ENDIF()
|
||||
|
||||
# Platform specific compilation flags
|
||||
IF (MSVC)
|
||||
IF (STDCALL)
|
||||
MESSAGE(FATAL_ERROR "The STDCALL option is no longer supported; libgit2 is now always built as a cdecl library. If you're using PInvoke, please add the CallingConventions.Cdecl attribute for support.")
|
||||
ENDIF()
|
||||
|
||||
ADD_DEFINITIONS(-D_SCL_SECURE_NO_WARNINGS)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
ADD_DEFINITIONS(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
|
||||
STRING(REPLACE "/Zm1000" " " CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
|
||||
# /GF - String pooling
|
||||
# /MP - Parallel build
|
||||
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
|
||||
|
||||
# /Gd - explicitly set cdecl calling convention
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
|
||||
|
||||
IF (STATIC_CRT)
|
||||
SET(CRT_FLAG_DEBUG "/MTd")
|
||||
SET(CRT_FLAG_RELEASE "/MT")
|
||||
ELSE()
|
||||
SET(CRT_FLAG_DEBUG "/MDd")
|
||||
SET(CRT_FLAG_RELEASE "/MD")
|
||||
ENDIF()
|
||||
|
||||
IF (MSVC_CRTDBG)
|
||||
SET(GIT_MSVC_CRTDBG 1)
|
||||
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
|
||||
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
|
||||
ENDIF()
|
||||
|
||||
# /Zi - Create debugging information
|
||||
# /Od - Disable optimization
|
||||
# /D_DEBUG - #define _DEBUG
|
||||
# /MTd - Statically link the multithreaded debug version of the CRT
|
||||
# /MDd - Dynamically link the multithreaded debug version of the CRT
|
||||
# /RTC1 - Run time checks
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Zi /Od /D_DEBUG /RTC1 ${CRT_FLAG_DEBUG}")
|
||||
|
||||
# /DNDEBUG - Disables asserts
|
||||
# /MT - Statically link the multithreaded release version of the CRT
|
||||
# /MD - Dynamically link the multithreaded release version of the CRT
|
||||
# /O2 - Optimize for speed
|
||||
# /Oy - Enable frame pointer omission (FPO) (otherwise CMake will automatically turn it off)
|
||||
# /GL - Link time code generation (whole program optimization)
|
||||
# /Gy - Function-level linking
|
||||
SET(CMAKE_C_FLAGS_RELEASE "/DNDEBUG /O2 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
|
||||
|
||||
# /Oy- - Disable frame pointer omission (FPO)
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "/DNDEBUG /Zi /O2 /Oy- /GL /Gy ${CRT_FLAG_RELEASE}")
|
||||
|
||||
# /O1 - Optimize for size
|
||||
SET(CMAKE_C_FLAGS_MINSIZEREL "/DNDEBUG /O1 /Oy /GL /Gy ${CRT_FLAG_RELEASE}")
|
||||
|
||||
# /IGNORE:4221 - Ignore empty compilation units
|
||||
SET(CMAKE_STATIC_LINKER_FLAGS "/IGNORE:4221")
|
||||
|
||||
# /DYNAMICBASE - Address space load randomization (ASLR)
|
||||
# /NXCOMPAT - Data execution prevention (DEP)
|
||||
# /LARGEADDRESSAWARE - >2GB user address space on x86
|
||||
# /VERSION - Embed version information in PE header
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "/DYNAMICBASE /NXCOMPAT /LARGEADDRESSAWARE /VERSION:${LIBGIT2_VERSION_MAJOR}.${LIBGIT2_VERSION_MINOR}")
|
||||
|
||||
# /DEBUG - Create a PDB
|
||||
# /LTCG - Link time code generation (whole program optimization)
|
||||
# /OPT:REF /OPT:ICF - Fold out duplicate code at link step
|
||||
# /INCREMENTAL:NO - Required to use /LTCG
|
||||
# /DEBUGTYPE:cv,fixup - Additional data embedded in the PDB (requires /INCREMENTAL:NO, so not on for Debug)
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO "/DEBUG /RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO /DEBUGTYPE:cv,fixup")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS_MINSIZEREL "/RELEASE /LTCG /OPT:REF /OPT:ICF /INCREMENTAL:NO")
|
||||
|
||||
# Same linker settings for DLL as EXE
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO}")
|
||||
SET(CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL "${CMAKE_EXE_LINKER_FLAGS_MINSIZEREL}")
|
||||
ELSE ()
|
||||
IF (ENABLE_REPRODUCIBLE_BUILDS)
|
||||
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> Dqc <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
SET(CMAKE_C_ARCHIVE_APPEND "<CMAKE_AR> Dq <TARGET> <LINK_FLAGS> <OBJECTS>")
|
||||
SET(CMAKE_C_ARCHIVE_FINISH "<CMAKE_RANLIB> -D <TARGET>")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_C_FLAGS "-D_GNU_SOURCE ${CMAKE_C_FLAGS}")
|
||||
|
||||
ENABLE_WARNINGS(all)
|
||||
ENABLE_WARNINGS(extra)
|
||||
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
|
||||
SET(CMAKE_C_FLAGS "-D_POSIX_C_SOURCE=200112L -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS ${CMAKE_C_FLAGS}")
|
||||
ENDIF()
|
||||
|
||||
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG -O0")
|
||||
|
||||
IF (MINGW OR MSYS) # MinGW and MSYS always do PIC and complain if we tell them to
|
||||
STRING(REGEX REPLACE "-fPIC" "" CMAKE_SHARED_LIBRARY_C_FLAGS "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
|
||||
ELSEIF (BUILD_SHARED_LIBS)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-fvisibility=hidden)
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC")
|
||||
ENDIF ()
|
||||
|
||||
IF (MINGW)
|
||||
# MinGW >= 3.14 uses the C99-style stdio functions
|
||||
# automatically, but forks like mingw-w64 still want
|
||||
# us to define this in order to use them
|
||||
ADD_DEFINITIONS(-D__USE_MINGW_ANSI_STDIO=1)
|
||||
ENDIF ()
|
||||
|
||||
ENABLE_WARNINGS(documentation)
|
||||
DISABLE_WARNINGS(missing-field-initializers)
|
||||
ENABLE_WARNINGS(strict-aliasing)
|
||||
ENABLE_WARNINGS(strict-prototypes)
|
||||
ENABLE_WARNINGS(declaration-after-statement)
|
||||
ENABLE_WARNINGS(shift-count-overflow)
|
||||
ENABLE_WARNINGS(unused-const-variable)
|
||||
ENABLE_WARNINGS(unused-function)
|
||||
ENABLE_WARNINGS(int-conversion)
|
||||
|
||||
# MinGW uses gcc, which expects POSIX formatting for printf, but
|
||||
# uses the Windows C library, which uses its own format specifiers.
|
||||
# Disable format specifier warnings.
|
||||
IF(MINGW)
|
||||
DISABLE_WARNINGS(format)
|
||||
DISABLE_WARNINGS(format-security)
|
||||
ELSE()
|
||||
ENABLE_WARNINGS(format)
|
||||
ENABLE_WARNINGS(format-security)
|
||||
ENDIF()
|
||||
|
||||
IF("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
DISABLE_WARNINGS(documentation-deprecated-sync)
|
||||
ENDIF()
|
||||
|
||||
IF (PROFILE)
|
||||
SET(CMAKE_C_FLAGS "-pg ${CMAKE_C_FLAGS}")
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "-pg ${CMAKE_EXE_LINKER_FLAGS}")
|
||||
ENDIF ()
|
||||
ENDIF()
|
||||
|
||||
# Ensure that MinGW provides the correct header files.
|
||||
IF (WIN32 AND NOT CYGWIN)
|
||||
ADD_DEFINITIONS(-DWIN32 -D_WIN32_WINNT=0x0600)
|
||||
ENDIF()
|
||||
|
||||
IF( NOT CMAKE_CONFIGURATION_TYPES )
|
||||
# Build Debug by default
|
||||
IF (NOT CMAKE_BUILD_TYPE)
|
||||
SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
ENDIF ()
|
||||
ELSE()
|
||||
# Using a multi-configuration generator eg MSVC or Xcode
|
||||
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
|
||||
ENDIF()
|
||||
|
||||
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
|
||||
# The actual sanitizer link target will be added when linking the fuzz
|
||||
# targets.
|
||||
SET(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
|
||||
ADD_C_FLAG(-fsanitize=fuzzer-no-link)
|
||||
UNSET(CMAKE_REQUIRED_FLAGS)
|
||||
ENDIF ()
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
|
||||
# Tests
|
||||
IF (NOT MSVC)
|
||||
IF (NOT BUILD_SHARED_LIBS)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
|
||||
IF (BUILD_CLAR)
|
||||
ENABLE_TESTING()
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
ENDIF ()
|
||||
|
||||
IF (TAGS)
|
||||
FIND_PROGRAM(CTAGS ctags)
|
||||
IF (NOT CTAGS)
|
||||
MESSAGE(FATAL_ERROR "Could not find ctags command")
|
||||
ENDIF ()
|
||||
|
||||
FILE(GLOB_RECURSE SRC_ALL *.[ch])
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
OUTPUT tags
|
||||
COMMAND ${CTAGS} -a ${SRC_ALL}
|
||||
DEPENDS ${SRC_ALL}
|
||||
)
|
||||
ADD_CUSTOM_TARGET(
|
||||
do_tags ALL
|
||||
DEPENDS tags
|
||||
)
|
||||
ENDIF ()
|
||||
|
||||
IF (BUILD_EXAMPLES)
|
||||
ADD_SUBDIRECTORY(examples)
|
||||
ENDIF ()
|
||||
|
||||
IF(BUILD_FUZZERS)
|
||||
IF(NOT USE_STANDALONE_FUZZERS)
|
||||
IF(BUILD_EXAMPLES)
|
||||
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
|
||||
ENDIF()
|
||||
IF(BUILD_CLAR)
|
||||
MESSAGE(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ADD_SUBDIRECTORY(fuzzers)
|
||||
ENDIF()
|
||||
|
||||
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
|
||||
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
|
||||
1021
godot-git-plugin/thirdparty/libgit2/COPYING
vendored
1021
godot-git-plugin/thirdparty/libgit2/COPYING
vendored
File diff suppressed because it is too large
Load Diff
391
godot-git-plugin/thirdparty/libgit2/README.md
vendored
391
godot-git-plugin/thirdparty/libgit2/README.md
vendored
@@ -1,391 +0,0 @@
|
||||
libgit2 - the Git linkable library
|
||||
==================================
|
||||
|
||||
| Build Status | |
|
||||
| ------------ | - |
|
||||
| **master** branch CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=master) |
|
||||
| **v0.99 branch** CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.99) |
|
||||
| **v0.28 branch** CI builds | [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=7&branchName=maint/v0.28) |
|
||||
| **Nightly** builds | [](https://libgit2.visualstudio.com/libgit2/_build/latest?definitionId=9&branchName=master) [](https://dev.azure.com/libgit2/libgit2/_build/latest?definitionId=21?branchName=master) [](https://scan.coverity.com/projects/639) |
|
||||
|
||||
`libgit2` is a portable, pure C implementation of the Git core methods
|
||||
provided as a linkable library with a solid API, allowing to build Git
|
||||
functionality into your application. Language bindings like
|
||||
[Rugged](https://github.com/libgit2/rugged) (Ruby),
|
||||
[LibGit2Sharp](https://github.com/libgit2/libgit2sharp) (.NET),
|
||||
[pygit2](http://www.pygit2.org/) (Python) and
|
||||
[NodeGit](http://nodegit.org) (Node) allow you to build Git tooling
|
||||
in your favorite language.
|
||||
|
||||
`libgit2` is used to power Git GUI clients like
|
||||
[GitKraken](https://gitkraken.com/) and [gmaster](https://gmaster.io/)
|
||||
and on Git hosting providers like [GitHub](https://github.com/),
|
||||
[GitLab](https://gitlab.com/) and
|
||||
[Azure DevOps](https://azure.com/devops).
|
||||
We perform the merge every time you click "merge pull request".
|
||||
|
||||
`libgit2` is licensed under a **very permissive license** (GPLv2 with a special
|
||||
Linking Exception). This basically means that you can link it (unmodified)
|
||||
with any kind of software without having to release its source code.
|
||||
Additionally, the example code has been released to the public domain (see the
|
||||
[separate license](examples/COPYING) for more information).
|
||||
|
||||
Table of Contents
|
||||
=================
|
||||
|
||||
* [Quick Start](#quick-start)
|
||||
* [Getting Help](#getting-help)
|
||||
* [What It Can Do](#what-it-can-do)
|
||||
* [Optional dependencies](#optional-dependencies)
|
||||
* [Initialization](#initialization)
|
||||
* [Threading](#threading)
|
||||
* [Conventions](#conventions)
|
||||
* [Building libgit2 - Using CMake](#building-libgit2---using-cmake)
|
||||
* [Building](#building)
|
||||
* [Installation](#installation)
|
||||
* [Advanced Usage](#advanced-usage)
|
||||
* [Compiler and linker options](#compiler-and-linker-options)
|
||||
* [MacOS X](#macos-x)
|
||||
* [Android](#android)
|
||||
* [Language Bindings](#language-bindings)
|
||||
* [How Can I Contribute?](#how-can-i-contribute)
|
||||
* [License](#license)
|
||||
|
||||
Quick Start
|
||||
===========
|
||||
|
||||
**Prerequisites** for building libgit2:
|
||||
|
||||
1. [CMake](https://cmake.org/), and is recommended to be installed into
|
||||
your `PATH`.
|
||||
2. [Python](https://www.python.org) is used by our test framework, and
|
||||
should be installed into your `PATH`.
|
||||
3. C compiler: libgit2 is C90 and should compile on most compilers.
|
||||
* Windows: Visual Studio is recommended
|
||||
* Mac: Xcode is recommended
|
||||
* Unix: gcc or clang is recommended.
|
||||
|
||||
**Build**
|
||||
|
||||
1. Create a build directory beneath the libgit2 source directory, and change
|
||||
into it: `mkdir build && cd build`
|
||||
2. Create the cmake build environment: `cmake ..`
|
||||
3. Build libgit2: `cmake --build .`
|
||||
|
||||
Trouble with these steps? Read our [troubleshooting guide](docs/troubleshooting.md).
|
||||
More detailed build guidance is available below.
|
||||
|
||||
Getting Help
|
||||
============
|
||||
|
||||
**Chat with us**
|
||||
|
||||
- via IRC: join [#libgit2](https://webchat.freenode.net/#libgit2) on Freenode
|
||||
- via Slack: visit [slack.libgit2.org](http://slack.libgit2.org/) to sign up,
|
||||
then join us in `#libgit2`
|
||||
|
||||
**Getting Help**
|
||||
|
||||
If you have questions about the library, please be sure to check out the
|
||||
[API documentation](http://libgit2.github.com/libgit2/). If you still have
|
||||
questions, reach out to us on Slack or post a question on
|
||||
[StackOverflow](http://stackoverflow.com/questions/tagged/libgit2) (with the `libgit2` tag).
|
||||
|
||||
**Reporting Bugs**
|
||||
|
||||
Please open a [GitHub Issue](https://github.com/libgit2/libgit2/issues) and
|
||||
include as much information as possible. If possible, provide sample code
|
||||
that illustrates the problem you're seeing. If you're seeing a bug only
|
||||
on a specific repository, please provide a link to it if possible.
|
||||
|
||||
We ask that you not open a GitHub Issue for help, only for bug reports.
|
||||
|
||||
**Reporting Security Issues**
|
||||
|
||||
Please have a look at SECURITY.md.
|
||||
|
||||
What It Can Do
|
||||
==============
|
||||
|
||||
libgit2 provides you with the ability to manage Git repositories in the
|
||||
programming language of your choice. It's used in production to power many
|
||||
applications including GitHub.com, Plastic SCM and Azure DevOps.
|
||||
|
||||
It does not aim to replace the git tool or its user-facing commands. Some APIs
|
||||
resemble the plumbing commands as those align closely with the concepts of the
|
||||
Git system, but most commands a user would type are out of scope for this
|
||||
library to implement directly.
|
||||
|
||||
The library provides:
|
||||
|
||||
* SHA conversions, formatting and shortening
|
||||
* abstracted ODB backend system
|
||||
* commit, tag, tree and blob parsing, editing, and write-back
|
||||
* tree traversal
|
||||
* revision walking
|
||||
* index file (staging area) manipulation
|
||||
* reference management (including packed references)
|
||||
* config file management
|
||||
* high level repository management
|
||||
* thread safety and reentrancy
|
||||
* descriptive and detailed error messages
|
||||
* ...and more (over 175 different API calls)
|
||||
|
||||
As libgit2 is purely a consumer of the Git system, we have to
|
||||
adjust to changes made upstream. This has two major consequences:
|
||||
|
||||
* Some changes may require us to change provided interfaces. While we try to
|
||||
implement functions in a generic way so that no future changes are required,
|
||||
we cannot promise a completely stable API.
|
||||
* As we have to keep up with changes in behavior made upstream, we may lag
|
||||
behind in some areas. We usually to document these incompatibilities in our
|
||||
issue tracker with the label "git change".
|
||||
|
||||
Optional dependencies
|
||||
=====================
|
||||
|
||||
While the library provides git functionality without the need for
|
||||
dependencies, it can make use of a few libraries to add to it:
|
||||
|
||||
- pthreads (non-Windows) to enable threadsafe access as well as multi-threaded pack generation
|
||||
- OpenSSL (non-Windows) to talk over HTTPS and provide the SHA-1 functions
|
||||
- LibSSH2 to enable the SSH transport
|
||||
- iconv (OSX) to handle the HFS+ path encoding peculiarities
|
||||
|
||||
Initialization
|
||||
===============
|
||||
|
||||
The library needs to keep track of some global state. Call
|
||||
|
||||
git_libgit2_init();
|
||||
|
||||
before calling any other libgit2 functions. You can call this function many times. A matching number of calls to
|
||||
|
||||
git_libgit2_shutdown();
|
||||
|
||||
will free the resources. Note that if you have worker threads, you should
|
||||
call `git_libgit2_shutdown` *after* those threads have exited. If you
|
||||
require assistance coordinating this, simply have the worker threads call
|
||||
`git_libgit2_init` at startup and `git_libgit2_shutdown` at shutdown.
|
||||
|
||||
Threading
|
||||
=========
|
||||
|
||||
See [threading](docs/threading.md) for information
|
||||
|
||||
Conventions
|
||||
===========
|
||||
|
||||
See [conventions](docs/conventions.md) for an overview of the external
|
||||
and internal API/coding conventions we use.
|
||||
|
||||
Building libgit2 - Using CMake
|
||||
==============================
|
||||
|
||||
Building
|
||||
--------
|
||||
|
||||
`libgit2` builds cleanly on most platforms without any external dependencies.
|
||||
Under Unix-like systems, like Linux, \*BSD and Mac OS X, libgit2 expects `pthreads` to be available;
|
||||
they should be installed by default on all systems. Under Windows, libgit2 uses the native Windows API
|
||||
for threading.
|
||||
|
||||
The `libgit2` library is built using [CMake](<https://cmake.org/>) (version 2.8 or newer) on all platforms.
|
||||
|
||||
On most systems you can build the library using the following commands
|
||||
|
||||
$ mkdir build && cd build
|
||||
$ cmake ..
|
||||
$ cmake --build .
|
||||
|
||||
Alternatively you can point the CMake GUI tool to the CMakeLists.txt file and generate platform specific build project or IDE workspace.
|
||||
|
||||
Running Tests
|
||||
-------------
|
||||
|
||||
Once built, you can run the tests from the `build` directory with the command
|
||||
|
||||
$ ctest -V
|
||||
|
||||
Alternatively you can run the test suite directly using,
|
||||
|
||||
$ ./libgit2_clar
|
||||
|
||||
Invoking the test suite directly is useful because it allows you to execute
|
||||
individual tests, or groups of tests using the `-s` flag. For example, to
|
||||
run the index tests:
|
||||
|
||||
$ ./libgit2_clar -sindex
|
||||
|
||||
To run a single test named `index::racy::diff`, which corresponds to the test
|
||||
function [`test_index_racy__diff`](https://github.com/libgit2/libgit2/blob/master/tests/index/racy.c#L23):
|
||||
|
||||
$ ./libgit2_clar -sindex::racy::diff
|
||||
|
||||
The test suite will print a `.` for every passing test, and an `F` for any
|
||||
failing test. An `S` indicates that a test was skipped because it is not
|
||||
applicable to your platform or is particularly expensive.
|
||||
|
||||
**Note:** There should be _no_ failing tests when you build an unmodified
|
||||
source tree from a [release](https://github.com/libgit2/libgit2/releases),
|
||||
or from the [master branch](https://github.com/libgit2/libgit2/tree/master).
|
||||
Please contact us or [open an issue](https://github.com/libgit2/libgit2/issues)
|
||||
if you see test failures.
|
||||
|
||||
Installation
|
||||
------------
|
||||
|
||||
To install the library you can specify the install prefix by setting:
|
||||
|
||||
$ cmake .. -DCMAKE_INSTALL_PREFIX=/install/prefix
|
||||
$ cmake --build . --target install
|
||||
|
||||
Advanced Usage
|
||||
--------------
|
||||
|
||||
For more advanced use or questions about CMake please read <https://cmake.org/Wiki/CMake_FAQ>.
|
||||
|
||||
The following CMake variables are declared:
|
||||
|
||||
- `CMAKE_INSTALL_BINDIR`: Where to install binaries to.
|
||||
- `CMAKE_INSTALL_LIBDIR`: Where to install libraries to.
|
||||
- `CMAKE_INSTALL_INCLUDEDIR`: Where to install headers to.
|
||||
- `BUILD_SHARED_LIBS`: Build libgit2 as a Shared Library (defaults to ON)
|
||||
- `BUILD_CLAR`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
|
||||
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
|
||||
|
||||
To list all build options and their current value, you can do the
|
||||
following:
|
||||
|
||||
# Create and set up a build directory
|
||||
$ mkdir build
|
||||
$ cmake ..
|
||||
# List all build options and their values
|
||||
$ cmake -L
|
||||
|
||||
Compiler and linker options
|
||||
---------------------------
|
||||
|
||||
CMake lets you specify a few variables to control the behavior of the
|
||||
compiler and linker. These flags are rarely used but can be useful for
|
||||
64-bit to 32-bit cross-compilation.
|
||||
|
||||
- `CMAKE_C_FLAGS`: Set your own compiler flags
|
||||
- `CMAKE_FIND_ROOT_PATH`: Override the search path for libraries
|
||||
- `ZLIB_LIBRARY`, `OPENSSL_SSL_LIBRARY` AND `OPENSSL_CRYPTO_LIBRARY`:
|
||||
Tell CMake where to find those specific libraries
|
||||
|
||||
MacOS X
|
||||
-------
|
||||
|
||||
If you want to build a universal binary for Mac OS X, CMake sets it
|
||||
all up for you if you use `-DCMAKE_OSX_ARCHITECTURES="i386;x86_64"`
|
||||
when configuring.
|
||||
|
||||
Android
|
||||
-------
|
||||
|
||||
Extract toolchain from NDK using, `make-standalone-toolchain.sh` script.
|
||||
Optionally, crosscompile and install OpenSSL inside of it. Then create CMake
|
||||
toolchain file that configures paths to your crosscompiler (substitute `{PATH}`
|
||||
with full path to the toolchain):
|
||||
|
||||
SET(CMAKE_SYSTEM_NAME Linux)
|
||||
SET(CMAKE_SYSTEM_VERSION Android)
|
||||
|
||||
SET(CMAKE_C_COMPILER {PATH}/bin/arm-linux-androideabi-gcc)
|
||||
SET(CMAKE_CXX_COMPILER {PATH}/bin/arm-linux-androideabi-g++)
|
||||
SET(CMAKE_FIND_ROOT_PATH {PATH}/sysroot/)
|
||||
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
|
||||
Add `-DCMAKE_TOOLCHAIN_FILE={pathToToolchainFile}` to cmake command
|
||||
when configuring.
|
||||
|
||||
Language Bindings
|
||||
==================================
|
||||
|
||||
Here are the bindings to libgit2 that are currently available:
|
||||
|
||||
* C++
|
||||
* libqgit2, Qt bindings <https://projects.kde.org/projects/playground/libs/libqgit2/repository/>
|
||||
* Chicken Scheme
|
||||
* chicken-git <https://wiki.call-cc.org/egg/git>
|
||||
* D
|
||||
* dlibgit <https://github.com/s-ludwig/dlibgit>
|
||||
* Delphi
|
||||
* GitForDelphi <https://github.com/libgit2/GitForDelphi>
|
||||
* Erlang
|
||||
* Geef <https://github.com/carlosmn/geef>
|
||||
* Go
|
||||
* git2go <https://github.com/libgit2/git2go>
|
||||
* GObject
|
||||
* libgit2-glib <https://wiki.gnome.org/Projects/Libgit2-glib>
|
||||
* Guile
|
||||
* Guile-Git <https://gitlab.com/guile-git/guile-git>
|
||||
* Haskell
|
||||
* hgit2 <https://github.com/jwiegley/gitlib>
|
||||
* Java
|
||||
* Jagged <https://github.com/ethomson/jagged>
|
||||
* Javascript / WebAssembly ( browser and nodejs )
|
||||
* WASM-git <https://github.com/petersalomonsen/wasm-git>
|
||||
* Julia
|
||||
* LibGit2.jl <https://github.com/JuliaLang/julia/tree/master/stdlib/LibGit2>
|
||||
* Lua
|
||||
* luagit2 <https://github.com/libgit2/luagit2>
|
||||
* .NET
|
||||
* libgit2sharp <https://github.com/libgit2/libgit2sharp>
|
||||
* Node.js
|
||||
* nodegit <https://github.com/nodegit/nodegit>
|
||||
* Objective-C
|
||||
* objective-git <https://github.com/libgit2/objective-git>
|
||||
* OCaml
|
||||
* ocaml-libgit2 <https://github.com/fxfactorial/ocaml-libgit2>
|
||||
* Parrot Virtual Machine
|
||||
* parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
|
||||
* Perl
|
||||
* Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
|
||||
* PHP
|
||||
* php-git <https://github.com/libgit2/php-git>
|
||||
* PowerShell
|
||||
* PSGit <https://github.com/PoshCode/PSGit>
|
||||
* Python
|
||||
* pygit2 <https://github.com/libgit2/pygit2>
|
||||
* R
|
||||
* git2r <https://github.com/ropensci/git2r>
|
||||
* Ruby
|
||||
* Rugged <https://github.com/libgit2/rugged>
|
||||
* Rust
|
||||
* git2-rs <https://github.com/rust-lang/git2-rs>
|
||||
* Swift
|
||||
* SwiftGit2 <https://github.com/SwiftGit2/SwiftGit2>
|
||||
* Vala
|
||||
* libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
|
||||
|
||||
If you start another language binding to libgit2, please let us know so
|
||||
we can add it to the list.
|
||||
|
||||
How Can I Contribute?
|
||||
==================================
|
||||
|
||||
We welcome new contributors! We have a number of issues marked as
|
||||
["up for grabs"](https://github.com/libgit2/libgit2/issues?q=is%3Aissue+is%3Aopen+label%3A%22up+for+grabs%22)
|
||||
and
|
||||
["easy fix"](https://github.com/libgit2/libgit2/issues?utf8=✓&q=is%3Aissue+is%3Aopen+label%3A%22easy+fix%22)
|
||||
that are good places to jump in and get started. There's much more detailed
|
||||
information in our list of [outstanding projects](docs/projects.md).
|
||||
|
||||
Please be sure to check the [contribution guidelines](docs/contributing.md) to
|
||||
understand our workflow, and the libgit2 [coding conventions](docs/conventions.md).
|
||||
|
||||
License
|
||||
==================================
|
||||
|
||||
`libgit2` is under GPL2 **with linking exception**. This means you can link to
|
||||
and use the library from any program, proprietary or open source; paid or
|
||||
gratis. However, if you modify libgit2 itself, you must distribute the
|
||||
source to your modified version of libgit2.
|
||||
|
||||
See the [COPYING file](COPYING) for the full license text.
|
||||
14
godot-git-plugin/thirdparty/libgit2/SECURITY.md
vendored
14
godot-git-plugin/thirdparty/libgit2/SECURITY.md
vendored
@@ -1,14 +0,0 @@
|
||||
# Security Policy
|
||||
|
||||
## Supported Versions
|
||||
|
||||
This project will always provide security fixes for the latest two released
|
||||
versions. E.g. if the latest version is v0.28.x, then we will provide security
|
||||
fixes for both v0.28.x and v0.27.y, but no later versions.
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
In case you think to have found a security issue with libgit2, please do not
|
||||
open a public issue. Instead, you can report the issue to the private mailing
|
||||
list [security@libgit2.com](mailto:security@libgit2.com). We will acknowledge
|
||||
receipt of your message in at most three days and try to clarify further steps.
|
||||
13
godot-git-plugin/thirdparty/libgit2/api.docurium
vendored
13
godot-git-plugin/thirdparty/libgit2/api.docurium
vendored
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"name": "libgit2",
|
||||
"github": "libgit2/libgit2",
|
||||
"input": "include",
|
||||
"prefix": "git_",
|
||||
"output": "docs",
|
||||
"branch": "gh-pages",
|
||||
"examples": "examples",
|
||||
"legacy": {
|
||||
"input": {"src/git": ["v0.1.0"],
|
||||
"src/git2": ["v0.2.0", "v0.3.0"]}
|
||||
}
|
||||
}
|
||||
@@ -1,190 +0,0 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
trigger:
|
||||
- master
|
||||
- maint/*
|
||||
|
||||
jobs:
|
||||
- job: linux_amd64_xenial_gcc_openssl
|
||||
displayName: 'Linux (amd64; Xenial; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
|
||||
|
||||
- job: linux_amd64_xenial_gcc_mbedtls
|
||||
displayName: 'Linux (amd64; Xenial; GCC; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
|
||||
|
||||
- job: linux_amd64_xenial_clang_openssl
|
||||
displayName: 'Linux (amd64; Xenial; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
|
||||
|
||||
- job: linux_amd64_xenial_clang_mbedtls
|
||||
displayName: 'Linux (amd64; Xenial; Clang; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: azure-pipelines/docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
GITTEST_NEGOTIATE_PASSWORD=${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
|
||||
|
||||
- job: macos
|
||||
displayName: 'macOS (amd64; 10.15)'
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
|
||||
displayName: Setup
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
TMPDIR: $(Agent.TempDirectory)
|
||||
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
GITTEST_NEGOTIATE_PASSWORD: ${{ variables.GITTEST_NEGOTIATE_PASSWORD }}
|
||||
|
||||
- job: windows_vs_amd64
|
||||
displayName: 'Windows (amd64; Visual Studio)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
|
||||
- job: windows_vs_x86
|
||||
displayName: 'Windows (x86; Visual Studio)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
|
||||
- job: windows_mingw_amd64
|
||||
displayName: 'Windows (amd64; MinGW)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
|
||||
displayName: Setup
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: amd64
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
CMAKE_GENERATOR: MinGW Makefiles
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
|
||||
- job: windows_mingw_x86
|
||||
displayName: 'Windows (x86; MinGW)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
|
||||
displayName: Setup
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: x86
|
||||
- template: azure-pipelines/bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
CMAKE_GENERATOR: MinGW Makefiles
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
|
||||
- job: documentation
|
||||
displayName: 'Generate Documentation'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- script: |
|
||||
cd $(Build.SourcesDirectory)/azure-pipelines/docker
|
||||
docker build -t libgit2/docurium --build-arg BASE=ubuntu:trusty -f docurium .
|
||||
displayName: 'Build Docker image'
|
||||
- script: |
|
||||
git config user.name 'Documentation Generation'
|
||||
git config user.email 'libgit2@users.noreply.github.com'
|
||||
git branch gh-pages origin/gh-pages
|
||||
docker run --rm -v $(Build.SourcesDirectory):/home/libgit2/source -w /home/libgit2/source libgit2/docurium:latest cm doc api.docurium
|
||||
git checkout gh-pages
|
||||
cp -R * '$(Build.BinariesDirectory)'
|
||||
displayName: 'Generate Documentation'
|
||||
- task: archivefiles@2
|
||||
displayName: 'Archive Documentation'
|
||||
inputs:
|
||||
rootFolderOrFile: '$(Build.BinariesDirectory)'
|
||||
includeRootFolder: false
|
||||
archiveFile: '$(Build.ArtifactStagingDirectory)/api-documentation.zip'
|
||||
- task: publishbuildartifacts@1
|
||||
displayName: 'Upload Documentation Artifact'
|
||||
inputs:
|
||||
pathToPublish: '$(Build.ArtifactStagingDirectory)'
|
||||
artifactName: 'docs'
|
||||
- script: |
|
||||
git remote -v
|
||||
echo 'machine github.com' > ~/.netrc
|
||||
echo 'login $(GITHUB_USERNAME)' >> ~/.netrc
|
||||
echo 'password $(GITHUB_PAT)' >> ~/.netrc
|
||||
git push origin gh-pages
|
||||
displayName: 'Publish Documentation'
|
||||
condition: and(eq(variables['Build.Repository.Name'], 'libgit2/libgit2'), eq(variables['Build.Reason'], 'IndividualCI'))
|
||||
@@ -1,17 +0,0 @@
|
||||
# These are the steps used for building on machines with bash.
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/build.sh'
|
||||
displayName: Build
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
env: ${{ parameters.environmentVariables }}
|
||||
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/test.sh'
|
||||
displayName: Test
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
env: ${{ parameters.environmentVariables }}
|
||||
- task: PublishTestResults@2
|
||||
displayName: Publish Test Results
|
||||
condition: succeededOrFailed()
|
||||
inputs:
|
||||
testResultsFiles: 'results_*.xml'
|
||||
searchFolder: '$(Build.BinariesDirectory)'
|
||||
mergeTestResults: true
|
||||
@@ -1,56 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Environment variables:
|
||||
#
|
||||
# SOURCE_DIR: Set to the directory of the libgit2 source (optional)
|
||||
# If not set, it will be derived relative to this script.
|
||||
|
||||
set -e
|
||||
|
||||
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
|
||||
BUILD_DIR=$(pwd)
|
||||
BUILD_PATH=${BUILD_PATH:=$PATH}
|
||||
CMAKE=$(which cmake)
|
||||
CMAKE_GENERATOR=${CMAKE_GENERATOR:-Unix Makefiles}
|
||||
|
||||
indent() { sed "s/^/ /"; }
|
||||
|
||||
echo "Source directory: ${SOURCE_DIR}"
|
||||
echo "Build directory: ${BUILD_DIR}"
|
||||
echo ""
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
echo "macOS version:"
|
||||
sw_vers | indent
|
||||
fi
|
||||
|
||||
if [ -f "/etc/debian_version" ]; then
|
||||
echo "Debian version:"
|
||||
(source /etc/lsb-release && echo "${DISTRIB_DESCRIPTION}") | indent
|
||||
fi
|
||||
|
||||
echo "Kernel version:"
|
||||
uname -a 2>&1 | indent
|
||||
|
||||
echo "CMake version:"
|
||||
env PATH="$BUILD_PATH" "$CMAKE" --version 2>&1 | indent
|
||||
|
||||
if test -n "$CC"; then
|
||||
echo "Compiler version:"
|
||||
"$CC" --version 2>&1 | indent
|
||||
fi
|
||||
echo ""
|
||||
|
||||
echo "##############################################################################"
|
||||
echo "## Configuring build environment"
|
||||
echo "##############################################################################"
|
||||
|
||||
echo cmake ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS}
|
||||
env PATH="$BUILD_PATH" "$CMAKE" ${SOURCE_DIR} -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS}
|
||||
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Building libgit2"
|
||||
echo "##############################################################################"
|
||||
|
||||
env PATH="$BUILD_PATH" "$CMAKE" --build .
|
||||
@@ -1,62 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
|
||||
if test -z "$COVERITY_TOKEN"
|
||||
then
|
||||
echo "Need to set a coverity token"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case $(uname -m) in
|
||||
i?86)
|
||||
BITS=32;;
|
||||
amd64|x86_64)
|
||||
BITS=64;;
|
||||
*)
|
||||
echo "Unsupported arch '$(uname -m)'"
|
||||
exit 1;;
|
||||
esac
|
||||
|
||||
SCAN_TOOL=https://scan.coverity.com/download/cxx/linux${BITS}
|
||||
SOURCE_DIR=$(realpath "$(dirname "${BASH_SOURCE[0]}")"/..)
|
||||
BUILD_DIR=${SOURCE_DIR}/coverity-build
|
||||
TOOL_DIR=${BUILD_DIR}/coverity-tools
|
||||
|
||||
# Install coverity tools
|
||||
if ! test -d "$TOOL_DIR"
|
||||
then
|
||||
mkdir -p "$TOOL_DIR"
|
||||
curl --silent --show-error --location --data "project=libgit2&token=$COVERITY_TOKEN" "$SCAN_TOOL" |
|
||||
tar -xzC "$TOOL_DIR"
|
||||
ln -s "$(find "$TOOL_DIR" -type d -name 'cov-analysis*')" "$TOOL_DIR"/cov-analysis
|
||||
fi
|
||||
|
||||
cp "${SOURCE_DIR}/script/user_nodefs.h" "$TOOL_DIR"/cov-analysis/config/
|
||||
|
||||
# Build libgit2 with Coverity
|
||||
mkdir -p "$BUILD_DIR"
|
||||
cd "$BUILD_DIR"
|
||||
cmake "$SOURCE_DIR"
|
||||
COVERITY_UNSUPPORTED=1 \
|
||||
"$TOOL_DIR/cov-analysis/bin/cov-build" --dir cov-int \
|
||||
cmake --build .
|
||||
|
||||
# Upload results
|
||||
tar -czf libgit2.tgz cov-int
|
||||
REVISION=$(cd ${SOURCE_DIR} && git rev-parse --short HEAD)
|
||||
HTML="$(curl \
|
||||
--silent --show-error \
|
||||
--write-out "\n%{http_code}" \
|
||||
--form token="$COVERITY_TOKEN" \
|
||||
--form email=libgit2@gmail.com \
|
||||
--form file=@libgit2.tgz \
|
||||
--form version="$REVISION" \
|
||||
--form description="libgit2 build" \
|
||||
https://scan.coverity.com/builds?project=libgit2)"
|
||||
|
||||
# Status code is the last line
|
||||
STATUS_CODE="$(echo "$HTML" | tail -n1)"
|
||||
if test "${STATUS_CODE}" != 200 && test "${STATUS_CODE}" != 201
|
||||
then
|
||||
echo "Received error code ${STATUS_CODE} from Coverity"
|
||||
exit 1
|
||||
fi
|
||||
@@ -1,26 +0,0 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
jobs:
|
||||
- job: coverity
|
||||
displayName: 'Coverity'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- script: |
|
||||
cd $(Build.SourcesDirectory)/azure-pipelines/docker
|
||||
docker build -t libgit2/xenial --build-arg BASE=ubuntu:xenial -f xenial .
|
||||
displayName: 'Build Docker image'
|
||||
- task: Docker@0
|
||||
displayName: Analyze
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: libgit2/xenial
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/home/libgit2/source
|
||||
$(Build.BinariesDirectory):/home/libgit2/build
|
||||
envVars: |
|
||||
COVERITY_TOKEN=$(COVERITY_TOKEN)
|
||||
workDir: '/home/libgit2/build'
|
||||
containerCommand: '/home/libgit2/source/azure-pipelines/coverity.sh'
|
||||
detached: false
|
||||
@@ -1,51 +0,0 @@
|
||||
# These are the steps used in a container-based build in VSTS.
|
||||
steps:
|
||||
- ${{ if eq(parameters.qemu, 'true') }}:
|
||||
- script: docker run --rm --privileged multiarch/qemu-user-static:register --reset
|
||||
displayName: 'Register Docker QEMU'
|
||||
|
||||
- task: cache@2
|
||||
displayName: Cache Docker layers
|
||||
inputs:
|
||||
key: docker
|
||||
path: /tmp/dockercache
|
||||
- script: |
|
||||
if [ -f /tmp/dockercache/${{parameters.docker.image}}.tar ]; then docker load < /tmp/dockercache/${{parameters.docker.image}}.tar; fi
|
||||
displayName: 'Load Docker cache'
|
||||
- script: |
|
||||
cd $(Build.SourcesDirectory)/azure-pipelines/docker &&
|
||||
docker build -t libgit2/${{parameters.docker.image}} --build-arg BASE=${{parameters.docker.base}} -f ${{parameters.docker.image}} . &&
|
||||
if [ ! -d /tmp/dockercache ]; then mkdir /tmp/dockercache; fi &&
|
||||
docker save libgit2/${{parameters.docker.image}} $(docker history -q libgit2/${{parameters.docker.image}} | grep -v '<missing>') > /tmp/dockercache/${{parameters.docker.image}}.tar
|
||||
displayName: 'Build Docker image'
|
||||
- task: docker@0
|
||||
displayName: Build
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: libgit2/${{ parameters.docker.image }}
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/home/libgit2/source
|
||||
$(Build.BinariesDirectory):/home/libgit2/build
|
||||
envVars: ${{ parameters.environmentVariables }}
|
||||
workDir: '/home/libgit2/build'
|
||||
containerCommand: '/home/libgit2/source/azure-pipelines/build.sh'
|
||||
detached: false
|
||||
- task: docker@0
|
||||
displayName: Test
|
||||
inputs:
|
||||
action: 'Run an image'
|
||||
imageName: libgit2/${{ parameters.docker.image }}
|
||||
volumes: |
|
||||
$(Build.SourcesDirectory):/home/libgit2/source
|
||||
$(Build.BinariesDirectory):/home/libgit2/build
|
||||
envVars: ${{ parameters.environmentVariables }}
|
||||
workDir: '/home/libgit2/build'
|
||||
containerCommand: '/home/libgit2/source/azure-pipelines/test.sh'
|
||||
detached: false
|
||||
- task: publishtestresults@2
|
||||
displayName: Publish Test Results
|
||||
condition: succeededOrFailed()
|
||||
inputs:
|
||||
testResultsFiles: 'results_*.xml'
|
||||
searchFolder: '$(Build.BinariesDirectory)'
|
||||
mergeTestResults: true
|
||||
@@ -1,42 +0,0 @@
|
||||
ARG BASE
|
||||
FROM $BASE AS apt
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
clang \
|
||||
cmake \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
libcurl4-openssl-dev \
|
||||
libpcre3-dev \
|
||||
libssh2-1-dev \
|
||||
libssl-dev \
|
||||
libz-dev \
|
||||
ninja-build \
|
||||
openjdk-8-jre-headless \
|
||||
openssh-server \
|
||||
openssl \
|
||||
pkgconf \
|
||||
python \
|
||||
sudo \
|
||||
valgrind \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM apt AS mbedtls
|
||||
RUN cd /tmp && \
|
||||
curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
|
||||
tar -xz && \
|
||||
cd mbedtls-2.16.2 && \
|
||||
scripts/config.pl set MBEDTLS_MD4_C 1 && \
|
||||
CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
|
||||
ninja install && \
|
||||
cd .. && \
|
||||
rm -rf mbedtls-2.16.2
|
||||
|
||||
FROM mbedtls AS configure
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod a+x /usr/local/bin/entrypoint.sh
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
@@ -1,3 +0,0 @@
|
||||
FROM ubuntu:bionic
|
||||
RUN apt update && apt install -y cmake pkg-config ruby ruby-dev llvm libclang-dev libssl-dev python-pygments
|
||||
RUN gem install docurium
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash -e
|
||||
useradd --shell /bin/bash libgit2
|
||||
chown --recursive libgit2:libgit2 /home/libgit2
|
||||
exec sudo --preserve-env --set-home --user=libgit2 "$@"
|
||||
@@ -1,67 +0,0 @@
|
||||
ARG BASE
|
||||
FROM $BASE AS apt
|
||||
RUN apt-get update && \
|
||||
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
|
||||
bzip2 \
|
||||
clang \
|
||||
cmake \
|
||||
curl \
|
||||
gcc \
|
||||
git \
|
||||
krb5-user \
|
||||
libcurl4-gnutls-dev \
|
||||
libgcrypt20-dev \
|
||||
libkrb5-dev \
|
||||
libpcre3-dev \
|
||||
libssl-dev \
|
||||
libz-dev \
|
||||
make \
|
||||
ninja-build \
|
||||
openjdk-8-jre-headless \
|
||||
openssh-server \
|
||||
openssl \
|
||||
pkgconf \
|
||||
python \
|
||||
sudo \
|
||||
valgrind \
|
||||
&& \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
FROM apt AS mbedtls
|
||||
RUN cd /tmp && \
|
||||
curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
|
||||
tar -xz && \
|
||||
cd mbedtls-2.16.2 && \
|
||||
scripts/config.pl set MBEDTLS_MD4_C 1 && \
|
||||
CFLAGS=-fPIC cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=OFF -DUSE_STATIC_MBEDTLS_LIBRARY=ON . && \
|
||||
ninja install && \
|
||||
cd .. && \
|
||||
rm -rf mbedtls-2.16.2
|
||||
|
||||
FROM mbedtls AS libssh2
|
||||
RUN cd /tmp && \
|
||||
curl --insecure --location --silent --show-error https://www.libssh2.org/download/libssh2-1.8.2.tar.gz | \
|
||||
tar -xz && \
|
||||
cd libssh2-1.8.2 && \
|
||||
CFLAGS=-fPIC cmake -G Ninja -DBUILD_SHARED_LIBS=ON -DCRYPTO_BACKEND=Libgcrypt . && \
|
||||
ninja install && \
|
||||
cd .. && \
|
||||
rm -rf libssh2-1.8.2
|
||||
|
||||
FROM libssh2 AS valgrind
|
||||
RUN cd /tmp && \
|
||||
curl --insecure --location --silent --show-error https://sourceware.org/pub/valgrind/valgrind-3.15.0.tar.bz2 | \
|
||||
tar -xj && \
|
||||
cd valgrind-3.15.0 && \
|
||||
./configure && \
|
||||
make && \
|
||||
make install && \
|
||||
cd .. && \
|
||||
rm -rf valgrind-3.15.0
|
||||
|
||||
FROM valgrind AS configure
|
||||
COPY entrypoint.sh /usr/local/bin/entrypoint.sh
|
||||
RUN chmod a+x /usr/local/bin/entrypoint.sh
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/entrypoint.sh"]
|
||||
@@ -1,219 +0,0 @@
|
||||
resources:
|
||||
- repo: self
|
||||
|
||||
jobs:
|
||||
- job: linux_amd64_xenial_gcc_openssl
|
||||
displayName: 'Linux (amd64; Xenial; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_xenial_gcc_mbedtls
|
||||
displayName: 'Linux (amd64; Xenial; GCC; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_xenial_clang_openssl
|
||||
displayName: 'Linux (amd64; Xenial; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_amd64_xenial_clang_mbedtls
|
||||
displayName: 'Linux (amd64; Xenial; Clang; mbedTLS)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
docker:
|
||||
image: xenial
|
||||
base: ubuntu:xenial
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: macos
|
||||
displayName: 'macOS (amd64; 10.15)'
|
||||
pool:
|
||||
vmImage: 'macOS-10.15'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)/azure-pipelines/setup-osx.sh'
|
||||
displayName: Setup
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
TMPDIR: $(Agent.TempDirectory)
|
||||
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=leaks -DUSE_GSSAPI=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_vs_amd64
|
||||
displayName: 'Windows (amd64; Visual Studio)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
CMAKE_OPTIONS: -A x64 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_vs_x86
|
||||
displayName: 'Windows (x86; Visual Studio)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
CMAKE_GENERATOR: Visual Studio 15 2017
|
||||
CMAKE_OPTIONS: -A Win32 -DMSVC_CRTDBG=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_mingw_amd64
|
||||
displayName: 'Windows (amd64; MinGW)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
|
||||
displayName: Setup
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: amd64
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
BUILD_PATH: $(Agent.TempDirectory)\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
CMAKE_GENERATOR: MinGW Makefiles
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: windows_mingw_x86
|
||||
displayName: 'Windows (x86; MinGW)'
|
||||
pool:
|
||||
vmImage: 'vs2017-win2016'
|
||||
steps:
|
||||
- bash: . '$(Build.SourcesDirectory)\azure-pipelines\setup-mingw.sh'
|
||||
displayName: Setup
|
||||
workingDirectory: '$(Build.BinariesDirectory)'
|
||||
env:
|
||||
TEMP: $(Agent.TempDirectory)
|
||||
ARCH: x86
|
||||
- template: bash.yml
|
||||
parameters:
|
||||
environmentVariables:
|
||||
BUILD_PATH: $(Agent.TempDirectory)\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
CMAKE_GENERATOR: MinGW Makefiles
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
|
||||
- job: linux_x86_bionic_gcc_openssl
|
||||
displayName: 'Linux (x86; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
docker:
|
||||
image: bionic
|
||||
base: multiarch/ubuntu-core:x86-bionic
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_x86_bionic_clang_openssl
|
||||
displayName: 'Linux (x86; Bionic; Clang; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
docker:
|
||||
image: bionic
|
||||
base: multiarch/ubuntu-core:x86-bionic
|
||||
environmentVariables: |
|
||||
CC=clang
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind
|
||||
RUN_INVASIVE_TESTS=true
|
||||
|
||||
- job: linux_arm32_bionic_gcc_openssl
|
||||
displayName: 'Linux (arm32; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
docker:
|
||||
image: bionic
|
||||
base: multiarch/ubuntu-core:armhf-bionic
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS=true
|
||||
SKIP_PROXY_TESTS=true
|
||||
|
||||
- job: linux_arm64_bionic_gcc_openssl
|
||||
displayName: 'Linux (arm64; Bionic; GCC; OpenSSL)'
|
||||
pool:
|
||||
vmImage: 'ubuntu-18.04'
|
||||
steps:
|
||||
- template: docker.yml
|
||||
parameters:
|
||||
qemu: 'true'
|
||||
docker:
|
||||
image: bionic
|
||||
base: multiarch/ubuntu-core:arm64-bionic
|
||||
environmentVariables: |
|
||||
CC=gcc
|
||||
CMAKE_GENERATOR=Ninja
|
||||
CMAKE_OPTIONS=-DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON
|
||||
RUN_INVASIVE_TESTS=true
|
||||
SKIP_PROXY_TESTS=true
|
||||
@@ -1,15 +0,0 @@
|
||||
#!/bin/sh -e
|
||||
|
||||
echo "##############################################################################"
|
||||
echo "## Downloading mingw"
|
||||
echo "##############################################################################"
|
||||
|
||||
case "$ARCH" in
|
||||
amd64)
|
||||
MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-x86_64-8.1.0-release-win32-seh-rt_v6-rev0.zip";;
|
||||
x86)
|
||||
MINGW_URI="https://bintray.com/libgit2/build-dependencies/download_file?file_path=mingw-w64-i686-8.1.0-release-win32-sjlj-rt_v6-rev0.zip";;
|
||||
esac
|
||||
|
||||
curl -s -L "$MINGW_URI" -o "$TEMP"/mingw-"$ARCH".zip
|
||||
unzip -q "$TEMP"/mingw-"$ARCH".zip -d "$TEMP"
|
||||
@@ -1,8 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
|
||||
brew update
|
||||
brew install pkgconfig zlib curl openssl libssh2 ninja
|
||||
|
||||
ln -s /Applications/Xcode.app/Contents/Developer/usr/lib/libLeaksAtExit.dylib /usr/local/lib
|
||||
@@ -1,325 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
set -e
|
||||
|
||||
if [ -n "$SKIP_TESTS" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Windows doesn't run the NTLM tests properly (yet)
|
||||
if [[ "$(uname -s)" == MINGW* ]]; then
|
||||
SKIP_NTLM_TESTS=1
|
||||
fi
|
||||
|
||||
SOURCE_DIR=${SOURCE_DIR:-$( cd "$( dirname "${BASH_SOURCE[0]}" )" && dirname $( pwd ) )}
|
||||
BUILD_DIR=$(pwd)
|
||||
TMPDIR=${TMPDIR:-/tmp}
|
||||
USER=${USER:-$(whoami)}
|
||||
|
||||
SUCCESS=1
|
||||
|
||||
cleanup() {
|
||||
echo "Cleaning up..."
|
||||
|
||||
if [ ! -z "$GITDAEMON_PID" ]; then
|
||||
echo "Stopping git daemon..."
|
||||
kill $GITDAEMON_PID
|
||||
fi
|
||||
|
||||
if [ ! -z "$SSHD_DIR" -a -f "${SSHD_DIR}/pid" ]; then
|
||||
echo "Stopping SSH..."
|
||||
kill $(cat "${SSHD_DIR}/pid")
|
||||
fi
|
||||
|
||||
echo "Done."
|
||||
}
|
||||
|
||||
run_test() {
|
||||
if [[ "$GITTEST_FLAKY_RETRY" > 0 ]]; then
|
||||
ATTEMPTS_REMAIN=$GITTEST_FLAKY_RETRY
|
||||
else
|
||||
ATTEMPTS_REMAIN=1
|
||||
fi
|
||||
|
||||
FAILED=0
|
||||
while [[ "$ATTEMPTS_REMAIN" > 0 ]]; do
|
||||
if [ "$FAILED" -eq 1 ]; then
|
||||
echo ""
|
||||
echo "Re-running flaky ${1} tests..."
|
||||
echo ""
|
||||
fi
|
||||
|
||||
RETURN_CODE=0
|
||||
|
||||
CLAR_SUMMARY="${BUILD_DIR}/results_${1}.xml" ctest -V -R "^${1}$" || RETURN_CODE=$? && true
|
||||
|
||||
if [ "$RETURN_CODE" -eq 0 ]; then
|
||||
FAILED=0
|
||||
break
|
||||
fi
|
||||
|
||||
echo "Test exited with code: $RETURN_CODE"
|
||||
ATTEMPTS_REMAIN="$(($ATTEMPTS_REMAIN-1))"
|
||||
FAILED=1
|
||||
done
|
||||
|
||||
if [ "$FAILED" -ne 0 ]; then
|
||||
SUCCESS=0
|
||||
fi
|
||||
}
|
||||
|
||||
# Configure the test environment; run them early so that we're certain
|
||||
# that they're started by the time we need them.
|
||||
|
||||
echo "##############################################################################"
|
||||
echo "## Configuring test environment"
|
||||
echo "##############################################################################"
|
||||
|
||||
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
|
||||
echo "Starting git daemon..."
|
||||
GITDAEMON_DIR=`mktemp -d ${TMPDIR}/gitdaemon.XXXXXXXX`
|
||||
git init --bare "${GITDAEMON_DIR}/test.git"
|
||||
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
|
||||
GITDAEMON_PID=$!
|
||||
disown $GITDAEMON_PID
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
curl --location --silent --show-error https://github.com/ethomson/poxyproxy/releases/download/v0.7.0/poxyproxy-0.7.0.jar >poxyproxy.jar
|
||||
|
||||
echo ""
|
||||
echo "Starting HTTP proxy (Basic)..."
|
||||
java -jar poxyproxy.jar --address 127.0.0.1 --port 8080 --credentials foo:bar --auth-type basic --quiet &
|
||||
|
||||
echo ""
|
||||
echo "Starting HTTP proxy (NTLM)..."
|
||||
java -jar poxyproxy.jar --address 127.0.0.1 --port 8090 --credentials foo:bar --auth-type ntlm --quiet &
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_NTLM_TESTS" ]; then
|
||||
curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.4.0/poxygit-0.4.0.jar >poxygit.jar
|
||||
|
||||
echo ""
|
||||
echo "Starting HTTP server..."
|
||||
NTLM_DIR=`mktemp -d ${TMPDIR}/ntlm.XXXXXXXX`
|
||||
git init --bare "${NTLM_DIR}/test.git"
|
||||
java -jar poxygit.jar --address 127.0.0.1 --port 9000 --credentials foo:baz --quiet "${NTLM_DIR}" &
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_SSH_TESTS" ]; then
|
||||
echo "Starting ssh daemon..."
|
||||
HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
|
||||
SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
|
||||
git init --bare "${SSHD_DIR}/test.git"
|
||||
cat >"${SSHD_DIR}/sshd_config" <<-EOF
|
||||
Port 2222
|
||||
ListenAddress 0.0.0.0
|
||||
Protocol 2
|
||||
HostKey ${SSHD_DIR}/id_rsa
|
||||
PidFile ${SSHD_DIR}/pid
|
||||
AuthorizedKeysFile ${HOME}/.ssh/authorized_keys
|
||||
LogLevel DEBUG
|
||||
RSAAuthentication yes
|
||||
PasswordAuthentication yes
|
||||
PubkeyAuthentication yes
|
||||
ChallengeResponseAuthentication no
|
||||
StrictModes no
|
||||
# Required here as sshd will simply close connection otherwise
|
||||
UsePAM no
|
||||
EOF
|
||||
ssh-keygen -t rsa -f "${SSHD_DIR}/id_rsa" -N "" -q
|
||||
/usr/sbin/sshd -f "${SSHD_DIR}/sshd_config" -E "${SSHD_DIR}/log"
|
||||
|
||||
# Set up keys
|
||||
mkdir "${HOME}/.ssh"
|
||||
ssh-keygen -t rsa -f "${HOME}/.ssh/id_rsa" -N "" -q
|
||||
cat "${HOME}/.ssh/id_rsa.pub" >>"${HOME}/.ssh/authorized_keys"
|
||||
while read algorithm key comment; do
|
||||
echo "[localhost]:2222 $algorithm $key" >>"${HOME}/.ssh/known_hosts"
|
||||
done <"${SSHD_DIR}/id_rsa.pub"
|
||||
|
||||
# Get the fingerprint for localhost and remove the colons so we can
|
||||
# parse it as a hex number. Older versions have a different output
|
||||
# format.
|
||||
if [[ $(ssh -V 2>&1) == OpenSSH_6* ]]; then
|
||||
SSH_FINGERPRINT=$(ssh-keygen -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 2 | tr -d ':')
|
||||
else
|
||||
SSH_FINGERPRINT=$(ssh-keygen -E md5 -F '[localhost]:2222' -f "${HOME}/.ssh/known_hosts" -l | tail -n 1 | cut -d ' ' -f 3 | cut -d : -f2- | tr -d :)
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the tests that do not require network connectivity.
|
||||
|
||||
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running (offline) tests"
|
||||
echo "##############################################################################"
|
||||
|
||||
run_test offline
|
||||
fi
|
||||
|
||||
if [ -n "$RUN_INVASIVE_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running invasive tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_INVASIVE_FS_SIZE=1
|
||||
export GITTEST_INVASIVE_MEMORY=1
|
||||
export GITTEST_INVASIVE_SPEED=1
|
||||
run_test invasive
|
||||
unset GITTEST_INVASIVE_FS_SIZE
|
||||
unset GITTEST_INVASIVE_MEMORY
|
||||
unset GITTEST_INVASIVE_SPEED
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_ONLINE_TESTS" ]; then
|
||||
# Run the various online tests. The "online" test suite only includes the
|
||||
# default online tests that do not require additional configuration. The
|
||||
# "proxy" and "ssh" test suites require further setup.
|
||||
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running (online) tests"
|
||||
echo "##############################################################################"
|
||||
|
||||
export GITTEST_FLAKY_RETRY=5
|
||||
run_test online
|
||||
unset GITTEST_FLAKY_RETRY
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_GITDAEMON_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running gitdaemon tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="git://localhost/test.git"
|
||||
run_test gitdaemon
|
||||
unset GITTEST_REMOTE_URL
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running proxy tests (Basic authentication)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_PROXY_HOST="localhost:8080"
|
||||
export GITTEST_REMOTE_PROXY_USER="foo"
|
||||
export GITTEST_REMOTE_PROXY_PASS="bar"
|
||||
run_test proxy
|
||||
unset GITTEST_REMOTE_PROXY_HOST
|
||||
unset GITTEST_REMOTE_PROXY_USER
|
||||
unset GITTEST_REMOTE_PROXY_PASS
|
||||
|
||||
echo ""
|
||||
echo "Running proxy tests (NTLM authentication)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_PROXY_HOST="localhost:8090"
|
||||
export GITTEST_REMOTE_PROXY_USER="foo"
|
||||
export GITTEST_REMOTE_PROXY_PASS="bar"
|
||||
export GITTEST_FLAKY_RETRY=5
|
||||
run_test proxy
|
||||
unset GITTEST_FLAKY_RETRY
|
||||
unset GITTEST_REMOTE_PROXY_HOST
|
||||
unset GITTEST_REMOTE_PROXY_USER
|
||||
unset GITTEST_REMOTE_PROXY_PASS
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_NTLM_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running NTLM tests (IIS emulation)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="http://localhost:9000/ntlm/test.git"
|
||||
export GITTEST_REMOTE_USER="foo"
|
||||
export GITTEST_REMOTE_PASS="baz"
|
||||
run_test auth_clone_and_push
|
||||
unset GITTEST_REMOTE_URL
|
||||
unset GITTEST_REMOTE_USER
|
||||
unset GITTEST_REMOTE_PASS
|
||||
|
||||
echo ""
|
||||
echo "Running NTLM tests (Apache emulation)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="http://localhost:9000/broken-ntlm/test.git"
|
||||
export GITTEST_REMOTE_USER="foo"
|
||||
export GITTEST_REMOTE_PASS="baz"
|
||||
run_test auth_clone_and_push
|
||||
unset GITTEST_REMOTE_URL
|
||||
unset GITTEST_REMOTE_USER
|
||||
unset GITTEST_REMOTE_PASS
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
|
||||
echo ""
|
||||
echo "Running SPNEGO tests"
|
||||
echo ""
|
||||
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
KINIT_FLAGS="--password-file=STDIN"
|
||||
fi
|
||||
|
||||
echo $GITTEST_NEGOTIATE_PASSWORD | kinit $KINIT_FLAGS test@LIBGIT2.ORG
|
||||
klist -5f
|
||||
|
||||
export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
|
||||
export GITTEST_REMOTE_DEFAULT="true"
|
||||
run_test auth_clone
|
||||
unset GITTEST_REMOTE_URL
|
||||
unset GITTEST_REMOTE_DEFAULT
|
||||
|
||||
echo ""
|
||||
echo "Running SPNEGO tests (expect/continue)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="https://test.libgit2.org/kerberos/empty.git"
|
||||
export GITTEST_REMOTE_DEFAULT="true"
|
||||
export GITTEST_REMOTE_EXPECTCONTINUE="true"
|
||||
run_test auth_clone
|
||||
unset GITTEST_REMOTE_URL
|
||||
unset GITTEST_REMOTE_DEFAULT
|
||||
unset GITTEST_REMOTE_EXPECTCONTINUE
|
||||
|
||||
kdestroy -A
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_SSH_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Running ssh tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
|
||||
export GITTEST_REMOTE_USER=$USER
|
||||
export GITTEST_REMOTE_SSH_KEY="${HOME}/.ssh/id_rsa"
|
||||
export GITTEST_REMOTE_SSH_PUBKEY="${HOME}/.ssh/id_rsa.pub"
|
||||
export GITTEST_REMOTE_SSH_PASSPHRASE=""
|
||||
export GITTEST_REMOTE_SSH_FINGERPRINT="${SSH_FINGERPRINT}"
|
||||
run_test ssh
|
||||
unset GITTEST_REMOTE_URL
|
||||
unset GITTEST_REMOTE_USER
|
||||
unset GITTEST_REMOTE_SSH_KEY
|
||||
unset GITTEST_REMOTE_SSH_PUBKEY
|
||||
unset GITTEST_REMOTE_SSH_PASSPHRASE
|
||||
unset GITTEST_REMOTE_SSH_FINGERPRINT
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_FUZZERS" ]; then
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running fuzzers"
|
||||
echo "##############################################################################"
|
||||
|
||||
ctest -V -R 'fuzzer'
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
if [ "$SUCCESS" -ne 1 ]; then
|
||||
echo "Some tests failed."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Success."
|
||||
exit 0
|
||||
@@ -1,30 +0,0 @@
|
||||
# - Append compiler flag to CMAKE_C_FLAGS if compiler supports it
|
||||
# ADD_C_FLAG_IF_SUPPORTED(<flag>)
|
||||
# <flag> - the compiler flag to test
|
||||
# This internally calls the CHECK_C_COMPILER_FLAG macro.
|
||||
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
|
||||
MACRO(ADD_C_FLAG _FLAG)
|
||||
STRING(TOUPPER ${_FLAG} UPCASE)
|
||||
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
||||
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
||||
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
|
||||
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Required flag ${_FLAG} is not supported")
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(ADD_C_FLAG_IF_SUPPORTED _FLAG)
|
||||
STRING(TOUPPER ${_FLAG} UPCASE)
|
||||
STRING(REGEX REPLACE "[-=]" "_" UPCASE_PRETTY ${UPCASE})
|
||||
STRING(REGEX REPLACE "^_+" "" UPCASE_PRETTY ${UPCASE_PRETTY})
|
||||
CHECK_C_COMPILER_FLAG(${_FLAG} IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
|
||||
IF(IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
||||
ENDIF()
|
||||
ENDMACRO()
|
||||
@@ -1,29 +0,0 @@
|
||||
@CHECK_PROTOTYPE_DEFINITION_HEADER@
|
||||
|
||||
static void cmakeRequireSymbol(int dummy, ...) {
|
||||
(void) dummy;
|
||||
}
|
||||
|
||||
static void checkSymbol(void) {
|
||||
#ifndef @CHECK_PROTOTYPE_DEFINITION_SYMBOL@
|
||||
cmakeRequireSymbol(0, &@CHECK_PROTOTYPE_DEFINITION_SYMBOL@);
|
||||
#endif
|
||||
}
|
||||
|
||||
@CHECK_PROTOTYPE_DEFINITION_PROTO@ {
|
||||
return @CHECK_PROTOTYPE_DEFINITION_RETURN@;
|
||||
}
|
||||
|
||||
#ifdef __CLASSIC_C__
|
||||
int main() {
|
||||
int ac;
|
||||
char*av[];
|
||||
#else
|
||||
int main(int ac, char *av[]) {
|
||||
#endif
|
||||
checkSymbol();
|
||||
if (ac > 1000) {
|
||||
return *av[0];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -1,96 +0,0 @@
|
||||
# - Check if the protoype we expect is correct.
|
||||
# check_prototype_definition(FUNCTION PROTOTYPE RETURN HEADER VARIABLE)
|
||||
# FUNCTION - The name of the function (used to check if prototype exists)
|
||||
# PROTOTYPE- The prototype to check.
|
||||
# RETURN - The return value of the function.
|
||||
# HEADER - The header files required.
|
||||
# VARIABLE - The variable to store the result.
|
||||
# Example:
|
||||
# check_prototype_definition(getpwent_r
|
||||
# "struct passwd *getpwent_r(struct passwd *src, char *buf, int buflen)"
|
||||
# "NULL"
|
||||
# "unistd.h;pwd.h"
|
||||
# SOLARIS_GETPWENT_R)
|
||||
# The following variables may be set before calling this macro to
|
||||
# modify the way the check is run:
|
||||
#
|
||||
# CMAKE_REQUIRED_FLAGS = string of compile command line flags
|
||||
# CMAKE_REQUIRED_DEFINITIONS = list of macros to define (-DFOO=bar)
|
||||
# CMAKE_REQUIRED_INCLUDES = list of include directories
|
||||
# CMAKE_REQUIRED_LIBRARIES = list of libraries to link
|
||||
|
||||
#=============================================================================
|
||||
# Copyright 2005-2009 Kitware, Inc.
|
||||
# Copyright 2010-2011 Andreas Schneider <asn@cryptomilk.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
# (To distribute this file outside of CMake, substitute the full
|
||||
# License text for the above reference.)
|
||||
#
|
||||
|
||||
get_filename_component(__check_proto_def_dir "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
function(CHECK_PROTOTYPE_DEFINITION _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIABLE)
|
||||
|
||||
if ("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
|
||||
set(CHECK_PROTOTYPE_DEFINITION_CONTENT "/* */\n")
|
||||
|
||||
set(CHECK_PROTOTYPE_DEFINITION_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||
if (CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_PROTOTYPE_DEFINITION_LIBS
|
||||
"-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}")
|
||||
else(CMAKE_REQUIRED_LIBRARIES)
|
||||
set(CHECK_PROTOTYPE_DEFINITION_LIBS)
|
||||
endif(CMAKE_REQUIRED_LIBRARIES)
|
||||
if (CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_SYMBOL_EXISTS_INCLUDES
|
||||
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}")
|
||||
else(CMAKE_REQUIRED_INCLUDES)
|
||||
set(CMAKE_SYMBOL_EXISTS_INCLUDES)
|
||||
endif(CMAKE_REQUIRED_INCLUDES)
|
||||
|
||||
foreach(_FILE ${_HEADER})
|
||||
set(CHECK_PROTOTYPE_DEFINITION_HEADER
|
||||
"${CHECK_PROTOTYPE_DEFINITION_HEADER}#include <${_FILE}>\n")
|
||||
endforeach(_FILE)
|
||||
|
||||
set(CHECK_PROTOTYPE_DEFINITION_SYMBOL ${_FUNCTION})
|
||||
set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE})
|
||||
set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN})
|
||||
|
||||
configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in"
|
||||
"${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY)
|
||||
|
||||
file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE)
|
||||
|
||||
try_compile(${_VARIABLE}
|
||||
${CMAKE_BINARY_DIR}
|
||||
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c
|
||||
COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
|
||||
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CHECK_PROTOTYPE_DEFINITION_FLAGS}
|
||||
"${CHECK_PROTOTYPE_DEFINITION_LIBS}"
|
||||
"${CMAKE_SYMBOL_EXISTS_INCLUDES}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
if (${_VARIABLE})
|
||||
set(${_VARIABLE} 1 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
|
||||
message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - True")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
|
||||
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} passed with the following output:\n"
|
||||
"${OUTPUT}\n\n")
|
||||
else (${_VARIABLE})
|
||||
message(STATUS "Checking prototype ${_FUNCTION} for ${_VARIABLE} - False")
|
||||
set(${_VARIABLE} 0 CACHE INTERNAL "Have correct prototype for ${_FUNCTION}")
|
||||
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
|
||||
"Determining if the prototype ${_FUNCTION} exists for ${_VARIABLE} failed with the following output:\n"
|
||||
"${OUTPUT}\n\n${_SOURCE}\n\n")
|
||||
endif (${_VARIABLE})
|
||||
endif("${_VARIABLE}" MATCHES "^${_VARIABLE}$")
|
||||
|
||||
endfunction(CHECK_PROTOTYPE_DEFINITION)
|
||||
@@ -1,15 +0,0 @@
|
||||
MACRO(ENABLE_WARNINGS flag)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
|
||||
ENDMACRO()
|
||||
|
||||
MACRO(DISABLE_WARNINGS flag)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Wno-${flag})
|
||||
ENDMACRO()
|
||||
|
||||
IF(ENABLE_WERROR)
|
||||
IF(MSVC)
|
||||
ADD_COMPILE_OPTIONS(-WX)
|
||||
ELSE()
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Werror)
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
@@ -1,26 +0,0 @@
|
||||
# Find CoreFoundation.framework
|
||||
# This will define :
|
||||
#
|
||||
# COREFOUNDATION_FOUND
|
||||
# COREFOUNDATION_LIBRARIES
|
||||
# COREFOUNDATION_LDFLAGS
|
||||
#
|
||||
|
||||
FIND_PATH(COREFOUNDATION_INCLUDE_DIR NAMES CoreFoundation.h)
|
||||
FIND_LIBRARY(COREFOUNDATION_LIBRARIES NAMES CoreFoundation)
|
||||
IF (COREFOUNDATION_INCLUDE_DIR AND COREFOUNDATION_LIBRARIES)
|
||||
IF (NOT CoreFoundation_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found CoreFoundation ${COREFOUNDATION_LIBRARIES}")
|
||||
ENDIF()
|
||||
SET(COREFOUNDATION_FOUND TRUE)
|
||||
SET(COREFOUNDATION_LDFLAGS "-framework CoreFoundation")
|
||||
ENDIF ()
|
||||
|
||||
IF (CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
|
||||
MESSAGE(FATAL_ERROR "CoreFoundation not found")
|
||||
ENDIF()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
COREFOUNDATION_INCLUDE_DIR
|
||||
COREFOUNDATION_LIBRARIES
|
||||
)
|
||||
@@ -1,324 +0,0 @@
|
||||
# - Try to find GSSAPI
|
||||
# Once done this will define
|
||||
#
|
||||
# KRB5_CONFIG - Path to krb5-config
|
||||
# GSSAPI_ROOT_DIR - Set this variable to the root installation of GSSAPI
|
||||
#
|
||||
# Read-Only variables:
|
||||
# GSSAPI_FLAVOR_MIT - set to TURE if MIT Kerberos has been found
|
||||
# GSSAPI_FLAVOR_HEIMDAL - set to TRUE if Heimdal Kerberos has been found
|
||||
# GSSAPI_FOUND - system has GSSAPI
|
||||
# GSSAPI_INCLUDE_DIR - the GSSAPI include directory
|
||||
# GSSAPI_LIBRARIES - Link these to use GSSAPI
|
||||
# GSSAPI_DEFINITIONS - Compiler switches required for using GSSAPI
|
||||
#
|
||||
#=============================================================================
|
||||
# Copyright (c) 2013 Andreas Schneider <asn@cryptomilk.org>
|
||||
#
|
||||
# Distributed under the OSI-approved BSD License (the "License");
|
||||
# see accompanying file Copyright.txt for details.
|
||||
#
|
||||
# This software is distributed WITHOUT ANY WARRANTY; without even the
|
||||
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||
# See the License for more information.
|
||||
#=============================================================================
|
||||
#
|
||||
|
||||
find_path(GSSAPI_ROOT_DIR
|
||||
NAMES
|
||||
include/gssapi.h
|
||||
include/gssapi/gssapi.h
|
||||
HINTS
|
||||
${_GSSAPI_ROOT_HINTS}
|
||||
PATHS
|
||||
${_GSSAPI_ROOT_PATHS}
|
||||
)
|
||||
mark_as_advanced(GSSAPI_ROOT_DIR)
|
||||
|
||||
if (UNIX)
|
||||
find_program(KRB5_CONFIG
|
||||
NAMES
|
||||
krb5-config
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/bin
|
||||
/opt/local/bin)
|
||||
mark_as_advanced(KRB5_CONFIG)
|
||||
|
||||
if (KRB5_CONFIG)
|
||||
# Check if we have MIT KRB5
|
||||
execute_process(
|
||||
COMMAND
|
||||
${KRB5_CONFIG} --vendor
|
||||
RESULT_VARIABLE
|
||||
_GSSAPI_VENDOR_RESULT
|
||||
OUTPUT_VARIABLE
|
||||
_GSSAPI_VENDOR_STRING)
|
||||
|
||||
if (_GSSAPI_VENDOR_STRING MATCHES ".*Massachusetts.*")
|
||||
set(GSSAPI_FLAVOR_MIT TRUE)
|
||||
else()
|
||||
execute_process(
|
||||
COMMAND
|
||||
${KRB5_CONFIG} --libs gssapi
|
||||
RESULT_VARIABLE
|
||||
_GSSAPI_LIBS_RESULT
|
||||
OUTPUT_VARIABLE
|
||||
_GSSAPI_LIBS_STRING)
|
||||
|
||||
if (_GSSAPI_LIBS_STRING MATCHES ".*roken.*")
|
||||
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Get the include dir
|
||||
execute_process(
|
||||
COMMAND
|
||||
${KRB5_CONFIG} --cflags gssapi
|
||||
RESULT_VARIABLE
|
||||
_GSSAPI_INCLUDE_RESULT
|
||||
OUTPUT_VARIABLE
|
||||
_GSSAPI_INCLUDE_STRING)
|
||||
string(REGEX REPLACE "(\r?\n)+$" "" _GSSAPI_INCLUDE_STRING "${_GSSAPI_INCLUDE_STRING}")
|
||||
string(REGEX REPLACE " *-I" "" _GSSAPI_INCLUDEDIR "${_GSSAPI_INCLUDE_STRING}")
|
||||
endif()
|
||||
|
||||
if (NOT GSSAPI_FLAVOR_MIT AND NOT GSSAPI_FLAVOR_HEIMDAL)
|
||||
# Check for HEIMDAL
|
||||
find_package(PkgConfig)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules(_GSSAPI heimdal-gssapi)
|
||||
endif (PKG_CONFIG_FOUND)
|
||||
|
||||
if (_GSSAPI_FOUND)
|
||||
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
|
||||
else()
|
||||
find_path(_GSSAPI_ROKEN
|
||||
NAMES
|
||||
roken.h
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/include
|
||||
${_GSSAPI_INCLUDEDIR})
|
||||
if (_GSSAPI_ROKEN)
|
||||
set(GSSAPI_FLAVOR_HEIMDAL TRUE)
|
||||
endif()
|
||||
endif ()
|
||||
endif()
|
||||
endif (UNIX)
|
||||
|
||||
find_path(GSSAPI_INCLUDE_DIR
|
||||
NAMES
|
||||
gssapi.h
|
||||
gssapi/gssapi.h
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/include
|
||||
${_GSSAPI_INCLUDEDIR}
|
||||
)
|
||||
|
||||
if (GSSAPI_FLAVOR_MIT)
|
||||
find_library(GSSAPI_LIBRARY
|
||||
NAMES
|
||||
gssapi_krb5
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(KRB5_LIBRARY
|
||||
NAMES
|
||||
krb5
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(K5CRYPTO_LIBRARY
|
||||
NAMES
|
||||
k5crypto
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(COM_ERR_LIBRARY
|
||||
NAMES
|
||||
com_err
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
if (GSSAPI_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${GSSAPI_LIBRARY}
|
||||
)
|
||||
endif (GSSAPI_LIBRARY)
|
||||
|
||||
if (KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${KRB5_LIBRARY}
|
||||
)
|
||||
endif (KRB5_LIBRARY)
|
||||
|
||||
if (K5CRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${K5CRYPTO_LIBRARY}
|
||||
)
|
||||
endif (K5CRYPTO_LIBRARY)
|
||||
|
||||
if (COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${COM_ERR_LIBRARY}
|
||||
)
|
||||
endif (COM_ERR_LIBRARY)
|
||||
endif (GSSAPI_FLAVOR_MIT)
|
||||
|
||||
if (GSSAPI_FLAVOR_HEIMDAL)
|
||||
find_library(GSSAPI_LIBRARY
|
||||
NAMES
|
||||
gssapi
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(KRB5_LIBRARY
|
||||
NAMES
|
||||
krb5
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(HCRYPTO_LIBRARY
|
||||
NAMES
|
||||
hcrypto
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(COM_ERR_LIBRARY
|
||||
NAMES
|
||||
com_err
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(HEIMNTLM_LIBRARY
|
||||
NAMES
|
||||
heimntlm
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(HX509_LIBRARY
|
||||
NAMES
|
||||
hx509
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(ASN1_LIBRARY
|
||||
NAMES
|
||||
asn1
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(WIND_LIBRARY
|
||||
NAMES
|
||||
wind
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
find_library(ROKEN_LIBRARY
|
||||
NAMES
|
||||
roken
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
|
||||
if (GSSAPI_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${GSSAPI_LIBRARY}
|
||||
)
|
||||
endif (GSSAPI_LIBRARY)
|
||||
|
||||
if (KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${KRB5_LIBRARY}
|
||||
)
|
||||
endif (KRB5_LIBRARY)
|
||||
|
||||
if (HCRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HCRYPTO_LIBRARY}
|
||||
)
|
||||
endif (HCRYPTO_LIBRARY)
|
||||
|
||||
if (COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${COM_ERR_LIBRARY}
|
||||
)
|
||||
endif (COM_ERR_LIBRARY)
|
||||
|
||||
if (HEIMNTLM_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HEIMNTLM_LIBRARY}
|
||||
)
|
||||
endif (HEIMNTLM_LIBRARY)
|
||||
|
||||
if (HX509_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HX509_LIBRARY}
|
||||
)
|
||||
endif (HX509_LIBRARY)
|
||||
|
||||
if (ASN1_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${ASN1_LIBRARY}
|
||||
)
|
||||
endif (ASN1_LIBRARY)
|
||||
|
||||
if (WIND_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${WIND_LIBRARY}
|
||||
)
|
||||
endif (WIND_LIBRARY)
|
||||
|
||||
if (ROKEN_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${WIND_LIBRARY}
|
||||
)
|
||||
endif (ROKEN_LIBRARY)
|
||||
endif (GSSAPI_FLAVOR_HEIMDAL)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(GSSAPI DEFAULT_MSG GSSAPI_LIBRARIES GSSAPI_INCLUDE_DIR)
|
||||
|
||||
if (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
|
||||
set(GSSAPI_FOUND TRUE)
|
||||
endif (GSSAPI_INCLUDE_DIRS AND GSSAPI_LIBRARIES)
|
||||
|
||||
# show the GSSAPI_INCLUDE_DIRS and GSSAPI_LIBRARIES variables only in the advanced view
|
||||
mark_as_advanced(GSSAPI_INCLUDE_DIRS GSSAPI_LIBRARIES)
|
||||
@@ -1,28 +0,0 @@
|
||||
# Find GSS.framework
|
||||
# This will define :
|
||||
#
|
||||
# GSSFRAMEWORK_FOUND
|
||||
# GSSFRAMEWORK_INCLUDE_DIR
|
||||
# GSSFRAMEWORK_LIBRARIES
|
||||
# GSSFRAMEWORK_LDFLAGS
|
||||
#
|
||||
|
||||
FIND_PATH(GSSFRAMEWORK_INCLUDE_DIR NAMES GSS.h)
|
||||
FIND_LIBRARY(GSSFRAMEWORK_LIBRARIES NAMES GSS)
|
||||
IF (GSSFRAMEWORK_INCLUDE_DIR AND GSSFRAMEWORK_LIBRARIES)
|
||||
IF (NOT CoreFoundation_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found GSS.framework ${GSSFRAMEWORK_LIBRARIES}")
|
||||
ENDIF()
|
||||
SET(GSSFRAMEWORK_FOUND TRUE)
|
||||
SET(GSSFRAMEWORK_LDFLAGS "-framework GSS")
|
||||
ENDIF ()
|
||||
|
||||
IF (GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
|
||||
MESSAGE(FATAL_ERROR "CoreFoundation not found")
|
||||
ENDIF()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
GSSFRAMEWORK_INCLUDE_DIR
|
||||
GSSFRAMEWORK_LIBRARIES
|
||||
GSSFRAMEWORK_LDFLAGS
|
||||
)
|
||||
@@ -1,39 +0,0 @@
|
||||
# - Try to find http-parser
|
||||
#
|
||||
# Defines the following variables:
|
||||
#
|
||||
# HTTP_PARSER_FOUND - system has http-parser
|
||||
# HTTP_PARSER_INCLUDE_DIR - the http-parser include directory
|
||||
# HTTP_PARSER_LIBRARIES - Link these to use http-parser
|
||||
# HTTP_PARSER_VERSION_MAJOR - major version
|
||||
# HTTP_PARSER_VERSION_MINOR - minor version
|
||||
# HTTP_PARSER_VERSION_STRING - the version of http-parser found
|
||||
|
||||
# Find the header and library
|
||||
FIND_PATH(HTTP_PARSER_INCLUDE_DIR NAMES http_parser.h)
|
||||
FIND_LIBRARY(HTTP_PARSER_LIBRARY NAMES http_parser libhttp_parser)
|
||||
|
||||
# Found the header, read version
|
||||
if (HTTP_PARSER_INCLUDE_DIR AND EXISTS "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h")
|
||||
FILE(READ "${HTTP_PARSER_INCLUDE_DIR}/http_parser.h" HTTP_PARSER_H)
|
||||
IF (HTTP_PARSER_H)
|
||||
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MAJOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MAJOR "${HTTP_PARSER_H}")
|
||||
STRING(REGEX REPLACE ".*#define[\t ]+HTTP_PARSER_VERSION_MINOR[\t ]+([0-9]+).*" "\\1" HTTP_PARSER_VERSION_MINOR "${HTTP_PARSER_H}")
|
||||
SET(HTTP_PARSER_VERSION_STRING "${HTTP_PARSER_VERSION_MAJOR}.${HTTP_PARSER_VERSION_MINOR}")
|
||||
ENDIF()
|
||||
UNSET(HTTP_PARSER_H)
|
||||
ENDIF()
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set HTTP_PARSER_FOUND
|
||||
# to TRUE if all listed variables are TRUE
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(HTTP_Parser REQUIRED_VARS HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
|
||||
|
||||
# Hide advanced variables
|
||||
MARK_AS_ADVANCED(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
|
||||
|
||||
# Set standard variables
|
||||
IF (HTTP_PARSER_FOUND)
|
||||
SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
|
||||
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
|
||||
ENDIF()
|
||||
@@ -1,45 +0,0 @@
|
||||
# - Try to find Iconv
|
||||
# Once done this will define
|
||||
#
|
||||
# ICONV_FOUND - system has Iconv
|
||||
# ICONV_INCLUDE_DIR - the Iconv include directory
|
||||
# ICONV_LIBRARIES - Link these to use Iconv
|
||||
#
|
||||
|
||||
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(ICONV_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_PATH(ICONV_INCLUDE_DIR iconv.h)
|
||||
CHECK_FUNCTION_EXISTS(iconv_open libc_has_iconv)
|
||||
FIND_LIBRARY(iconv_lib NAMES iconv libiconv libiconv-2 c)
|
||||
|
||||
IF(ICONV_INCLUDE_DIR AND libc_has_iconv)
|
||||
SET(ICONV_FOUND TRUE)
|
||||
SET(ICONV_LIBRARIES "")
|
||||
IF(NOT ICONV_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Iconv: provided by libc")
|
||||
ENDIF(NOT ICONV_FIND_QUIETLY)
|
||||
ELSEIF(ICONV_INCLUDE_DIR AND iconv_lib)
|
||||
SET(ICONV_FOUND TRUE)
|
||||
# split iconv into -L and -l linker options, so we can
|
||||
# set them for pkg-config
|
||||
GET_FILENAME_COMPONENT(iconv_path ${iconv_lib} PATH)
|
||||
GET_FILENAME_COMPONENT(iconv_name ${iconv_lib} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" iconv_name ${iconv_name})
|
||||
SET(ICONV_LIBRARIES "-L${iconv_path} -l${iconv_name}")
|
||||
|
||||
IF(NOT ICONV_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
|
||||
ENDIF(NOT ICONV_FIND_QUIETLY)
|
||||
ELSE()
|
||||
IF(Iconv_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find Iconv")
|
||||
ENDIF(Iconv_FIND_REQUIRED)
|
||||
ENDIF()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
ICONV_INCLUDE_DIR
|
||||
ICONV_LIBRARIES
|
||||
)
|
||||
@@ -1,38 +0,0 @@
|
||||
# Copyright (C) 2007-2009 LuaDist.
|
||||
# Created by Peter Kapec <kapecp@gmail.com>
|
||||
# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
||||
# For details see the COPYRIGHT file distributed with LuaDist.
|
||||
# Note:
|
||||
# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
||||
# distributed with CMake, because LuaDist defines directories to search for.
|
||||
# Everyone is encouraged to contact the author with improvements. Maybe this file
|
||||
# becomes part of CMake distribution sometimes.
|
||||
|
||||
# - Find pcre
|
||||
# Find the native PCRE headers and libraries.
|
||||
#
|
||||
# PCRE_INCLUDE_DIRS - where to find pcre.h, etc.
|
||||
# PCRE_LIBRARIES - List of libraries when using pcre.
|
||||
# PCRE_FOUND - True if pcre found.
|
||||
|
||||
# Look for the header file.
|
||||
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
|
||||
FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set PCRE_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE DEFAULT_MSG PCRE_LIBRARY PCRE_POSIX_LIBRARY PCRE_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(PCRE_FOUND)
|
||||
SET(PCRE_LIBRARIES ${PCRE_LIBRARY} ${PCRE_POSIX_LIBRARY})
|
||||
SET(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
|
||||
ELSE(PCRE_FOUND)
|
||||
SET(PCRE_LIBRARIES)
|
||||
SET(PCRE_INCLUDE_DIRS)
|
||||
ENDIF(PCRE_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
|
||||
@@ -1,37 +0,0 @@
|
||||
# Copyright (C) 2007-2009 LuaDist.
|
||||
# Created by Peter Kapec <kapecp@gmail.com>
|
||||
# Redistribution and use of this file is allowed according to the terms of the MIT license.
|
||||
# For details see the COPYRIGHT file distributed with LuaDist.
|
||||
# Note:
|
||||
# Searching headers and libraries is very simple and is NOT as powerful as scripts
|
||||
# distributed with CMake, because LuaDist defines directories to search for.
|
||||
# Everyone is encouraged to contact the author with improvements. Maybe this file
|
||||
# becomes part of CMake distribution sometimes.
|
||||
|
||||
# - Find pcre
|
||||
# Find the native PCRE2 headers and libraries.
|
||||
#
|
||||
# PCRE2_INCLUDE_DIRS - where to find pcre.h, etc.
|
||||
# PCRE2_LIBRARIES - List of libraries when using pcre.
|
||||
# PCRE2_FOUND - True if pcre found.
|
||||
|
||||
# Look for the header file.
|
||||
FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
|
||||
|
||||
# Handle the QUIETLY and REQUIRED arguments and set PCRE2_FOUND to TRUE if all listed variables are TRUE.
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PCRE2 DEFAULT_MSG PCRE2_LIBRARY PCRE2_INCLUDE_DIR)
|
||||
|
||||
# Copy the results to the output variables.
|
||||
IF(PCRE2_FOUND)
|
||||
SET(PCRE2_LIBRARIES ${PCRE2_LIBRARY})
|
||||
SET(PCRE2_INCLUDE_DIRS ${PCRE2_INCLUDE_DIR})
|
||||
ELSE(PCRE2_FOUND)
|
||||
SET(PCRE2_LIBRARIES)
|
||||
SET(PCRE2_INCLUDE_DIRS)
|
||||
ENDIF(PCRE2_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
|
||||
@@ -1,28 +0,0 @@
|
||||
INCLUDE(FindPkgConfig)
|
||||
|
||||
# This function will find and set up a pkg-config based module.
|
||||
# If a pc-file was found, it will resolve library paths to
|
||||
# absolute paths. Furthermore, the function will automatically
|
||||
# fall back to use static libraries in case no dynamic libraries
|
||||
# were found.
|
||||
FUNCTION(FIND_PKGLIBRARIES prefix package)
|
||||
PKG_CHECK_MODULES(${prefix} ${package})
|
||||
IF(NOT ${prefix}_FOUND)
|
||||
RETURN()
|
||||
ENDIF()
|
||||
|
||||
FOREACH(LIBRARY ${${prefix}_LIBRARIES})
|
||||
FIND_LIBRARY(${LIBRARY}_RESOLVED ${LIBRARY} PATHS ${${prefix}_LIBRARY_DIRS})
|
||||
IF(${${LIBRARY}_RESOLVED} STREQUAL "${LIBRARY}_RESOLVED-NOTFOUND")
|
||||
MESSAGE(FATAL_ERROR "could not resolve ${LIBRARY}")
|
||||
ENDIF()
|
||||
LIST(APPEND RESOLVED_LIBRARIES ${${LIBRARY}_RESOLVED})
|
||||
ENDFOREACH(LIBRARY)
|
||||
|
||||
SET(${prefix}_FOUND 1 PARENT_SCOPE)
|
||||
SET(${prefix}_LIBRARIES ${RESOLVED_LIBRARIES} PARENT_SCOPE)
|
||||
SET(${prefix}_INCLUDE_DIRS ${${prefix}_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
SET(${prefix}_LDFLAGS ${${prefix}_LDFLAGS} PARENT_SCOPE)
|
||||
|
||||
MESSAGE(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
|
||||
ENDFUNCTION()
|
||||
@@ -1,28 +0,0 @@
|
||||
# Find Security.framework
|
||||
# This will define :
|
||||
#
|
||||
# SECURITY_FOUND
|
||||
# SECURITY_LIBRARIES
|
||||
# SECURITY_LDFLAGS
|
||||
# SECURITY_HAS_SSLCREATECONTEXT
|
||||
#
|
||||
|
||||
FIND_PATH(SECURITY_INCLUDE_DIR NAMES Security/Security.h)
|
||||
FIND_LIBRARY(SECURITY_LIBRARIES NAMES Security)
|
||||
IF (SECURITY_INCLUDE_DIR AND SECURITY_LIBRARIES)
|
||||
IF (NOT Security_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found Security ${SECURITY_LIBRARIES}")
|
||||
ENDIF()
|
||||
SET(SECURITY_FOUND TRUE)
|
||||
SET(SECURITY_LDFLAGS "-framework Security")
|
||||
CHECK_LIBRARY_EXISTS("${SECURITY_LIBRARIES}" SSLCreateContext "Security/SecureTransport.h" SECURITY_HAS_SSLCREATECONTEXT)
|
||||
ENDIF ()
|
||||
|
||||
IF (Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Security not found")
|
||||
ENDIF()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
SECURITY_INCLUDE_DIR
|
||||
SECURITY_LIBRARIES
|
||||
)
|
||||
@@ -1,26 +0,0 @@
|
||||
INCLUDE(FeatureSummary)
|
||||
|
||||
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
|
||||
HAVE_STRUCT_STAT_ST_MTIM LANGUAGE C)
|
||||
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtimespec "sys/types.h;sys/stat.h"
|
||||
HAVE_STRUCT_STAT_ST_MTIMESPEC LANGUAGE C)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtime_nsec sys/stat.h
|
||||
HAVE_STRUCT_STAT_MTIME_NSEC LANGUAGE C)
|
||||
|
||||
IF (HAVE_STRUCT_STAT_ST_MTIM)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtim.tv_nsec sys/stat.h
|
||||
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
|
||||
ELSEIF (HAVE_STRUCT_STAT_ST_MTIMESPEC)
|
||||
CHECK_STRUCT_HAS_MEMBER("struct stat" st_mtimespec.tv_nsec sys/stat.h
|
||||
HAVE_STRUCT_STAT_NSEC LANGUAGE C)
|
||||
ELSE ()
|
||||
SET( HAVE_STRUCT_STAT_NSEC ON )
|
||||
ENDIF()
|
||||
|
||||
IF (HAVE_STRUCT_STAT_NSEC OR WIN32)
|
||||
OPTION( USE_NSEC "Care about sub-second file mtimes and ctimes" ON )
|
||||
ELSE()
|
||||
SET(USE_NSEC OFF)
|
||||
ENDIF()
|
||||
|
||||
ADD_FEATURE_INFO(nanoseconds USE_NSEC "whether to use sub-second file mtimes and ctimes")
|
||||
@@ -1,93 +0,0 @@
|
||||
# - Try to find mbedTLS
|
||||
# Once done this will define
|
||||
#
|
||||
# Read-Only variables
|
||||
# MBEDTLS_FOUND - system has mbedTLS
|
||||
# MBEDTLS_INCLUDE_DIR - the mbedTLS include directory
|
||||
# MBEDTLS_LIBRARY_DIR - the mbedTLS library directory
|
||||
# MBEDTLS_LIBRARIES - Link these to use mbedTLS
|
||||
# MBEDTLS_LIBRARY - path to mbedTLS library
|
||||
# MBEDX509_LIBRARY - path to mbedTLS X.509 library
|
||||
# MBEDCRYPTO_LIBRARY - path to mbedTLS Crypto library
|
||||
#
|
||||
# Hint
|
||||
# MBEDTLS_ROOT_DIR can be pointed to a local mbedTLS installation.
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS
|
||||
${MBEDTLS_ROOT_DIR}
|
||||
ENV MBEDTLS_ROOT_DIR
|
||||
)
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
||||
)
|
||||
|
||||
FIND_PATH(MBEDTLS_INCLUDE_DIR
|
||||
NAMES mbedtls/version.h
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES include
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(MBEDTLS_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
|
||||
FIND_LIBRARY(MBEDTLS_LIBRARY
|
||||
NAMES mbedtls libmbedtls
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDX509_LIBRARY
|
||||
NAMES mbedx509 libmbedx509
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
FIND_LIBRARY(MBEDCRYPTO_LIBRARY
|
||||
NAMES mbedcrypto libmbedcrypto
|
||||
${_MBEDTLS_ROOT_HINTS_AND_PATHS}
|
||||
PATH_SUFFIXES library
|
||||
)
|
||||
|
||||
IF(MBEDTLS_INCLUDE_DIR AND MBEDTLS_LIBRARY AND MBEDX509_LIBRARY AND MBEDCRYPTO_LIBRARY)
|
||||
SET(MBEDTLS_FOUND TRUE)
|
||||
ENDIF()
|
||||
|
||||
IF(MBEDTLS_FOUND)
|
||||
# split mbedTLS into -L and -l linker options, so we can set them for pkg-config
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_DIR ${MBEDTLS_LIBRARY} PATH)
|
||||
GET_FILENAME_COMPONENT(MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY} NAME_WE)
|
||||
GET_FILENAME_COMPONENT(MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY} NAME_WE)
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDTLS_LIBRARY_FILE ${MBEDTLS_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDX509_LIBRARY_FILE ${MBEDX509_LIBRARY_FILE})
|
||||
STRING(REGEX REPLACE "^lib" "" MBEDCRYPTO_LIBRARY_FILE ${MBEDCRYPTO_LIBRARY_FILE})
|
||||
SET(MBEDTLS_LIBRARIES "-L${MBEDTLS_LIBRARY_DIR} -l${MBEDTLS_LIBRARY_FILE} -l${MBEDX509_LIBRARY_FILE} -l${MBEDCRYPTO_LIBRARY_FILE}")
|
||||
|
||||
IF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Found mbedTLS:")
|
||||
FILE(READ ${MBEDTLS_INCLUDE_DIR}/mbedtls/version.h MBEDTLSCONTENT)
|
||||
STRING(REGEX MATCH "MBEDTLS_VERSION_STRING +\"[0-9|.]+\"" MBEDTLSMATCH ${MBEDTLSCONTENT})
|
||||
IF (MBEDTLSMATCH)
|
||||
STRING(REGEX REPLACE "MBEDTLS_VERSION_STRING +\"([0-9|.]+)\"" "\\1" MBEDTLS_VERSION ${MBEDTLSMATCH})
|
||||
MESSAGE(STATUS " version ${MBEDTLS_VERSION}")
|
||||
ENDIF(MBEDTLSMATCH)
|
||||
MESSAGE(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
MESSAGE(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
MESSAGE(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
ENDIF(NOT MBEDTLS_FIND_QUIETLY)
|
||||
ELSE(MBEDTLS_FOUND)
|
||||
IF(MBEDTLS_FIND_REQUIRED)
|
||||
MESSAGE(FATAL_ERROR "Could not find mbedTLS")
|
||||
ENDIF(MBEDTLS_FIND_REQUIRED)
|
||||
ENDIF(MBEDTLS_FOUND)
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
@@ -1,22 +0,0 @@
|
||||
# This function splits the sources files up into their appropriate
|
||||
# subdirectories. This is especially useful for IDEs like Xcode and
|
||||
# Visual Studio, so that you can navigate into the libgit2_clar project,
|
||||
# and see the folders within the tests folder (instead of just seeing all
|
||||
# source and tests in a single folder.)
|
||||
FUNCTION(IDE_SPLIT_SOURCES target)
|
||||
IF(MSVC_IDE OR CMAKE_GENERATOR STREQUAL Xcode)
|
||||
GET_TARGET_PROPERTY(sources ${target} SOURCES)
|
||||
FOREACH(source ${sources})
|
||||
IF(source MATCHES ".*/")
|
||||
STRING(REPLACE ${libgit2_SOURCE_DIR}/ "" rel ${source})
|
||||
IF(rel)
|
||||
STRING(REGEX REPLACE "/([^/]*)$" "" rel ${rel})
|
||||
IF(rel)
|
||||
STRING(REPLACE "/" "\\\\" rel ${rel})
|
||||
SOURCE_GROUP(${rel} FILES ${source})
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ENDIF()
|
||||
ENDFUNCTION()
|
||||
@@ -1,77 +0,0 @@
|
||||
# pkg-config file generation
|
||||
#
|
||||
|
||||
function(pkg_build_config)
|
||||
set(options)
|
||||
set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
|
||||
set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
|
||||
|
||||
cmake_parse_arguments(PKGCONFIG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT DEFINED PKGCONFIG_FILENAME AND DEFINED PKGCONFIG_NAME)
|
||||
set(PKGCONFIG_FILENAME ${PKGCONFIG_NAME})
|
||||
endif()
|
||||
if (NOT DEFINED PKGCONFIG_FILENAME)
|
||||
message(FATAL_ERROR "Missing FILENAME argument")
|
||||
endif()
|
||||
set(PKGCONFIG_FILE "${PROJECT_BINARY_DIR}/${PKGCONFIG_FILENAME}.pc")
|
||||
|
||||
if (NOT DEFINED PKGCONFIG_DESCRIPTION)
|
||||
message(FATAL_ERROR "Missing DESCRIPTION argument")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PKGCONFIG_VERSION)
|
||||
message(FATAL_ERROR "Missing VERSION argument")
|
||||
endif()
|
||||
|
||||
# Write .pc "header"
|
||||
file(WRITE "${PKGCONFIG_FILE}"
|
||||
"prefix=\"${CMAKE_INSTALL_PREFIX}\"\n"
|
||||
"libdir=\"${CMAKE_INSTALL_FULL_LIBDIR}\"\n"
|
||||
"includedir=\"${CMAKE_INSTALL_FULL_INCLUDEDIR}\"\n"
|
||||
"\n"
|
||||
"Name: ${PKGCONFIG_NAME}\n"
|
||||
"Description: ${PKGCONFIG_DESCRIPTION}\n"
|
||||
"Version: ${PKGCONFIG_VERSION}\n"
|
||||
)
|
||||
|
||||
# Prepare Libs
|
||||
if(NOT DEFINED PKGCONFIG_LIBS_SELF)
|
||||
set(PKGCONFIG_LIBS_SELF "${PKGCONFIG_FILE}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED PKGCONFIG_LIBS)
|
||||
set(PKGCONFIG_LIBS "-l${PKGCONFIG_LIBS_SELF}")
|
||||
else()
|
||||
list(INSERT PKGCONFIG_LIBS 0 "-l${PKGCONFIG_LIBS_SELF}")
|
||||
endif()
|
||||
|
||||
list(REMOVE_DUPLICATES PKGCONFIG_LIBS)
|
||||
string(REPLACE ";" " " PKGCONFIG_LIBS "${PKGCONFIG_LIBS}")
|
||||
file(APPEND "${PKGCONFIG_FILE}" "Libs: -L\${libdir} ${PKGCONFIG_LIBS}\n")
|
||||
|
||||
# Prepare Libs.private
|
||||
if(DEFINED PKGCONFIG_PRIVATE_LIBS)
|
||||
list(REMOVE_DUPLICATES PKGCONFIG_PRIVATE_LIBS)
|
||||
string(REPLACE ";" " " PKGCONFIG_PRIVATE_LIBS "${PKGCONFIG_PRIVATE_LIBS}")
|
||||
file(APPEND "${PKGCONFIG_FILE}" "Libs.private: ${PKGCONFIG_PRIVATE_LIBS}\n")
|
||||
endif()
|
||||
|
||||
# Prepare Requires.private
|
||||
if(DEFINED PKGCONFIG_REQUIRES)
|
||||
list(REMOVE_DUPLICATES PKGCONFIG_REQUIRES)
|
||||
string(REPLACE ";" " " PKGCONFIG_REQUIRES "${PKGCONFIG_REQUIRES}")
|
||||
file(APPEND "${PKGCONFIG_FILE}" "Requires.private: ${PKGCONFIG_REQUIRES}\n")
|
||||
endif()
|
||||
|
||||
# Prepare Cflags
|
||||
if(DEFINED PKGCONFIG_CFLAGS)
|
||||
string(REPLACE ";" " " PKGCONFIG_CFLAGS "${PKGCONFIG_CFLAGS}")
|
||||
else()
|
||||
set(PKGCONFIG_CFLAGS "")
|
||||
endif()
|
||||
file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n")
|
||||
|
||||
# Install .pc file
|
||||
install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endfunction()
|
||||
@@ -1,20 +0,0 @@
|
||||
FUNCTION(SanitizeBool VAR)
|
||||
STRING(TOLOWER "${${VAR}}" VALUE)
|
||||
IF(VALUE STREQUAL "on")
|
||||
SET(${VAR} "ON" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "yes")
|
||||
SET(${VAR} "ON" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "true")
|
||||
SET(${VAR} "ON" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "1")
|
||||
SET(${VAR} "ON" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "off")
|
||||
SET(${VAR} "OFF" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "no")
|
||||
SET(${VAR} "OFF" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "false")
|
||||
SET(${VAR} "OFF" PARENT_SCOPE)
|
||||
ELSEIF(VALUE STREQUAL "0")
|
||||
SET(${VAR} "OFF" PARENT_SCOPE)
|
||||
ENDIF()
|
||||
ENDFUNCTION()
|
||||
@@ -1,56 +0,0 @@
|
||||
# Select the backend to use
|
||||
|
||||
# We try to find any packages our backends might use
|
||||
|
||||
INCLUDE(SanitizeBool)
|
||||
|
||||
FIND_PACKAGE(GSSAPI)
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
INCLUDE(FindGSSFramework)
|
||||
ENDIF()
|
||||
|
||||
# Auto-select GSS backend
|
||||
SanitizeBool(USE_GSSAPI)
|
||||
IF (USE_GSSAPI STREQUAL ON)
|
||||
IF (GSSFRAMEWORK_FOUND)
|
||||
SET(GSS_BACKEND "GSS.framework")
|
||||
ELSEIF(GSSAPI_FOUND)
|
||||
SET(GSS_BACKEND "gssapi")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
|
||||
"Please pass the backend name explicitly (-DUSE_GSS=backend)")
|
||||
ENDIF()
|
||||
ELSEIF(USE_GSSAPI)
|
||||
# Backend was explicitly set
|
||||
SET(GSS_BACKEND ${USE_GSSAPI})
|
||||
ELSE()
|
||||
SET(GSS_BACKEND NO)
|
||||
ENDIF()
|
||||
|
||||
IF(GSS_BACKEND)
|
||||
# Check that we can find what's required for the selected backend
|
||||
IF (GSS_BACKEND STREQUAL "GSS.framework")
|
||||
IF (NOT GSSFRAMEWORK_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
|
||||
ENDIF()
|
||||
|
||||
LIST(APPEND LIBGIT2_LIBS ${GSSFRAMEWORK_LIBRARIES})
|
||||
|
||||
SET(GIT_GSSFRAMEWORK 1)
|
||||
ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${GSS_BACKEND})")
|
||||
ELSEIF (GSS_BACKEND STREQUAL "gssapi")
|
||||
IF (NOT GSSAPI_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
|
||||
LIST(APPEND LIBGIT2_LIBS ${GSSAPI_LIBRARIES})
|
||||
|
||||
SET(GIT_GSSAPI 1)
|
||||
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${GSS_BACKEND})")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for backend ${GSS_BACKEND} but it wasn't found")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(GIT_GSSAPI 0)
|
||||
ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
|
||||
ENDIF()
|
||||
@@ -1,127 +0,0 @@
|
||||
# Select the backend to use
|
||||
|
||||
INCLUDE(SanitizeBool)
|
||||
|
||||
# We try to find any packages our backends might use
|
||||
FIND_PACKAGE(OpenSSL)
|
||||
FIND_PACKAGE(mbedTLS)
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
FIND_PACKAGE(Security)
|
||||
FIND_PACKAGE(CoreFoundation)
|
||||
ENDIF()
|
||||
|
||||
# Auto-select TLS backend
|
||||
SanitizeBool(USE_HTTPS)
|
||||
IF (USE_HTTPS STREQUAL ON)
|
||||
IF (SECURITY_FOUND)
|
||||
IF (SECURITY_HAS_SSLCREATECONTEXT)
|
||||
SET(HTTPS_BACKEND "SecureTransport")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
|
||||
SET(HTTPS_BACKEND "OpenSSL")
|
||||
ENDIF()
|
||||
ELSEIF (WINHTTP)
|
||||
SET(HTTPS_BACKEND "WinHTTP")
|
||||
ELSEIF(OPENSSL_FOUND)
|
||||
SET(HTTPS_BACKEND "OpenSSL")
|
||||
ELSEIF(MBEDTLS_FOUND)
|
||||
SET(HTTPS_BACKEND "mbedTLS")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
|
||||
"Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
|
||||
ENDIF()
|
||||
ELSEIF(USE_HTTPS)
|
||||
# HTTPS backend was explicitly set
|
||||
SET(HTTPS_BACKEND ${USE_HTTPS})
|
||||
ELSE()
|
||||
SET(HTTPS_BACKEND NO)
|
||||
ENDIF()
|
||||
|
||||
IF(HTTPS_BACKEND)
|
||||
# Check that we can find what's required for the selected backend
|
||||
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
|
||||
IF (NOT COREFOUNDATION_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, CoreFoundation.framework not found")
|
||||
ENDIF()
|
||||
IF (NOT SECURITY_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, Security.framework not found")
|
||||
ENDIF()
|
||||
IF (NOT SECURITY_HAS_SSLCREATECONTEXT)
|
||||
MESSAGE(FATAL_ERROR "Cannot use SecureTransport backend, SSLCreateContext not supported")
|
||||
ENDIF()
|
||||
|
||||
SET(GIT_SECURE_TRANSPORT 1)
|
||||
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
|
||||
LIST(APPEND LIBGIT2_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
LIST(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
|
||||
IF (NOT OPENSSL_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
|
||||
SET(GIT_OPENSSL 1)
|
||||
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||
LIST(APPEND LIBGIT2_LIBS ${OPENSSL_LIBRARIES})
|
||||
LIST(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
|
||||
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
|
||||
ELSEIF(HTTPS_BACKEND STREQUAL "mbedTLS")
|
||||
IF (NOT MBEDTLS_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
|
||||
IF(NOT CERT_LOCATION)
|
||||
MESSAGE(STATUS "Auto-detecting default certificates location")
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES Darwin)
|
||||
# Check for an Homebrew installation
|
||||
SET(OPENSSL_CMD "/usr/local/opt/openssl/bin/openssl")
|
||||
ELSE()
|
||||
SET(OPENSSL_CMD "openssl")
|
||||
ENDIF()
|
||||
EXECUTE_PROCESS(COMMAND ${OPENSSL_CMD} version -d OUTPUT_VARIABLE OPENSSL_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
IF(OPENSSL_DIR)
|
||||
STRING(REGEX REPLACE "^OPENSSLDIR: \"(.*)\"$" "\\1/" OPENSSL_DIR ${OPENSSL_DIR})
|
||||
|
||||
SET(OPENSSL_CA_LOCATIONS
|
||||
"ca-bundle.pem" # OpenSUSE Leap 42.1
|
||||
"cert.pem" # Ubuntu 14.04, FreeBSD
|
||||
"certs/ca-certificates.crt" # Ubuntu 16.04
|
||||
"certs/ca.pem" # Debian 7
|
||||
)
|
||||
FOREACH(SUFFIX IN LISTS OPENSSL_CA_LOCATIONS)
|
||||
SET(LOC "${OPENSSL_DIR}${SUFFIX}")
|
||||
IF(NOT CERT_LOCATION AND EXISTS "${OPENSSL_DIR}${SUFFIX}")
|
||||
SET(CERT_LOCATION ${LOC})
|
||||
ENDIF()
|
||||
ENDFOREACH()
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to find OpenSSL executable. Please provide default certificate location via CERT_LOCATION")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
IF(CERT_LOCATION)
|
||||
IF(NOT EXISTS ${CERT_LOCATION})
|
||||
MESSAGE(FATAL_ERROR "Cannot use CERT_LOCATION=${CERT_LOCATION} as it doesn't exist")
|
||||
ENDIF()
|
||||
ADD_FEATURE_INFO(CERT_LOCATION ON "using certificates from ${CERT_LOCATION}")
|
||||
ADD_DEFINITIONS(-DGIT_DEFAULT_CERT_LOCATION="${CERT_LOCATION}")
|
||||
ENDIF()
|
||||
|
||||
SET(GIT_MBEDTLS 1)
|
||||
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
|
||||
# mbedTLS has no pkgconfig file, hence we can't require it
|
||||
# https://github.com/ARMmbed/mbedtls/issues/228
|
||||
# For now, pass its link flags as our own
|
||||
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
|
||||
ELSEIF (HTTPS_BACKEND STREQUAL "WinHTTP")
|
||||
# WinHTTP setup was handled in the WinHTTP-specific block above
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for backend ${HTTPS_BACKEND} but it wasn't found")
|
||||
ENDIF()
|
||||
|
||||
SET(GIT_HTTPS 1)
|
||||
ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${HTTPS_BACKEND}")
|
||||
ELSE()
|
||||
SET(GIT_HTTPS 0)
|
||||
ADD_FEATURE_INFO(HTTPS NO "")
|
||||
ENDIF()
|
||||
@@ -1,69 +0,0 @@
|
||||
# Select a hash backend
|
||||
|
||||
INCLUDE(SanitizeBool)
|
||||
|
||||
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
|
||||
|
||||
SanitizeBool(USE_SHA1)
|
||||
IF(USE_SHA1 STREQUAL ON OR USE_SHA1 STREQUAL "CollisionDetection")
|
||||
SET(SHA1_BACKEND "CollisionDetection")
|
||||
ELSEIF(USE_SHA1 STREQUAL "HTTPS")
|
||||
message(STATUS "Checking HTTPS backend… ${HTTPS_BACKEND}")
|
||||
IF(HTTPS_BACKEND STREQUAL "SecureTransport")
|
||||
SET(SHA1_BACKEND "CommonCrypto")
|
||||
ELSEIF(HTTPS_BACKEND STREQUAL "WinHTTP")
|
||||
SET(SHA1_BACKEND "Win32")
|
||||
ELSEIF(HTTPS_BACKEND)
|
||||
SET(SHA1_BACKEND ${HTTPS_BACKEND})
|
||||
ELSE()
|
||||
ENDIF()
|
||||
IF(NOT HTTPS_BACKEND)
|
||||
SET(SHA1_BACKEND "CollisionDetection")
|
||||
ENDIF()
|
||||
message(STATUS "Using SHA1 backend ${SHA1_BACKEND}")
|
||||
ELSEIF(USE_SHA1 STREQUAL "Generic")
|
||||
SET(SHA1_BACKEND "Generic")
|
||||
# ELSEIF(NOT USE_SHA1)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Invalid value for USE_SHA1: ${USE_SHA1}")
|
||||
ENDIF()
|
||||
|
||||
IF(SHA1_BACKEND STREQUAL "CollisionDetection")
|
||||
SET(GIT_SHA1_COLLISIONDETECT 1)
|
||||
ADD_DEFINITIONS(-DSHA1DC_NO_STANDARD_INCLUDES=1)
|
||||
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_SHA1_C=\"common.h\")
|
||||
ADD_DEFINITIONS(-DSHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C=\"common.h\")
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/collisiondetect.* hash/sha1/sha1dc/*)
|
||||
ELSEIF(SHA1_BACKEND STREQUAL "OpenSSL")
|
||||
# OPENSSL_FOUND should already be set, we're checking HTTPS_BACKEND
|
||||
|
||||
SET(GIT_SHA1_OPENSSL 1)
|
||||
IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
LIST(APPEND LIBGIT2_PC_LIBS "-lssl")
|
||||
ELSE()
|
||||
LIST(APPEND LIBGIT2_PC_REQUIRES "openssl")
|
||||
ENDIF()
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/openssl.*)
|
||||
ELSEIF(SHA1_BACKEND STREQUAL "CommonCrypto")
|
||||
SET(GIT_SHA1_COMMON_CRYPTO 1)
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
|
||||
ELSEIF(SHA1_BACKEND STREQUAL "mbedTLS")
|
||||
SET(GIT_SHA1_MBEDTLS 1)
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/mbedtls.*)
|
||||
LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
LIST(APPEND LIBGIT2_LIBS ${MBEDTLS_LIBRARIES})
|
||||
# mbedTLS has no pkgconfig file, hence we can't require it
|
||||
# https://github.com/ARMmbed/mbedtls/issues/228
|
||||
# For now, pass its link flags as our own
|
||||
LIST(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
|
||||
ELSEIF(SHA1_BACKEND STREQUAL "Win32")
|
||||
SET(GIT_SHA1_WIN32 1)
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
|
||||
ELSEIF(SHA1_BACKEND STREQUAL "Generic")
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
|
||||
# ELSEIF(NOT USE_SHA1)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${SHA1_BACKEND}")
|
||||
ENDIF()
|
||||
|
||||
ADD_FEATURE_INFO(SHA ON "using ${SHA1_BACKEND}")
|
||||
@@ -1,5 +0,0 @@
|
||||
FILE(GLOB SRC_HTTP "*.c" "*.h")
|
||||
|
||||
ADD_LIBRARY(http-parser OBJECT ${SRC_HTTP})
|
||||
|
||||
ENABLE_WARNINGS(implicit-fallthrough=1)
|
||||
@@ -1,23 +0,0 @@
|
||||
http_parser.c is based on src/http/ngx_http_parse.c from NGINX copyright
|
||||
Igor Sysoev.
|
||||
|
||||
Additional changes are licensed under the same terms as NGINX and
|
||||
copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
|
||||
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.
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,305 +0,0 @@
|
||||
/* Copyright Joyent, Inc. and other Node contributors. All rights reserved.
|
||||
*
|
||||
* 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 http_parser_h
|
||||
#define http_parser_h
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define HTTP_PARSER_VERSION_MAJOR 2
|
||||
#define HTTP_PARSER_VERSION_MINOR 0
|
||||
|
||||
#include <sys/types.h>
|
||||
#if defined(_WIN32) && !defined(__MINGW32__) && (!defined(_MSC_VER) || _MSC_VER<1600)
|
||||
#include <BaseTsd.h>
|
||||
typedef __int8 int8_t;
|
||||
typedef unsigned __int8 uint8_t;
|
||||
typedef __int16 int16_t;
|
||||
typedef unsigned __int16 uint16_t;
|
||||
typedef __int32 int32_t;
|
||||
typedef unsigned __int32 uint32_t;
|
||||
typedef __int64 int64_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
typedef SIZE_T size_t;
|
||||
typedef SSIZE_T ssize_t;
|
||||
#elif defined(__sun) || defined(__sun__)
|
||||
#include <sys/inttypes.h>
|
||||
#else
|
||||
#include <stdint.h>
|
||||
#endif
|
||||
|
||||
/* Compile with -DHTTP_PARSER_STRICT=0 to make less checks, but run
|
||||
* faster
|
||||
*/
|
||||
#ifndef HTTP_PARSER_STRICT
|
||||
# define HTTP_PARSER_STRICT 1
|
||||
#endif
|
||||
|
||||
/* Maximium header size allowed */
|
||||
#define HTTP_MAX_HEADER_SIZE (80*1024)
|
||||
|
||||
|
||||
typedef struct http_parser http_parser;
|
||||
typedef struct http_parser_settings http_parser_settings;
|
||||
|
||||
|
||||
/* Callbacks should return non-zero to indicate an error. The parser will
|
||||
* then halt execution.
|
||||
*
|
||||
* The one exception is on_headers_complete. In a HTTP_RESPONSE parser
|
||||
* returning '1' from on_headers_complete will tell the parser that it
|
||||
* should not expect a body. This is used when receiving a response to a
|
||||
* HEAD request which may contain 'Content-Length' or 'Transfer-Encoding:
|
||||
* chunked' headers that indicate the presence of a body.
|
||||
*
|
||||
* http_data_cb does not return data chunks. It will be call arbitrarally
|
||||
* many times for each string. E.G. you might get 10 callbacks for "on_url"
|
||||
* each providing just a few characters more data.
|
||||
*/
|
||||
typedef int (*http_data_cb) (http_parser*, const char *at, size_t length);
|
||||
typedef int (*http_cb) (http_parser*);
|
||||
|
||||
|
||||
/* Request Methods */
|
||||
#define HTTP_METHOD_MAP(XX) \
|
||||
XX(0, DELETE, DELETE) \
|
||||
XX(1, GET, GET) \
|
||||
XX(2, HEAD, HEAD) \
|
||||
XX(3, POST, POST) \
|
||||
XX(4, PUT, PUT) \
|
||||
/* pathological */ \
|
||||
XX(5, CONNECT, CONNECT) \
|
||||
XX(6, OPTIONS, OPTIONS) \
|
||||
XX(7, TRACE, TRACE) \
|
||||
/* webdav */ \
|
||||
XX(8, COPY, COPY) \
|
||||
XX(9, LOCK, LOCK) \
|
||||
XX(10, MKCOL, MKCOL) \
|
||||
XX(11, MOVE, MOVE) \
|
||||
XX(12, PROPFIND, PROPFIND) \
|
||||
XX(13, PROPPATCH, PROPPATCH) \
|
||||
XX(14, SEARCH, SEARCH) \
|
||||
XX(15, UNLOCK, UNLOCK) \
|
||||
/* subversion */ \
|
||||
XX(16, REPORT, REPORT) \
|
||||
XX(17, MKACTIVITY, MKACTIVITY) \
|
||||
XX(18, CHECKOUT, CHECKOUT) \
|
||||
XX(19, MERGE, MERGE) \
|
||||
/* upnp */ \
|
||||
XX(20, MSEARCH, M-SEARCH) \
|
||||
XX(21, NOTIFY, NOTIFY) \
|
||||
XX(22, SUBSCRIBE, SUBSCRIBE) \
|
||||
XX(23, UNSUBSCRIBE, UNSUBSCRIBE) \
|
||||
/* RFC-5789 */ \
|
||||
XX(24, PATCH, PATCH) \
|
||||
XX(25, PURGE, PURGE) \
|
||||
|
||||
enum http_method
|
||||
{
|
||||
#define XX(num, name, string) HTTP_##name = num,
|
||||
HTTP_METHOD_MAP(XX)
|
||||
#undef XX
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_type { HTTP_REQUEST, HTTP_RESPONSE, HTTP_BOTH };
|
||||
|
||||
|
||||
/* Flag values for http_parser.flags field */
|
||||
enum flags
|
||||
{ F_CHUNKED = 1 << 0
|
||||
, F_CONNECTION_KEEP_ALIVE = 1 << 1
|
||||
, F_CONNECTION_CLOSE = 1 << 2
|
||||
, F_TRAILING = 1 << 3
|
||||
, F_UPGRADE = 1 << 4
|
||||
, F_SKIPBODY = 1 << 5
|
||||
};
|
||||
|
||||
|
||||
/* Map for errno-related constants
|
||||
*
|
||||
* The provided argument should be a macro that takes 2 arguments.
|
||||
*/
|
||||
#define HTTP_ERRNO_MAP(XX) \
|
||||
/* No error */ \
|
||||
XX(OK, "success") \
|
||||
\
|
||||
/* Callback-related errors */ \
|
||||
XX(CB_message_begin, "the on_message_begin callback failed") \
|
||||
XX(CB_url, "the on_url callback failed") \
|
||||
XX(CB_header_field, "the on_header_field callback failed") \
|
||||
XX(CB_header_value, "the on_header_value callback failed") \
|
||||
XX(CB_headers_complete, "the on_headers_complete callback failed") \
|
||||
XX(CB_body, "the on_body callback failed") \
|
||||
XX(CB_message_complete, "the on_message_complete callback failed") \
|
||||
\
|
||||
/* Parsing-related errors */ \
|
||||
XX(INVALID_EOF_STATE, "stream ended at an unexpected time") \
|
||||
XX(HEADER_OVERFLOW, \
|
||||
"too many header bytes seen; overflow detected") \
|
||||
XX(CLOSED_CONNECTION, \
|
||||
"data received after completed connection: close message") \
|
||||
XX(INVALID_VERSION, "invalid HTTP version") \
|
||||
XX(INVALID_STATUS, "invalid HTTP status code") \
|
||||
XX(INVALID_METHOD, "invalid HTTP method") \
|
||||
XX(INVALID_URL, "invalid URL") \
|
||||
XX(INVALID_HOST, "invalid host") \
|
||||
XX(INVALID_PORT, "invalid port") \
|
||||
XX(INVALID_PATH, "invalid path") \
|
||||
XX(INVALID_QUERY_STRING, "invalid query string") \
|
||||
XX(INVALID_FRAGMENT, "invalid fragment") \
|
||||
XX(LF_EXPECTED, "LF character expected") \
|
||||
XX(INVALID_HEADER_TOKEN, "invalid character in header") \
|
||||
XX(INVALID_CONTENT_LENGTH, \
|
||||
"invalid character in content-length header") \
|
||||
XX(INVALID_CHUNK_SIZE, \
|
||||
"invalid character in chunk size header") \
|
||||
XX(INVALID_CONSTANT, "invalid constant string") \
|
||||
XX(INVALID_INTERNAL_STATE, "encountered unexpected internal state")\
|
||||
XX(STRICT, "strict mode assertion failed") \
|
||||
XX(PAUSED, "parser is paused") \
|
||||
XX(UNKNOWN, "an unknown error occurred")
|
||||
|
||||
|
||||
/* Define HPE_* values for each errno value above */
|
||||
#define HTTP_ERRNO_GEN(n, s) HPE_##n,
|
||||
enum http_errno {
|
||||
HTTP_ERRNO_MAP(HTTP_ERRNO_GEN)
|
||||
};
|
||||
#undef HTTP_ERRNO_GEN
|
||||
|
||||
|
||||
/* Get an http_errno value from an http_parser */
|
||||
#define HTTP_PARSER_ERRNO(p) ((enum http_errno) (p)->http_errno)
|
||||
|
||||
|
||||
struct http_parser {
|
||||
/** PRIVATE **/
|
||||
unsigned char type : 2; /* enum http_parser_type */
|
||||
unsigned char flags : 6; /* F_* values from 'flags' enum; semi-public */
|
||||
unsigned char state; /* enum state from http_parser.c */
|
||||
unsigned char header_state; /* enum header_state from http_parser.c */
|
||||
unsigned char index; /* index into current matcher */
|
||||
|
||||
uint32_t nread; /* # bytes read in various scenarios */
|
||||
uint64_t content_length; /* # bytes in body (0 if no Content-Length header) */
|
||||
|
||||
/** READ-ONLY **/
|
||||
unsigned short http_major;
|
||||
unsigned short http_minor;
|
||||
unsigned short status_code; /* responses only */
|
||||
unsigned char method; /* requests only */
|
||||
unsigned char http_errno : 7;
|
||||
|
||||
/* 1 = Upgrade header was present and the parser has exited because of that.
|
||||
* 0 = No upgrade header present.
|
||||
* Should be checked when http_parser_execute() returns in addition to
|
||||
* error checking.
|
||||
*/
|
||||
unsigned char upgrade : 1;
|
||||
|
||||
/** PUBLIC **/
|
||||
void *data; /* A pointer to get hook to the "connection" or "socket" object */
|
||||
};
|
||||
|
||||
|
||||
struct http_parser_settings {
|
||||
http_cb on_message_begin;
|
||||
http_data_cb on_url;
|
||||
http_data_cb on_header_field;
|
||||
http_data_cb on_header_value;
|
||||
http_cb on_headers_complete;
|
||||
http_data_cb on_body;
|
||||
http_cb on_message_complete;
|
||||
};
|
||||
|
||||
|
||||
enum http_parser_url_fields
|
||||
{ UF_SCHEMA = 0
|
||||
, UF_HOST = 1
|
||||
, UF_PORT = 2
|
||||
, UF_PATH = 3
|
||||
, UF_QUERY = 4
|
||||
, UF_FRAGMENT = 5
|
||||
, UF_USERINFO = 6
|
||||
, UF_MAX = 7
|
||||
};
|
||||
|
||||
|
||||
/* Result structure for http_parser_parse_url().
|
||||
*
|
||||
* Callers should index into field_data[] with UF_* values iff field_set
|
||||
* has the relevant (1 << UF_*) bit set. As a courtesy to clients (and
|
||||
* because we probably have padding left over), we convert any port to
|
||||
* a uint16_t.
|
||||
*/
|
||||
struct http_parser_url {
|
||||
uint16_t field_set; /* Bitmask of (1 << UF_*) values */
|
||||
uint16_t port; /* Converted UF_PORT string */
|
||||
|
||||
struct {
|
||||
uint16_t off; /* Offset into buffer in which field starts */
|
||||
uint16_t len; /* Length of run in buffer */
|
||||
} field_data[UF_MAX];
|
||||
};
|
||||
|
||||
|
||||
void http_parser_init(http_parser *parser, enum http_parser_type type);
|
||||
|
||||
|
||||
size_t http_parser_execute(http_parser *parser,
|
||||
const http_parser_settings *settings,
|
||||
const char *data,
|
||||
size_t len);
|
||||
|
||||
|
||||
/* If http_should_keep_alive() in the on_headers_complete or
|
||||
* on_message_complete callback returns 0, then this should be
|
||||
* the last message on the connection.
|
||||
* If you are the server, respond with the "Connection: close" header.
|
||||
* If you are the client, close the connection.
|
||||
*/
|
||||
int http_should_keep_alive(const http_parser *parser);
|
||||
|
||||
/* Returns a string version of the HTTP method. */
|
||||
const char *http_method_str(enum http_method m);
|
||||
|
||||
/* Return a string name of the given error */
|
||||
const char *http_errno_name(enum http_errno err);
|
||||
|
||||
/* Return a string description of the given error */
|
||||
const char *http_errno_description(enum http_errno err);
|
||||
|
||||
/* Parse a URL; return nonzero on failure */
|
||||
int http_parser_parse_url(const char *buf, size_t buflen,
|
||||
int is_connect,
|
||||
struct http_parser_url *u);
|
||||
|
||||
/* Pause or un-pause the parser; a nonzero value pauses */
|
||||
void http_parser_pause(http_parser *parser, int paused);
|
||||
|
||||
/* Checks if this is the final chunk of the body. */
|
||||
int http_body_is_final(const http_parser *parser);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
@@ -1,23 +0,0 @@
|
||||
FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")
|
||||
|
||||
ADD_DEFINITIONS(-DNTLM_STATIC=1)
|
||||
|
||||
DISABLE_WARNINGS(implicit-fallthrough)
|
||||
|
||||
IF (HTTPS_BACKEND STREQUAL "SecureTransport")
|
||||
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c")
|
||||
# CC_MD4 has been deprecated in macOS 10.15.
|
||||
SET_SOURCE_FILES_PROPERTIES("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
|
||||
ELSEIF (HTTPS_BACKEND STREQUAL "OpenSSL")
|
||||
ADD_DEFINITIONS(-DCRYPT_OPENSSL)
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c")
|
||||
ELSEIF (HTTPS_BACKEND STREQUAL "mbedTLS")
|
||||
ADD_DEFINITIONS(-DCRYPT_MBEDTLS)
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c")
|
||||
ELSE ()
|
||||
MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${HTTPS_BACKEND}) for NTLM crypto")
|
||||
ENDIF()
|
||||
|
||||
ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_CRYPTO})
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#ifndef PRIVATE_COMPAT_H__
|
||||
#define PRIVATE_COMPAT_H__
|
||||
|
||||
#if defined (_MSC_VER)
|
||||
typedef unsigned char bool;
|
||||
# ifndef true
|
||||
# define true 1
|
||||
# endif
|
||||
# ifndef false
|
||||
# define false 0
|
||||
# endif
|
||||
#else
|
||||
# include <stdbool.h>
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
/* See man page endian(3) */
|
||||
# include <endian.h>
|
||||
# define htonll htobe64
|
||||
#elif defined(__OpenBSD__)
|
||||
/* See man page htobe64(3) */
|
||||
# include <endian.h>
|
||||
# define htonll htobe64
|
||||
#elif defined(__FreeBSD__)
|
||||
/* See man page bwaps64(9) */
|
||||
# include <sys/endian.h>
|
||||
# define htonll htobe64
|
||||
#elif defined(sun) || defined(__sun)
|
||||
/* See man page byteorder(3SOCKET) */
|
||||
# include <sys/types.h>
|
||||
# include <netinet/in.h>
|
||||
# include <inttypes.h>
|
||||
|
||||
# if !defined(htonll)
|
||||
# if defined(_BIG_ENDIAN)
|
||||
# define htonll(x) (x)
|
||||
# else
|
||||
# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32))
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
# define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
#endif /* PRIVATE_COMPAT_H__ */
|
||||
@@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#ifndef PRIVATE_CRYPT_COMMON_H__
|
||||
#define PRIVATE_CRYPT_COMMON_H__
|
||||
|
||||
#if defined(CRYPT_OPENSSL)
|
||||
# include "crypt_openssl.h"
|
||||
#elif defined(CRYPT_MBEDTLS)
|
||||
# include "crypt_mbedtls.h"
|
||||
#elif defined(CRYPT_COMMONCRYPTO)
|
||||
# include "crypt_commoncrypto.h"
|
||||
#else
|
||||
# error "no crypto support"
|
||||
#endif
|
||||
|
||||
#define CRYPT_DES_BLOCKSIZE 8
|
||||
#define CRYPT_MD4_DIGESTSIZE 16
|
||||
#define CRYPT_MD5_DIGESTSIZE 16
|
||||
|
||||
typedef unsigned char ntlm_des_block[CRYPT_DES_BLOCKSIZE];
|
||||
|
||||
extern bool ntlm_random_bytes(
|
||||
ntlm_client *ntlm,
|
||||
unsigned char *out,
|
||||
size_t len);
|
||||
|
||||
extern bool ntlm_des_encrypt(
|
||||
ntlm_des_block *out,
|
||||
ntlm_des_block *plaintext,
|
||||
ntlm_des_block *key);
|
||||
|
||||
extern bool ntlm_md4_digest(
|
||||
unsigned char out[CRYPT_MD4_DIGESTSIZE],
|
||||
const unsigned char *in,
|
||||
size_t in_len);
|
||||
|
||||
extern ntlm_hmac_ctx *ntlm_hmac_ctx_init(void);
|
||||
|
||||
extern bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx);
|
||||
|
||||
extern bool ntlm_hmac_md5_init(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *key,
|
||||
size_t key_len);
|
||||
|
||||
extern bool ntlm_hmac_md5_update(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *data,
|
||||
size_t data_len);
|
||||
|
||||
extern bool ntlm_hmac_md5_final(
|
||||
unsigned char *out,
|
||||
size_t *out_len,
|
||||
ntlm_hmac_ctx *ctx);
|
||||
|
||||
extern void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx);
|
||||
|
||||
#endif /* PRIVATE_CRYPT_COMMON_H__ */
|
||||
@@ -1,120 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
#include "ntlm.h"
|
||||
#include "crypt.h"
|
||||
|
||||
bool ntlm_random_bytes(
|
||||
ntlm_client *ntlm,
|
||||
unsigned char *out,
|
||||
size_t len)
|
||||
{
|
||||
int fd, ret;
|
||||
size_t total = 0;
|
||||
|
||||
if ((fd = open("/dev/urandom", O_RDONLY)) < 0) {
|
||||
ntlm_client_set_errmsg(ntlm, strerror(errno));
|
||||
return false;
|
||||
}
|
||||
|
||||
while (total < len) {
|
||||
if ((ret = read(fd, out, (len - total))) < 0) {
|
||||
ntlm_client_set_errmsg(ntlm, strerror(errno));
|
||||
return false;
|
||||
} else if (ret == 0) {
|
||||
ntlm_client_set_errmsg(ntlm, "unexpected eof on random device");
|
||||
return false;
|
||||
}
|
||||
|
||||
total += ret;
|
||||
}
|
||||
|
||||
close(fd);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ntlm_des_encrypt(
|
||||
ntlm_des_block *out,
|
||||
ntlm_des_block *plaintext,
|
||||
ntlm_des_block *key)
|
||||
{
|
||||
size_t written;
|
||||
|
||||
CCCryptorStatus result = CCCrypt(kCCEncrypt,
|
||||
kCCAlgorithmDES, kCCOptionECBMode,
|
||||
key, sizeof(ntlm_des_block), NULL,
|
||||
plaintext, sizeof(ntlm_des_block),
|
||||
out, sizeof(ntlm_des_block), &written);
|
||||
|
||||
return (result == kCCSuccess) ? true : false;
|
||||
}
|
||||
|
||||
bool ntlm_md4_digest(
|
||||
unsigned char out[CRYPT_MD4_DIGESTSIZE],
|
||||
const unsigned char *in,
|
||||
size_t in_len)
|
||||
{
|
||||
return !!CC_MD4(in, in_len, out);
|
||||
}
|
||||
|
||||
ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
|
||||
{
|
||||
return calloc(1, sizeof(ntlm_hmac_ctx));
|
||||
}
|
||||
|
||||
bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
memset(ctx, 0, sizeof(ntlm_hmac_ctx));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_init(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *key,
|
||||
size_t key_len)
|
||||
{
|
||||
CCHmacInit(&ctx->native, kCCHmacAlgMD5, key, key_len);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_update(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *data,
|
||||
size_t data_len)
|
||||
{
|
||||
CCHmacUpdate(&ctx->native, data, data_len);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_final(
|
||||
unsigned char *out,
|
||||
size_t *out_len,
|
||||
ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
if (*out_len < CRYPT_MD5_DIGESTSIZE)
|
||||
return false;
|
||||
|
||||
CCHmacFinal(&ctx->native, out);
|
||||
|
||||
*out_len = CRYPT_MD5_DIGESTSIZE;
|
||||
return true;
|
||||
}
|
||||
|
||||
void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
free(ctx);
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#ifndef PRIVATE_CRYPT_COMMONCRYPTO_H__
|
||||
#define PRIVATE_CRYPT_COMMONCRYPTO_H__
|
||||
|
||||
#include <CommonCrypto/CommonCrypto.h>
|
||||
|
||||
typedef struct {
|
||||
CCHmacContext native;
|
||||
} ntlm_hmac_ctx;
|
||||
|
||||
#endif /* PRIVATE_CRYPT_COMMONCRYPTO_H__ */
|
||||
@@ -1,145 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mbedtls/ctr_drbg.h"
|
||||
#include "mbedtls/des.h"
|
||||
#include "mbedtls/entropy.h"
|
||||
#include "mbedtls/md4.h"
|
||||
|
||||
#include "ntlm.h"
|
||||
#include "crypt.h"
|
||||
|
||||
bool ntlm_random_bytes(
|
||||
ntlm_client *ntlm,
|
||||
unsigned char *out,
|
||||
size_t len)
|
||||
{
|
||||
mbedtls_ctr_drbg_context ctr_drbg;
|
||||
mbedtls_entropy_context entropy;
|
||||
bool ret = true;
|
||||
|
||||
const unsigned char personalization[] = {
|
||||
0xec, 0xb5, 0xd1, 0x0b, 0x8f, 0x15, 0x1f, 0xc2,
|
||||
0xe4, 0x8e, 0xec, 0x36, 0xf7, 0x0a, 0x45, 0x9a,
|
||||
0x1f, 0xe1, 0x35, 0x58, 0xb1, 0xcb, 0xfd, 0x8a,
|
||||
0x57, 0x5c, 0x75, 0x7d, 0x2f, 0xc9, 0x70, 0xac
|
||||
};
|
||||
|
||||
mbedtls_ctr_drbg_init(&ctr_drbg);
|
||||
mbedtls_entropy_init(&entropy);
|
||||
|
||||
if (mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func,
|
||||
&entropy, personalization, sizeof(personalization)) ||
|
||||
mbedtls_ctr_drbg_random(&ctr_drbg, out, len)) {
|
||||
ntlm_client_set_errmsg(ntlm, "random generation failed");
|
||||
ret = false;
|
||||
}
|
||||
|
||||
mbedtls_entropy_free(&entropy);
|
||||
mbedtls_ctr_drbg_free(&ctr_drbg);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
bool ntlm_des_encrypt(
|
||||
ntlm_des_block *out,
|
||||
ntlm_des_block *plaintext,
|
||||
ntlm_des_block *key)
|
||||
{
|
||||
mbedtls_des_context ctx;
|
||||
bool success = false;
|
||||
|
||||
mbedtls_des_init(&ctx);
|
||||
|
||||
if (mbedtls_des_setkey_enc(&ctx, *key) ||
|
||||
mbedtls_des_crypt_ecb(&ctx, *plaintext, *out))
|
||||
goto done;
|
||||
|
||||
success = true;
|
||||
|
||||
done:
|
||||
mbedtls_des_free(&ctx);
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ntlm_md4_digest(
|
||||
unsigned char out[CRYPT_MD4_DIGESTSIZE],
|
||||
const unsigned char *in,
|
||||
size_t in_len)
|
||||
{
|
||||
mbedtls_md4_context ctx;
|
||||
|
||||
mbedtls_md4_init(&ctx);
|
||||
mbedtls_md4_starts(&ctx);
|
||||
mbedtls_md4_update(&ctx, in, in_len);
|
||||
mbedtls_md4_finish(&ctx, out);
|
||||
mbedtls_md4_free(&ctx);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
ntlm_hmac_ctx *ntlm_hmac_ctx_init(void)
|
||||
{
|
||||
ntlm_hmac_ctx *ctx;
|
||||
const mbedtls_md_info_t *info = mbedtls_md_info_from_type(MBEDTLS_MD_MD5);
|
||||
|
||||
if ((ctx = calloc(1, sizeof(ntlm_hmac_ctx))) == NULL)
|
||||
return NULL;
|
||||
|
||||
mbedtls_md_init(&ctx->mbed);
|
||||
|
||||
if (mbedtls_md_setup(&ctx->mbed, info, 1) != 0) {
|
||||
free(ctx);
|
||||
return false;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
bool ntlm_hmac_ctx_reset(ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
return !mbedtls_md_hmac_reset(&ctx->mbed);
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_init(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *key,
|
||||
size_t key_len)
|
||||
{
|
||||
return !mbedtls_md_hmac_starts(&ctx->mbed, key, key_len);
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_update(
|
||||
ntlm_hmac_ctx *ctx,
|
||||
const unsigned char *in,
|
||||
size_t in_len)
|
||||
{
|
||||
return !mbedtls_md_hmac_update(&ctx->mbed, in, in_len);
|
||||
}
|
||||
|
||||
bool ntlm_hmac_md5_final(
|
||||
unsigned char *out,
|
||||
size_t *out_len,
|
||||
ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
if (*out_len < CRYPT_MD5_DIGESTSIZE)
|
||||
return false;
|
||||
|
||||
return !mbedtls_md_hmac_finish(&ctx->mbed, out);
|
||||
}
|
||||
|
||||
void ntlm_hmac_ctx_free(ntlm_hmac_ctx *ctx)
|
||||
{
|
||||
if (ctx) {
|
||||
mbedtls_md_free(&ctx->mbed);
|
||||
free(ctx);
|
||||
}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Edward Thomson. All rights reserved.
|
||||
*
|
||||
* This file is part of ntlmclient, distributed under the MIT license.
|
||||
* For full terms and copyright information, and for third-party
|
||||
* copyright information, see the included LICENSE.txt file.
|
||||
*/
|
||||
|
||||
#ifndef PRIVATE_CRYPT_MBEDTLS_H__
|
||||
#define PRIVATE_CRYPT_MBEDTLS_H__
|
||||
|
||||
#include "mbedtls/md.h"
|
||||
|
||||
typedef struct {
|
||||
mbedtls_md_context_t mbed;
|
||||
} ntlm_hmac_ctx;
|
||||
|
||||
#endif /* PRIVATE_CRYPT_MBEDTLS_H__ */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user