mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
Merge branch 'main' into fix-invalid-branch-name
This commit is contained in:
92
.clang-format
Normal file
92
.clang-format
Normal file
@@ -0,0 +1,92 @@
|
||||
# This file is an example configuration for clang-format 5.0.
|
||||
#
|
||||
# Note that this style definition should only be understood as a hint
|
||||
# for writing new code. The rules are still work-in-progress and does
|
||||
# not yet exactly match the style we have in the existing code.
|
||||
|
||||
# C Language specifics
|
||||
Language: Cpp
|
||||
|
||||
# Use tabs whenever we need to fill whitespace that spans at least from one tab
|
||||
# stop to the next one.
|
||||
#
|
||||
# These settings are mirrored in .editorconfig. Keep them in sync.
|
||||
UseTab: ForIndentation
|
||||
TabWidth: 8
|
||||
IndentWidth: 8
|
||||
ContinuationIndentWidth: 8
|
||||
ColumnLimit: 80
|
||||
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
AlignEscapedNewlines: Left
|
||||
AlignTrailingComments: false
|
||||
|
||||
# Allow putting parameters onto the next line
|
||||
AllowAllArgumentsOnNextLine: false
|
||||
AllowAllParametersOfDeclarationOnNextLine: false
|
||||
|
||||
# Don't allow short braced statements to be on a single line
|
||||
# if (a) not if (a) return;
|
||||
# return;
|
||||
AllowShortBlocksOnASingleLine: false
|
||||
AllowShortFunctionsOnASingleLine: None
|
||||
AllowShortLoopsOnASingleLine: false
|
||||
AllowShortLambdasOnASingleLine: None
|
||||
|
||||
# Pack as many parameters or arguments onto the same line as possible
|
||||
# int myFunction(int aaaaaaaaaaaa, int bbbbbbbb,
|
||||
# int cccc);
|
||||
BinPackArguments: true
|
||||
BinPackParameters: false
|
||||
|
||||
BreakBeforeBraces: Linux
|
||||
BreakBeforeBinaryOperators: None
|
||||
BreakBeforeTernaryOperators: false
|
||||
BreakStringLiterals: false
|
||||
|
||||
# The number of spaces before trailing line comments (// - comments).
|
||||
# This does not affect trailing block comments (/* - comments).
|
||||
SpacesBeforeTrailingComments: 1
|
||||
|
||||
# Don't insert spaces in casts
|
||||
# x = (int32) y; not x = ( int32 ) y;
|
||||
SpacesInCStyleCastParentheses: false
|
||||
|
||||
# Don't insert spaces inside container literals
|
||||
# var arr = [1, 2, 3]; not var arr = [ 1, 2, 3 ];
|
||||
SpacesInContainerLiterals: false
|
||||
|
||||
# Don't insert spaces after '(' or before ')'
|
||||
# f(arg); not f( arg );
|
||||
SpacesInParentheses: false
|
||||
|
||||
# Don't insert spaces after '[' or before ']'
|
||||
# int a[5]; not int a[ 5 ];
|
||||
SpacesInSquareBrackets: false
|
||||
|
||||
# Insert a space after '{' and before '}' in struct initializers
|
||||
Cpp11BracedListStyle: false
|
||||
|
||||
# A list of macros that should be interpreted as foreach loops instead of as
|
||||
# function calls.
|
||||
ForEachMacros:
|
||||
- 'git_array_foreach'
|
||||
- 'git_vector_foreach'
|
||||
|
||||
# The maximum number of consecutive empty lines to keep.
|
||||
MaxEmptyLinesToKeep: 1
|
||||
|
||||
# No empty line at the start of a block.
|
||||
KeepEmptyLinesAtTheStartOfBlocks: false
|
||||
|
||||
# Penalties
|
||||
# This decides what order things should be done if a line is too long
|
||||
PenaltyBreakAssignment: 10
|
||||
PenaltyBreakBeforeFirstCallParameter: 30
|
||||
PenaltyBreakComment: 10
|
||||
PenaltyBreakFirstLessLess: 0
|
||||
PenaltyBreakString: 10
|
||||
PenaltyExcessCharacter: 100
|
||||
PenaltyReturnTypeOnItsOwnLine: 60
|
||||
|
||||
SortIncludes: false
|
||||
20
.github/release.yml
vendored
Normal file
20
.github/release.yml
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
changelog:
|
||||
categories:
|
||||
- title: New features
|
||||
labels:
|
||||
- feature
|
||||
- title: Bug fixes
|
||||
labels:
|
||||
- bug
|
||||
- title: Code cleanups
|
||||
labels:
|
||||
- cleanup
|
||||
- title: CI improvements
|
||||
labels:
|
||||
- build
|
||||
- title: Documentation improvements
|
||||
labels:
|
||||
- documentation
|
||||
- title: Other changes
|
||||
labels:
|
||||
- '*'
|
||||
82
.github/workflows/benchmark.yml
vendored
Normal file
82
.github/workflows/benchmark.yml
vendored
Normal file
@@ -0,0 +1,82 @@
|
||||
# Benchmark libgit2 against the git reference implementation.
|
||||
name: Benchmark
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '15 4 * * *'
|
||||
|
||||
jobs:
|
||||
# Run our nightly builds. We build a matrix with the various build
|
||||
# targets and their details. Then we build either in a docker container
|
||||
# (Linux) or on the actual hosts (macOS, Windows).
|
||||
build:
|
||||
# Only run scheduled workflows on the main repository; prevents people
|
||||
# from using build minutes on their forks.
|
||||
if: github.repository == 'libgit2/libgit2'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- name: "Linux (clang, OpenSSL)"
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
|
||||
CMAKE_BUILD_OPTIONS: --config Release
|
||||
id: linux
|
||||
os: ubuntu-latest
|
||||
setup-script: ubuntu
|
||||
- name: "macOS"
|
||||
os: macos-10.15
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_OPTIONS: -DREGEX_BACKEND=regcomp_l -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
|
||||
CMAKE_BUILD_OPTIONS: --config Release
|
||||
PKG_CONFIG_PATH: /usr/local/opt/openssl/lib/pkgconfig
|
||||
id: macos
|
||||
setup-script: osx
|
||||
- name: "Windows (amd64, Visual Studio)"
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: amd64
|
||||
CMAKE_GENERATOR: Visual Studio 16 2019
|
||||
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DBUILD_CLI=ON -DCMAKE_BUILD_TYPE=Release
|
||||
CMAKE_BUILD_OPTIONS: --config Release
|
||||
id: windows
|
||||
setup-script: win32
|
||||
fail-fast: false
|
||||
name: "Build ${{ matrix.platform.name }}"
|
||||
env: ${{ matrix.platform.env }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
path: source
|
||||
fetch-depth: 0
|
||||
- name: Set up benchmark environment
|
||||
run: source/ci/setup-${{ matrix.platform.setup-script }}-benchmark.sh
|
||||
shell: bash
|
||||
if: matrix.platform.setup-script != ''
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build && cd build
|
||||
../source/ci/build.sh
|
||||
shell: bash
|
||||
- name: Benchmark
|
||||
run: |
|
||||
if [[ "$(uname -s)" == MINGW* ]]; then
|
||||
GIT2_CLI="$(cygpath -w $(pwd))\\build\\Release\\git2_cli"
|
||||
else
|
||||
GIT2_CLI="$(pwd)/build/git2_cli"
|
||||
fi
|
||||
|
||||
mkdir benchmark && cd benchmark
|
||||
../source/tests/benchmarks/benchmark.sh --baseline-cli "git" --cli "${GIT2_CLI}" --json benchmarks.json --zip benchmarks.zip
|
||||
shell: bash
|
||||
- name: Upload results
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: benchmark-${{ matrix.platform.id }}
|
||||
path: benchmark
|
||||
if: always()
|
||||
36
.github/workflows/codeql.yml
vendored
36
.github/workflows/codeql.yml
vendored
@@ -1,36 +0,0 @@
|
||||
name: "CodeQL"
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
schedule:
|
||||
- cron: '21 3 * * 1'
|
||||
|
||||
env:
|
||||
docker-registry: docker.pkg.github.com
|
||||
|
||||
jobs:
|
||||
analyze:
|
||||
name: Analyze
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: 'cpp'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
cmake --build .
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
104
.github/workflows/main.yml
vendored
104
.github/workflows/main.yml
vendored
@@ -10,7 +10,7 @@ on:
|
||||
workflow_dispatch:
|
||||
|
||||
env:
|
||||
docker-registry: docker.pkg.github.com
|
||||
docker-registry: ghcr.io
|
||||
docker-config-path: source/ci/docker
|
||||
|
||||
jobs:
|
||||
@@ -22,8 +22,7 @@ jobs:
|
||||
# with both the sha and "latest" so that the subsequent runs need not
|
||||
# know the sha. Only do this on CI builds (when the event is a "push")
|
||||
# because PR builds from forks lack permission to write packages.
|
||||
build_containers:
|
||||
name: Create docker image
|
||||
containers:
|
||||
strategy:
|
||||
matrix:
|
||||
container:
|
||||
@@ -46,6 +45,7 @@ jobs:
|
||||
- name: centos7
|
||||
- name: centos8
|
||||
runs-on: ubuntu-latest
|
||||
name: "Create container: ${{ matrix.container.name }}"
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
@@ -69,7 +69,7 @@ jobs:
|
||||
if [ "${{ matrix.container.base }}" != "" ]; then
|
||||
BASE_ARG="--build-arg BASE=${{ matrix.container.base }}"
|
||||
fi
|
||||
docker build -t ${{ env.docker-registry-container-sha }} ${BASE_ARG} -f ${{ env.dockerfile }} .
|
||||
docker build -t ${{ env.docker-registry-container-sha }} --build-arg UID=$(id -u) --build-arg GID=$(id -g) ${BASE_ARG} -f ${{ env.dockerfile }} .
|
||||
docker tag ${{ env.docker-registry-container-sha }} ${{ env.docker-registry-container-latest }}
|
||||
docker push ${{ env.docker-registry-container-sha }}
|
||||
docker push ${{ env.docker-registry-container-latest }}
|
||||
@@ -80,76 +80,82 @@ jobs:
|
||||
# and their details. Then we build either in a docker container (Linux)
|
||||
# or on the actual hosts (macOS, Windows).
|
||||
build:
|
||||
name: Build
|
||||
needs: [ build_containers ]
|
||||
needs: [ containers ]
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- # Xenial, GCC, OpenSSL
|
||||
- name: "Linux (Xenial, GCC, OpenSSL)"
|
||||
id: xenial-gcc-openssl
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON -DDEBUG_STRICT_ALLOC=ON -DDEBUG_STRICT_OPEN=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, GCC, mbedTLS
|
||||
- name: Linux (Xenial, GCC, mbedTLS)
|
||||
id: xenial-gcc-mbedtls
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, Clang, OpenSSL
|
||||
- name: "Linux (Xenial, Clang, OpenSSL)"
|
||||
id: xenial-clang-openssl
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, Clang, mbedTLS
|
||||
- name: "Linux (Xenial, Clang, mbedTLS)"
|
||||
id: xenial-clang-mbedtls
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, mbedTLS, MemorySanitizer
|
||||
- name: "Linux (MemorySanitizer)"
|
||||
id: memorysanitizer
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
CC: clang-10
|
||||
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer
|
||||
- name: "Linux (UndefinedBehaviorSanitizer)"
|
||||
id: ubsanitizer
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
CC: clang-10
|
||||
CFLAGS: -fsanitize=undefined,nullability -fno-sanitize-recover=undefined,nullability -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, OpenSSL, ThreadSanitizer
|
||||
- name: "Linux (ThreadSanitizer)"
|
||||
id: threadsanitizer
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
CC: clang-10
|
||||
CFLAGS: -fsanitize=thread -fno-optimize-sibling-calls -fno-omit-frame-pointer
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local -DUSE_HTTPS=OpenSSL -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
@@ -157,7 +163,8 @@ jobs:
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
|
||||
os: ubuntu-latest
|
||||
- # macOS
|
||||
- name: "macOS"
|
||||
id: macos
|
||||
os: macos-10.15
|
||||
env:
|
||||
CC: clang
|
||||
@@ -166,7 +173,8 @@ jobs:
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
setup-script: osx
|
||||
- # Windows amd64 Visual Studio
|
||||
- name: "Windows (amd64, Visual Studio)"
|
||||
id: windows-amd64-vs
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: amd64
|
||||
@@ -174,7 +182,8 @@ jobs:
|
||||
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows x86 Visual Studio
|
||||
- name: "Windows (x86, Visual Studio)"
|
||||
id: windows-x86-vs
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: x86
|
||||
@@ -182,7 +191,8 @@ jobs:
|
||||
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows amd64 mingw
|
||||
- name: "Windows (amd64, mingw)"
|
||||
id: windows-amd64-mingw
|
||||
os: windows-2019
|
||||
setup-script: mingw
|
||||
env:
|
||||
@@ -193,7 +203,8 @@ jobs:
|
||||
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows x86 mingw
|
||||
- name: "Windows (x86, mingw)"
|
||||
id: windows-x86-mingw
|
||||
os: windows-2019
|
||||
setup-script: mingw
|
||||
env:
|
||||
@@ -207,6 +218,7 @@ jobs:
|
||||
fail-fast: false
|
||||
env: ${{ matrix.platform.env }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
name: "Build: ${{ matrix.platform.name }}"
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
@@ -214,7 +226,7 @@ jobs:
|
||||
path: source
|
||||
fetch-depth: 0
|
||||
- name: Set up build environment
|
||||
run: source/ci/setup-${{ matrix.platform.setup-script }}.sh
|
||||
run: source/ci/setup-${{ matrix.platform.setup-script }}-build.sh
|
||||
shell: bash
|
||||
if: matrix.platform.setup-script != ''
|
||||
- name: Setup QEMU
|
||||
@@ -229,7 +241,11 @@ jobs:
|
||||
working-directory: ${{ env.docker-config-path }}
|
||||
if: matrix.platform.container.name != ''
|
||||
- name: Create container
|
||||
run: docker build -t ${{ env.docker-registry-container-sha }} -f ${{ env.dockerfile }} .
|
||||
run: |
|
||||
if [ "${{ matrix.container.base }}" != "" ]; then
|
||||
BASE_ARG="--build-arg BASE=${{ matrix.container.base }}"
|
||||
fi
|
||||
docker build -t ${{ env.docker-registry-container-sha }} --build-arg UID=$(id -u) --build-arg GID=$(id -g) ${BASE_ARG} -f ${{ env.dockerfile }} .
|
||||
working-directory: ${{ env.docker-config-path }}
|
||||
if: matrix.platform.container.name != '' && env.docker-container-exists != 'true'
|
||||
- name: Build and test
|
||||
@@ -237,10 +253,12 @@ jobs:
|
||||
export GITTEST_NEGOTIATE_PASSWORD="${{ secrets.GITTEST_NEGOTIATE_PASSWORD }}"
|
||||
|
||||
if [ -n "${{ matrix.platform.container.name }}" ]; then
|
||||
mkdir build
|
||||
docker run \
|
||||
--rm \
|
||||
--user libgit2:libgit2 \
|
||||
--user "$(id -u):$(id -g)" \
|
||||
-v "$(pwd)/source:/home/libgit2/source" \
|
||||
-v "$(pwd)/build:/home/libgit2/build" \
|
||||
-w /home/libgit2 \
|
||||
-e ASAN_SYMBOLIZER_PATH \
|
||||
-e CC \
|
||||
@@ -248,19 +266,40 @@ jobs:
|
||||
-e CMAKE_GENERATOR \
|
||||
-e CMAKE_OPTIONS \
|
||||
-e GITTEST_NEGOTIATE_PASSWORD \
|
||||
-e GITTEST_FLAKY_STAT \
|
||||
-e PKG_CONFIG_PATH \
|
||||
-e SKIP_NEGOTIATE_TESTS \
|
||||
-e SKIP_SSH_TESTS \
|
||||
-e TSAN_OPTIONS \
|
||||
-e UBSAN_OPTIONS \
|
||||
${{ env.docker-registry-container-sha }} \
|
||||
/bin/bash -c "mkdir build && cd build && ../source/ci/build.sh && ../source/ci/test.sh"
|
||||
/bin/bash -c "cd build && ../source/ci/build.sh && ../source/ci/test.sh"
|
||||
else
|
||||
mkdir build && cd build
|
||||
mkdir build
|
||||
cd build
|
||||
../source/ci/build.sh
|
||||
../source/ci/test.sh
|
||||
fi
|
||||
shell: bash
|
||||
- name: Upload test results
|
||||
uses: actions/upload-artifact@v3
|
||||
if: success() || failure()
|
||||
with:
|
||||
name: test-results-${{ matrix.platform.id }}
|
||||
path: build/results_*.xml
|
||||
|
||||
test_results:
|
||||
name: Test results
|
||||
needs: [ build ]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Download test results
|
||||
uses: actions/download-artifact@v3
|
||||
- name: Generate test summary
|
||||
uses: test-summary/action@v1
|
||||
with:
|
||||
paths: 'test-results-*/*.xml'
|
||||
|
||||
|
||||
# Generate documentation using docurium. We'll upload the documentation
|
||||
# as a build artifact so that it can be reviewed as part of a pull
|
||||
@@ -269,7 +308,8 @@ jobs:
|
||||
# published to our documentation site.
|
||||
documentation:
|
||||
name: Generate documentation
|
||||
needs: [build_containers]
|
||||
needs: [ containers ]
|
||||
if: success() || failure()
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
@@ -300,4 +340,4 @@ jobs:
|
||||
- name: Push documentation branch
|
||||
working-directory: source
|
||||
run: git push origin gh-pages
|
||||
if: github.event_name != 'pull_request' && github.repository == 'libgit2/libgit2'
|
||||
if: github.event_name == 'push' && github.repository == 'libgit2/libgit2'
|
||||
|
||||
124
.github/workflows/nightly.yml
vendored
124
.github/workflows/nightly.yml
vendored
@@ -7,7 +7,7 @@ on:
|
||||
- cron: '15 1 * * *'
|
||||
|
||||
env:
|
||||
docker-registry: docker.pkg.github.com
|
||||
docker-registry: ghcr.io
|
||||
docker-config-path: source/ci/docker
|
||||
|
||||
jobs:
|
||||
@@ -15,71 +15,75 @@ jobs:
|
||||
# targets and their details. Then we build either in a docker container
|
||||
# (Linux) or on the actual hosts (macOS, Windows).
|
||||
build:
|
||||
name: Build
|
||||
# Only run scheduled workflows on the main repository; prevents people
|
||||
# from using build minutes on their forks.
|
||||
if: github.repository == 'libgit2/libgit2'
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
platform:
|
||||
- # Xenial, GCC, OpenSSL
|
||||
- name: Linux (Xenial, GCC, OpenSSL)
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DREGEX_BACKEND=builtin -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, GCC, mbedTLS
|
||||
- name: "Linux (Xenial, GCC, mbedTLS)"
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, Clang, OpenSSL
|
||||
- name: "Linux (Xenial, Clang, OpenSSL)"
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
os: ubuntu-latest
|
||||
- # Xenial, Clang, mbedTLS
|
||||
- name: "Linux (Xenial, Clang, mbedTLS)"
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
os: ubuntu-latest
|
||||
- # Xenial, GCC, thread-free
|
||||
- name: "Linux (no threads)"
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DTHREADSAFE=OFF -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
os: ubuntu-latest
|
||||
- # Xenial, Clang, OpenSSL (dynamically loaded)
|
||||
- name: "Linux (dynamically-loaded OpenSSL)"
|
||||
container:
|
||||
name: xenial
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, mbedTLS, MemorySanitizer
|
||||
- name: "Linux (MemorySanitizer)"
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
CC: clang-10
|
||||
CFLAGS: -fsanitize=memory -fsanitize-memory-track-origins=2 -fsanitize-blacklist=/home/libgit2/source/script/sanitizers.supp -fno-optimize-sibling-calls -fno-omit-frame-pointer
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
CMAKE_OPTIONS: -DCMAKE_PREFIX_PATH=/usr/local/msan -DUSE_HTTPS=mbedTLS -DUSE_SHA1=HTTPS -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON -DUSE_SSH=ON
|
||||
CMAKE_GENERATOR: Ninja
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
|
||||
UBSAN_OPTIONS: print_stacktrace=1
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, OpenSSL, UndefinedBehaviorSanitizer
|
||||
- name: "Linux (UndefinedBehaviorSanitizer)"
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
@@ -91,7 +95,7 @@ jobs:
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, OpenSSL, ThreadSanitizer
|
||||
- name: "Linux (ThreadSanitizer)"
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
@@ -104,7 +108,7 @@ jobs:
|
||||
ASAN_SYMBOLIZER_PATH: /usr/bin/llvm-symbolizer-10
|
||||
TSAN_OPTIONS: suppressions=/home/libgit2/source/script/thread-sanitizer.supp second_deadlock_stack=1
|
||||
os: ubuntu-latest
|
||||
- # Focal, Clang 10, mmap emulation (NO_MMAP)
|
||||
- name: "Linux (no mmap)"
|
||||
container:
|
||||
name: focal
|
||||
env:
|
||||
@@ -115,23 +119,23 @@ jobs:
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # CentOS 7
|
||||
- name: "Linux (CentOS 7)"
|
||||
container:
|
||||
name: centos7
|
||||
env:
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # CentOS 7, OpenSSL (dynamically loaded)
|
||||
- name: "Linux (CentOS 7, dynamically-loaded OpenSSL)"
|
||||
container:
|
||||
name: centos7
|
||||
env:
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
PKG_CONFIG_PATH: /usr/local/lib/pkgconfig
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # CentOS 8
|
||||
- name: "Linux (CentOS 8)"
|
||||
container:
|
||||
name: centos8
|
||||
env:
|
||||
@@ -140,7 +144,7 @@ jobs:
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # CentOS 8, OpenSSL (dynamically loaded)
|
||||
- name: "Linux (CentOS 8, dynamically-loaded OpenSSL)"
|
||||
container:
|
||||
name: centos8
|
||||
env:
|
||||
@@ -149,7 +153,7 @@ jobs:
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
SKIP_SSH_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # macOS
|
||||
- name: "macOS"
|
||||
os: macos-10.15
|
||||
env:
|
||||
CC: clang
|
||||
@@ -158,7 +162,7 @@ jobs:
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
setup-script: osx
|
||||
- # Windows amd64 Visual Studio
|
||||
- name: "Windows (amd64, Visual Studio)"
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: amd64
|
||||
@@ -166,7 +170,7 @@ jobs:
|
||||
CMAKE_OPTIONS: -A x64 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows amd64 Visual Studio (NO_MMAP)
|
||||
- name: "Windows (no mmap)"
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: amd64
|
||||
@@ -175,7 +179,7 @@ jobs:
|
||||
CMAKE_OPTIONS: -A x64 -DDEPRECATE_HARD=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows x86 Visual Studio
|
||||
- name: "Windows (x86, Visual Studio)"
|
||||
os: windows-2019
|
||||
env:
|
||||
ARCH: x86
|
||||
@@ -183,7 +187,7 @@ jobs:
|
||||
CMAKE_OPTIONS: -A Win32 -DWIN32_LEAKCHECK=ON -DDEPRECATE_HARD=ON -DUSE_SHA1=HTTPS -DUSE_BUNDLED_ZLIB=ON
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows amd64 mingw
|
||||
- name: "Windows (amd64, mingw)"
|
||||
os: windows-2019
|
||||
setup-script: mingw
|
||||
env:
|
||||
@@ -194,7 +198,7 @@ jobs:
|
||||
BUILD_PATH: D:\Temp\mingw64\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Windows x86 mingw
|
||||
- name: "Windows (x86, mingw)"
|
||||
os: windows-2019
|
||||
setup-script: mingw
|
||||
env:
|
||||
@@ -205,17 +209,17 @@ jobs:
|
||||
BUILD_PATH: D:\Temp\mingw32\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Program Files (x86)\CMake\bin
|
||||
SKIP_SSH_TESTS: true
|
||||
SKIP_NEGOTIATE_TESTS: true
|
||||
- # Bionic, GCC, OpenSSL (dynamically loaded)
|
||||
- name: "Linux (Bionic, GCC, dynamically-loaded OpenSSL)"
|
||||
container:
|
||||
name: bionic
|
||||
dockerfile: bionic
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL-Dynamic -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # Bionic, x86, Clang, OpenSSL
|
||||
- name: "Linux (x86, Bionic, Clang, OpenSSL)"
|
||||
container:
|
||||
name: bionic-x86
|
||||
dockerfile: bionic
|
||||
@@ -223,20 +227,20 @@ jobs:
|
||||
env:
|
||||
CC: clang
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # Bionic, x86, GCC, OpenSSL
|
||||
- name: "Linux (x86, Bionic, GCC, OpenSSL)"
|
||||
container:
|
||||
name: bionic-x86
|
||||
dockerfile: bionic
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_LEAK_CHECKER=valgrind -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
os: ubuntu-latest
|
||||
- # Bionic, arm32, GCC, OpenSSL
|
||||
- name: "Linux (arm32, Bionic, GCC, OpenSSL)"
|
||||
container:
|
||||
name: bionic-arm32
|
||||
dockerfile: bionic
|
||||
@@ -244,11 +248,12 @@ jobs:
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_PROXY_TESTS: true
|
||||
GITTEST_FLAKY_STAT: true
|
||||
os: ubuntu-latest
|
||||
- # Bionic, arm64, GCC, OpenSSL
|
||||
- name: "Linux (arm64, Bionic, GCC, OpenSSL)"
|
||||
container:
|
||||
name: bionic-arm64
|
||||
dockerfile: bionic
|
||||
@@ -256,11 +261,12 @@ jobs:
|
||||
env:
|
||||
CC: gcc
|
||||
CMAKE_GENERATOR: Ninja
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON
|
||||
CMAKE_OPTIONS: -DUSE_HTTPS=OpenSSL -DDEPRECATE_HARD=ON -DUSE_GSSAPI=ON -DUSE_SSH=ON
|
||||
RUN_INVASIVE_TESTS: true
|
||||
SKIP_PROXY_TESTS: true
|
||||
os: ubuntu-latest
|
||||
fail-fast: false
|
||||
name: "Build ${{ matrix.platform.name }}"
|
||||
env: ${{ matrix.platform.env }}
|
||||
runs-on: ${{ matrix.platform.os }}
|
||||
steps:
|
||||
@@ -270,7 +276,7 @@ jobs:
|
||||
path: source
|
||||
fetch-depth: 0
|
||||
- name: Set up build environment
|
||||
run: source/ci/setup-${{ matrix.platform.setup-script }}.sh
|
||||
run: source/ci/setup-${{ matrix.platform.setup-script }}-build.sh
|
||||
shell: bash
|
||||
if: matrix.platform.setup-script != ''
|
||||
- name: Setup QEMU
|
||||
@@ -304,6 +310,7 @@ jobs:
|
||||
-e CMAKE_GENERATOR \
|
||||
-e CMAKE_OPTIONS \
|
||||
-e GITTEST_NEGOTIATE_PASSWORD \
|
||||
-e GITTEST_FLAKY_STAT \
|
||||
-e PKG_CONFIG_PATH \
|
||||
-e SKIP_NEGOTIATE_TESTS \
|
||||
-e SKIP_SSH_TESTS \
|
||||
@@ -318,6 +325,10 @@ jobs:
|
||||
shell: bash
|
||||
|
||||
coverity:
|
||||
# Only run scheduled workflows on the main repository; prevents people
|
||||
# from using build minutes on their forks.
|
||||
if: github.repository == 'libgit2/libgit2'
|
||||
|
||||
name: Coverity
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
@@ -337,3 +348,32 @@ jobs:
|
||||
run: source/ci/coverity.sh
|
||||
env:
|
||||
COVERITY_TOKEN: ${{ secrets.coverity_token }}
|
||||
|
||||
codeql:
|
||||
# Only run scheduled workflows on the main repository; prevents people
|
||||
# from using build minutes on their forks.
|
||||
if: github.repository == 'libgit2/libgit2'
|
||||
|
||||
name: CodeQL
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
# Initializes the CodeQL tools for scanning.
|
||||
- name: Initialize CodeQL
|
||||
uses: github/codeql-action/init@v1
|
||||
with:
|
||||
languages: 'cpp'
|
||||
|
||||
- name: Build
|
||||
run: |
|
||||
mkdir build
|
||||
cd build
|
||||
cmake .. -DREGEX_BACKEND=pcre -DDEPRECATE_HARD=ON -DUSE_BUNDLED_ZLIB=ON
|
||||
cmake --build .
|
||||
|
||||
- name: Perform CodeQL Analysis
|
||||
uses: github/codeql-action/analyze@v1
|
||||
|
||||
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@@ -8,7 +8,7 @@
|
||||
"name": "(gdb) Launch",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/libgit2_clar",
|
||||
"program": "${workspaceFolder}/build/libgit2_tests",
|
||||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"cwd": "${fileDirname}",
|
||||
@@ -24,4 +24,4 @@
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
4
.vscode/tasks.json
vendored
4
.vscode/tasks.json
vendored
@@ -16,7 +16,7 @@
|
||||
{
|
||||
"label": "Run Tests",
|
||||
"type": "shell",
|
||||
"command": "build/libgit2_clar -v",
|
||||
"command": "build/libgit2_tests -v",
|
||||
"group": "test",
|
||||
"presentation": {
|
||||
"reveal": "always",
|
||||
@@ -24,4 +24,4 @@
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
378
CMakeLists.txt
378
CMakeLists.txt
@@ -1,306 +1,146 @@
|
||||
# CMake build script for the libgit2 project
|
||||
# libgit2: the cross-platform, linkable library implementation of git.
|
||||
# See `README.md` for build instructions.
|
||||
#
|
||||
# Building (out of source build):
|
||||
# > mkdir build && cd build
|
||||
# > cmake .. [-DSETTINGS=VALUE]
|
||||
# > cmake --build .
|
||||
#
|
||||
# Testing:
|
||||
# > ctest -V
|
||||
#
|
||||
# Install:
|
||||
# > cmake --build . --target install
|
||||
# This top-level CMakeLists.txt sets up configuration options and
|
||||
# determines which subprojects to build.
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1)
|
||||
cmake_minimum_required(VERSION 3.5.1)
|
||||
|
||||
project(libgit2 VERSION "1.3.0" LANGUAGES C)
|
||||
project(libgit2 VERSION "1.5.0" LANGUAGES C)
|
||||
|
||||
# Add find modules to the path
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${libgit2_SOURCE_DIR}/cmake/")
|
||||
|
||||
INCLUDE(CheckLibraryExists)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckSymbolExists)
|
||||
INCLUDE(CheckStructHasMember)
|
||||
INCLUDE(CheckPrototypeDefinition) # Added in CMake 3.0
|
||||
INCLUDE(AddCFlagIfSupported)
|
||||
INCLUDE(FindPkgLibraries)
|
||||
INCLUDE(FindThreads)
|
||||
INCLUDE(FindStatNsec)
|
||||
INCLUDE(Findfutimens)
|
||||
INCLUDE(GNUInstallDirs)
|
||||
INCLUDE(IdeSplitSources)
|
||||
INCLUDE(FeatureSummary)
|
||||
INCLUDE(EnableWarnings)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
|
||||
|
||||
#
|
||||
# Build options
|
||||
#
|
||||
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(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(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
|
||||
OPTION(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
|
||||
OPTION(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
OPTION(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" 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()
|
||||
# Optional subsystems
|
||||
option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
|
||||
option(BUILD_TESTS "Build Tests using the Clar suite" ON)
|
||||
option(BUILD_CLI "Build the command-line interface" ON)
|
||||
option(BUILD_EXAMPLES "Build library usage example apps" OFF)
|
||||
option(BUILD_FUZZERS "Build the fuzz targets" OFF)
|
||||
|
||||
IF (UNIX AND NOT APPLE)
|
||||
OPTION(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
|
||||
ENDIF()
|
||||
# Suggested functionality that may not be available on a per-platform basis
|
||||
option(USE_THREADS "Use threads for parallel processing when possible" ON)
|
||||
option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
|
||||
|
||||
IF (APPLE)
|
||||
OPTION(USE_ICONV "Link with and use iconv library" ON)
|
||||
ENDIF()
|
||||
# Backend selection
|
||||
option(USE_SSH "Link with libssh2 to enable SSH support" OFF)
|
||||
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" ON)
|
||||
option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
|
||||
option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
|
||||
set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
|
||||
set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
|
||||
option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
|
||||
|
||||
IF(MSVC)
|
||||
# Debugging options
|
||||
option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
|
||||
option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
|
||||
option(DEBUG_POOL "Enable debug pool allocator" OFF)
|
||||
option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
|
||||
option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
|
||||
|
||||
# Output options
|
||||
option(SONAME "Set the (SO)VERSION of the target" ON)
|
||||
set(LIBGIT2_FILENAME "git2" CACHE STRING "Name of the produced binary")
|
||||
option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
|
||||
|
||||
# Compilation options
|
||||
option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
|
||||
|
||||
if(UNIX)
|
||||
# NTLM client requires crypto libraries from the system HTTPS stack
|
||||
if(NOT USE_HTTPS)
|
||||
option(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF)
|
||||
else()
|
||||
option(USE_NTLMCLIENT "Enable NTLM support on Unix." ON)
|
||||
endif()
|
||||
|
||||
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)
|
||||
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()
|
||||
option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
|
||||
|
||||
|
||||
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 leak checking using the debugging C runtime.
|
||||
OPTION(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
|
||||
ENDIF()
|
||||
option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
|
||||
endif()
|
||||
|
||||
IF (DEPRECATE_HARD)
|
||||
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
|
||||
ENDIF()
|
||||
if(WIN32)
|
||||
# By default, libgit2 is built with WinHTTP. To use the built-in
|
||||
# HTTP transport, invoke CMake with the "-DUSE_WINHTTP=OFF" argument.
|
||||
option(USE_WINHTTP "Use Win32 WinHTTP routines" ON)
|
||||
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()
|
||||
if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
|
||||
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}")
|
||||
# Modules
|
||||
|
||||
# /GF - String pooling
|
||||
# /MP - Parallel build
|
||||
SET(CMAKE_C_FLAGS "/GF /MP /nologo ${CMAKE_C_FLAGS}")
|
||||
include(CheckLibraryExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckStructHasMember)
|
||||
include(CheckPrototypeDefinition)
|
||||
include(AddCFlagIfSupported)
|
||||
include(FindPkgLibraries)
|
||||
include(FindThreads)
|
||||
include(FindStatNsec)
|
||||
include(Findfutimens)
|
||||
include(GNUInstallDirs)
|
||||
include(IdeSplitSources)
|
||||
include(FeatureSummary)
|
||||
include(EnableWarnings)
|
||||
include(DefaultCFlags)
|
||||
|
||||
# /Gd - explicitly set cdecl calling convention
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gd")
|
||||
|
||||
IF (NOT (MSVC_VERSION LESS 1900))
|
||||
# /guard:cf - Enable Control Flow Guard
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
|
||||
ENDIF()
|
||||
#
|
||||
# Subdirectories
|
||||
#
|
||||
|
||||
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()
|
||||
add_subdirectory(src)
|
||||
|
||||
IF (WIN32_LEAKCHECK)
|
||||
SET(GIT_WIN32_LEAKCHECK 1)
|
||||
SET(CRT_FLAG_DEBUG "${CRT_FLAG_DEBUG}")
|
||||
SET(CMAKE_C_STANDARD_LIBRARIES "${CMAKE_C_STANDARD_LIBRARIES} Dbghelp.lib")
|
||||
ENDIF()
|
||||
if(BUILD_TESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(tests)
|
||||
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}")
|
||||
if(BUILD_EXAMPLES)
|
||||
add_subdirectory(examples)
|
||||
endif()
|
||||
|
||||
# /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}")
|
||||
|
||||
IF (NOT (MSVC_VERSION LESS 1900))
|
||||
# /GUARD:CF - Enable Control Flow Guard
|
||||
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
|
||||
ENDIF()
|
||||
|
||||
# /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(documentation-deprecated-sync)
|
||||
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)
|
||||
enable_warnings(c11-extensions)
|
||||
enable_warnings(c99-c11-compat)
|
||||
|
||||
# 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)
|
||||
if(BUILD_FUZZERS)
|
||||
if((BUILD_TESTS OR BUILD_EXAMPLES) AND NOT USE_STANDALONE_FUZZERS)
|
||||
message(FATAL_ERROR "Cannot build the fuzzer and the tests or examples together")
|
||||
endif()
|
||||
ENDIF()
|
||||
add_subdirectory(fuzzers)
|
||||
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()
|
||||
# Export for people who use us as a dependency
|
||||
|
||||
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 ()
|
||||
if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
|
||||
set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
|
||||
set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
ADD_SUBDIRECTORY(src)
|
||||
|
||||
# Tests
|
||||
IF (NOT MSVC)
|
||||
IF (NOT BUILD_SHARED_LIBS)
|
||||
SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
ENDIF()
|
||||
ENDIF ()
|
||||
# Summary
|
||||
|
||||
IF (BUILD_CLAR)
|
||||
ENABLE_TESTING()
|
||||
ADD_SUBDIRECTORY(tests)
|
||||
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:")
|
||||
feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
|
||||
feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
|
||||
|
||||
95
COPYING
95
COPYING
@@ -406,30 +406,35 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
The regex library (deps/regex/) is licensed under the GNU LGPL
|
||||
(available at the end of this file).
|
||||
The bundled PCRE implementation (deps/pcre/) is licensed under the BSD
|
||||
license.
|
||||
|
||||
Definitions for data structures and routines for the regular
|
||||
expression library.
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
Copyright (C) 1985,1989-93,1995-98,2000,2001,2002,2003,2005,2006,2008
|
||||
Free Software Foundation, Inc.
|
||||
This file is part of the GNU C Library.
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
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.
|
||||
* 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.
|
||||
|
||||
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
|
||||
Lesser General Public License for more details.
|
||||
* Neither the name of the University of Cambridge nor the name of Google
|
||||
Inc. nor the names of their contributors may be used to endorse or
|
||||
promote products derived from this software without specific prior
|
||||
written permission.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the GNU C Library; if not, write to the Free
|
||||
Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
02110-1301 USA.
|
||||
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.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
@@ -1127,3 +1132,55 @@ 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 xoroshiro256** implementation is licensed in the public domain:
|
||||
|
||||
Written in 2018 by David Blackman and Sebastiano Vigna (vigna@acm.org)
|
||||
|
||||
To the extent possible under law, the author has dedicated all copyright
|
||||
and related and neighboring rights to this software to the public domain
|
||||
worldwide. This software is distributed without any warranty.
|
||||
|
||||
See <http://creativecommons.org/publicdomain/zero/1.0/>.
|
||||
|
||||
----------------------------------------------------------------------
|
||||
|
||||
The built-in SHA256 support (src/hash/rfc6234) is taken from RFC 6234
|
||||
under the following license:
|
||||
|
||||
Copyright (c) 2011 IETF Trust and the persons identified as
|
||||
authors of the code. 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 Internet Society, IETF or IETF Trust, nor
|
||||
the names of specific 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.
|
||||
|
||||
|
||||
22
README.md
22
README.md
@@ -4,8 +4,8 @@ libgit2 - the Git linkable library
|
||||
| Build Status | |
|
||||
| ------------ | - |
|
||||
| **main** branch CI builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush) |
|
||||
| **v1.2 branch** CI builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.2) |
|
||||
| **v1.1 branch** CI builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.1) |
|
||||
| **v1.4 branch** CI builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.4) |
|
||||
| **v1.3 branch** CI builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22CI+Build%22+event%3Apush+branch%3Amaint%2Fv1.3) |
|
||||
| **Nightly** builds | [](https://github.com/libgit2/libgit2/actions?query=workflow%3A%22Nightly+Build%22) [](https://scan.coverity.com/projects/639) |
|
||||
|
||||
`libgit2` is a portable, pure C implementation of the Git core methods
|
||||
@@ -236,18 +236,18 @@ Once built, you can run the tests from the `build` directory with the command
|
||||
|
||||
Alternatively you can run the test suite directly using,
|
||||
|
||||
$ ./libgit2_clar
|
||||
$ ./libgit2_tests
|
||||
|
||||
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
|
||||
$ ./libgit2_tests -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/main/tests/index/racy.c#L23):
|
||||
|
||||
$ ./libgit2_clar -sindex::racy::diff
|
||||
$ ./libgit2_tests -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
|
||||
@@ -278,8 +278,8 @@ The following CMake variables are declared:
|
||||
- `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)
|
||||
- `BUILD_TESTS`: Build the unit and integration test suites (defaults to ON)
|
||||
- `USE_THREADS`: Build libgit2 with threading support (defaults to ON)
|
||||
|
||||
To list all build options and their current value, you can do the
|
||||
following:
|
||||
@@ -301,6 +301,8 @@ compiler and linker. These flags are rarely used but can be useful for
|
||||
- `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
|
||||
- `LINK_WITH_STATIC_LIBRARIES`: Link only with static versions of
|
||||
system libraries
|
||||
|
||||
MacOS X
|
||||
-------
|
||||
@@ -390,10 +392,10 @@ Here are the bindings to libgit2 that are currently available:
|
||||
* parrot-libgit2 <https://github.com/letolabs/parrot-libgit2>
|
||||
* Perl
|
||||
* Git-Raw <https://github.com/jacquesg/p5-Git-Raw>
|
||||
* Pharo Smalltalk
|
||||
* libgit2-pharo-bindings <https://github.com/pharo-vcs/libgit2-pharo-bindings>
|
||||
* PHP
|
||||
* php-git <https://github.com/libgit2/php-git>
|
||||
* PowerShell
|
||||
* PSGit <https://github.com/PoshCode/PSGit>
|
||||
* Python
|
||||
* pygit2 <https://github.com/libgit2/pygit2>
|
||||
* R
|
||||
@@ -405,6 +407,8 @@ Here are the bindings to libgit2 that are currently available:
|
||||
* git2-rs <https://github.com/rust-lang/git2-rs>
|
||||
* Swift
|
||||
* SwiftGit2 <https://github.com/SwiftGit2/SwiftGit2>
|
||||
* Tcl
|
||||
* lg2 <https://github.com/apnadkarni/tcl-libgit2>
|
||||
* Vala
|
||||
* libgit2.vapi <https://github.com/apmasell/vapis/blob/master/libgit2.vapi>
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ echo "##########################################################################
|
||||
echo "## Configuring build environment"
|
||||
echo "##############################################################################"
|
||||
|
||||
echo cmake -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\"
|
||||
echo "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G \"${CMAKE_GENERATOR}\" ${CMAKE_OPTIONS} -S \"${SOURCE_DIR}\"
|
||||
env PATH="${BUILD_PATH}" "${CMAKE}" -DENABLE_WERROR=ON -DBUILD_EXAMPLES=ON -DBUILD_FUZZERS=ON -DUSE_STANDALONE_FUZZERS=ON -G "${CMAKE_GENERATOR}" ${CMAKE_OPTIONS} -S "${SOURCE_DIR}"
|
||||
|
||||
echo ""
|
||||
@@ -69,10 +69,11 @@ echo "##########################################################################
|
||||
|
||||
# Determine parallelism; newer cmake supports `--build --parallel` but
|
||||
# we cannot yet rely on that.
|
||||
if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" -a "${CORES}" != "" ]; then
|
||||
if [ "${CMAKE_GENERATOR}" = "Unix Makefiles" -a "${CORES}" != "" -a "${CMAKE_BUILD_OPTIONS}" = "" ]; then
|
||||
BUILDER=(make -j ${CORES})
|
||||
else
|
||||
BUILDER=("${CMAKE}" --build .)
|
||||
BUILDER=("${CMAKE}" --build . ${CMAKE_BUILD_OPTIONS})
|
||||
fi
|
||||
|
||||
echo "${BUILDER[@]}"
|
||||
env PATH="${BUILD_PATH}" "${BUILDER[@]}"
|
||||
|
||||
@@ -28,17 +28,22 @@ RUN apt-get update && \
|
||||
|
||||
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 && \
|
||||
curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \
|
||||
tar -xz && \
|
||||
cd mbedtls-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
|
||||
rm -rf mbedtls-mbedtls-2.16.2
|
||||
|
||||
FROM mbedtls AS adduser
|
||||
RUN useradd --shell /bin/bash libgit2 --create-home
|
||||
ARG UID=""
|
||||
ARG GID=""
|
||||
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
|
||||
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
|
||||
groupadd ${GROUP_ARG} libgit2 && \
|
||||
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2
|
||||
|
||||
FROM adduser AS configure
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
@@ -48,7 +48,12 @@ RUN cd /tmp && \
|
||||
rm -rf cmake-3.21.1
|
||||
|
||||
FROM cmake AS adduser
|
||||
RUN useradd --shell /bin/bash libgit2 --create-home
|
||||
ARG UID=""
|
||||
ARG GID=""
|
||||
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
|
||||
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
|
||||
groupadd ${GROUP_ARG} libgit2 && \
|
||||
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2
|
||||
|
||||
FROM adduser AS configure
|
||||
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
ARG BASE=centos:8
|
||||
|
||||
FROM ${BASE} AS yum
|
||||
FROM ${BASE} AS stream
|
||||
RUN dnf -y --disablerepo '*' --enablerepo=extras swap centos-linux-repos centos-stream-repos && \
|
||||
dnf -y distro-sync
|
||||
|
||||
FROM stream AS yum
|
||||
RUN yum install -y \
|
||||
which \
|
||||
bzip2 \
|
||||
@@ -40,7 +44,12 @@ RUN cd /tmp && \
|
||||
rm -rf valgrind-3.15.0
|
||||
|
||||
FROM valgrind AS adduser
|
||||
RUN useradd --shell /bin/bash libgit2 --create-home
|
||||
ARG UID=""
|
||||
ARG GID=""
|
||||
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
|
||||
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
|
||||
groupadd ${GROUP_ARG} libgit2 && \
|
||||
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2
|
||||
|
||||
FROM adduser AS configure
|
||||
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig
|
||||
|
||||
@@ -32,9 +32,9 @@ RUN apt-get update && \
|
||||
|
||||
FROM apt AS mbedtls
|
||||
RUN cd /tmp && \
|
||||
curl --location --silent --show-error https://tls.mbed.org/download/mbedtls-2.16.2-apache.tgz | \
|
||||
curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \
|
||||
tar -xz && \
|
||||
cd mbedtls-2.16.2 && \
|
||||
cd mbedtls-mbedtls-2.16.2 && \
|
||||
scripts/config.pl unset MBEDTLS_AESNI_C && \
|
||||
scripts/config.pl set MBEDTLS_MD4_C 1 && \
|
||||
mkdir build build-msan && \
|
||||
@@ -45,7 +45,7 @@ RUN cd /tmp && \
|
||||
CC=clang-10 CFLAGS="-fPIC" cmake -G Ninja -DENABLE_PROGRAMS=OFF -DENABLE_TESTING=OFF -DUSE_SHARED_MBEDTLS_LIBRARY=ON -DUSE_STATIC_MBEDTLS_LIBRARY=OFF -DCMAKE_BUILD_TYPE=MemSanDbg -DCMAKE_INSTALL_PREFIX=/usr/local/msan .. && \
|
||||
ninja install && \
|
||||
cd .. && \
|
||||
rm -rf mbedtls-2.16.2
|
||||
rm -rf mbedtls-mbedtls-2.16.2
|
||||
|
||||
FROM mbedtls AS libssh2
|
||||
RUN cd /tmp && \
|
||||
@@ -73,7 +73,13 @@ RUN cd /tmp && \
|
||||
rm -rf valgrind-3.15.0
|
||||
|
||||
FROM valgrind AS adduser
|
||||
RUN useradd --shell /bin/bash libgit2 --create-home
|
||||
ARG UID=""
|
||||
ARG GID=""
|
||||
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
|
||||
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
|
||||
groupadd ${GROUP_ARG} libgit2 && \
|
||||
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2
|
||||
|
||||
|
||||
FROM adduser AS configure
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
@@ -30,14 +30,14 @@ RUN apt-get update && \
|
||||
|
||||
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 && \
|
||||
curl --location --silent --show-error https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-2.16.2.tar.gz | \
|
||||
tar -xz && \
|
||||
cd mbedtls-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
|
||||
rm -rf mbedtls-mbedtls-2.16.2
|
||||
|
||||
FROM mbedtls AS libssh2
|
||||
RUN cd /tmp && \
|
||||
@@ -60,7 +60,13 @@ RUN cd /tmp && \
|
||||
rm -rf valgrind-3.15.0
|
||||
|
||||
FROM valgrind AS adduser
|
||||
RUN useradd --shell /bin/bash libgit2 --create-home
|
||||
ARG UID=""
|
||||
ARG GID=""
|
||||
RUN if [ "${UID}" != "" ]; then USER_ARG="--uid ${UID}"; fi && \
|
||||
if [ "${GID}" != "" ]; then GROUP_ARG="--gid ${GID}"; fi && \
|
||||
groupadd ${GROUP_ARG} libgit2 && \
|
||||
useradd ${USER_ARG} --gid libgit2 --shell /bin/bash --create-home libgit2
|
||||
|
||||
|
||||
FROM adduser AS configure
|
||||
RUN mkdir /var/run/sshd
|
||||
|
||||
@@ -37,9 +37,13 @@ DOCKER_REGISTRY_CONTAINER_SHA="${DOCKER_REGISTRY_CONTAINER}:${DOCKER_SHA}"
|
||||
echo "docker-registry-container-sha=${DOCKER_REGISTRY_CONTAINER_SHA}" >> $GITHUB_ENV
|
||||
echo "docker-registry-container-latest=${DOCKER_REGISTRY_CONTAINER}:latest" >> $GITHUB_ENV
|
||||
|
||||
echo "::: logging in to ${DOCKER_REGISTRY} as ${GITHUB_ACTOR}"
|
||||
|
||||
exists="true"
|
||||
docker login https://${DOCKER_REGISTRY} -u ${GITHUB_ACTOR} -p ${GITHUB_TOKEN} || exists="false"
|
||||
|
||||
echo "::: pulling ${DOCKER_REGISTRY_CONTAINER_SHA}"
|
||||
|
||||
if [ "${exists}" != "false" ]; then
|
||||
docker pull ${DOCKER_REGISTRY_CONTAINER_SHA} || exists="false"
|
||||
fi
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#!/bin/sh -e
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
echo "##############################################################################"
|
||||
echo "## Downloading mingw"
|
||||
6
ci/setup-osx-benchmark.sh
Executable file
6
ci/setup-osx-benchmark.sh
Executable file
@@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
brew update
|
||||
brew install hyperfine
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -x
|
||||
set -ex
|
||||
|
||||
brew update
|
||||
brew install pkgconfig zlib curl openssl libssh2 ninja
|
||||
20
ci/setup-ubuntu-benchmark.sh
Executable file
20
ci/setup-ubuntu-benchmark.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
sudo apt-get update
|
||||
sudo apt-get install -y --no-install-recommends \
|
||||
cargo \
|
||||
cmake \
|
||||
gcc \
|
||||
git \
|
||||
krb5-user \
|
||||
libkrb5-dev \
|
||||
libssl-dev \
|
||||
libz-dev \
|
||||
make \
|
||||
ninja-build \
|
||||
pkgconf
|
||||
|
||||
wget https://github.com/sharkdp/hyperfine/releases/download/v1.12.0/hyperfine_1.12.0_amd64.deb
|
||||
sudo dpkg -i hyperfine_1.12.0_amd64.deb
|
||||
9
ci/setup-win32-benchmark.sh
Executable file
9
ci/setup-win32-benchmark.sh
Executable file
@@ -0,0 +1,9 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -ex
|
||||
|
||||
choco install hyperfine zip
|
||||
|
||||
CHOCO_PATH=$(mktemp -d)
|
||||
curl -L https://github.com/ethomson/PurgeStandbyList/releases/download/v1.0/purgestandbylist.1.0.0.nupkg -o "${CHOCO_PATH}/purgestandbylist.1.0.0.nupkg"
|
||||
choco install purgestandbylist -s $(cygpath -w "${CHOCO_PATH}")
|
||||
55
ci/test.sh
55
ci/test.sh
@@ -83,7 +83,7 @@ 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 init --bare "${GITDAEMON_DIR}/test.git" >/dev/null
|
||||
git daemon --listen=localhost --export-all --enable=receive-pack --base-path="${GITDAEMON_DIR}" "${GITDAEMON_DIR}" 2>/dev/null &
|
||||
GITDAEMON_PID=$!
|
||||
disown $GITDAEMON_PID
|
||||
@@ -101,8 +101,8 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
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
|
||||
if [ -z "$SKIP_NTLM_TESTS" -o -z "$SKIP_ONLINE_TESTS" ]; then
|
||||
curl --location --silent --show-error https://github.com/ethomson/poxygit/releases/download/v0.5.1/poxygit-0.5.1.jar >poxygit.jar
|
||||
|
||||
echo ""
|
||||
echo "Starting HTTP server..."
|
||||
@@ -112,10 +112,11 @@ if [ -z "$SKIP_NTLM_TESTS" ]; then
|
||||
fi
|
||||
|
||||
if [ -z "$SKIP_SSH_TESTS" ]; then
|
||||
echo ""
|
||||
echo "Starting ssh daemon..."
|
||||
HOME=`mktemp -d ${TMPDIR}/home.XXXXXXXX`
|
||||
SSHD_DIR=`mktemp -d ${TMPDIR}/sshd.XXXXXXXX`
|
||||
git init --bare "${SSHD_DIR}/test.git"
|
||||
git init --bare "${SSHD_DIR}/test.git" >/dev/null
|
||||
cat >"${SSHD_DIR}/sshd_config" <<-EOF
|
||||
Port 2222
|
||||
ListenAddress 0.0.0.0
|
||||
@@ -158,10 +159,18 @@ fi
|
||||
if [ -z "$SKIP_OFFLINE_TESTS" ]; then
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running (offline) tests"
|
||||
echo "## Running core tests"
|
||||
echo "##############################################################################"
|
||||
|
||||
echo ""
|
||||
echo "Running libgit2 integration (offline) tests"
|
||||
echo ""
|
||||
run_test offline
|
||||
|
||||
echo ""
|
||||
echo "Running utility tests"
|
||||
echo ""
|
||||
run_test util
|
||||
fi
|
||||
|
||||
if [ -n "$RUN_INVASIVE_TESTS" ]; then
|
||||
@@ -185,19 +194,21 @@ if [ -z "$SKIP_ONLINE_TESTS" ]; then
|
||||
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running (online) tests"
|
||||
echo "## Running networking (online) tests"
|
||||
echo "##############################################################################"
|
||||
|
||||
export GITTEST_FLAKY_RETRY=5
|
||||
export GITTEST_REMOTE_REDIRECT_INITIAL="http://localhost:9000/initial-redirect/libgit2/TestGitRepository"
|
||||
export GITTEST_REMOTE_REDIRECT_SUBSEQUENT="http://localhost:9000/subsequent-redirect/libgit2/TestGitRepository"
|
||||
run_test online
|
||||
unset GITTEST_FLAKY_RETRY
|
||||
unset GITTEST_REMOTE_REDIRECT_INITIAL
|
||||
unset GITTEST_REMOTE_REDIRECT_SUBSEQUENT
|
||||
|
||||
# Run the online tests that immutably change global state separately
|
||||
# to avoid polluting the test environment.
|
||||
echo ""
|
||||
echo "##############################################################################"
|
||||
echo "## Running (online_customcert) tests"
|
||||
echo "##############################################################################"
|
||||
echo "Running custom certificate (online_customcert) tests"
|
||||
echo ""
|
||||
|
||||
run_test online_customcert
|
||||
fi
|
||||
|
||||
@@ -231,9 +242,7 @@ if [ -z "$SKIP_PROXY_TESTS" ]; then
|
||||
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
|
||||
@@ -299,18 +308,28 @@ if [ -z "$SKIP_NEGOTIATE_TESTS" -a -n "$GITTEST_NEGOTIATE_PASSWORD" ]; then
|
||||
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}"
|
||||
|
||||
echo ""
|
||||
echo "Running ssh tests"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="ssh://localhost:2222/$SSHD_DIR/test.git"
|
||||
run_test ssh
|
||||
unset GITTEST_REMOTE_URL
|
||||
|
||||
echo ""
|
||||
echo "Running ssh tests (scp-style paths)"
|
||||
echo ""
|
||||
|
||||
export GITTEST_REMOTE_URL="[localhost:2222]:$SSHD_DIR/test.git"
|
||||
run_test ssh
|
||||
unset GITTEST_REMOTE_URL
|
||||
|
||||
unset GITTEST_REMOTE_USER
|
||||
unset GITTEST_REMOTE_SSH_KEY
|
||||
unset GITTEST_REMOTE_SSH_PUBKEY
|
||||
|
||||
@@ -3,28 +3,28 @@
|
||||
# <flag> - the compiler flag to test
|
||||
# This internally calls the CHECK_C_COMPILER_FLAG macro.
|
||||
|
||||
INCLUDE(CheckCCompilerFlag)
|
||||
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)
|
||||
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()
|
||||
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)
|
||||
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()
|
||||
if(IS_${UPCASE_PRETTY}_SUPPORTED)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${_FLAG}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
7
cmake/AddClarTest.cmake
Normal file
7
cmake/AddClarTest.cmake
Normal file
@@ -0,0 +1,7 @@
|
||||
function(ADD_CLAR_TEST project name)
|
||||
if(NOT USE_LEAK_CHECKER STREQUAL "OFF")
|
||||
add_test(${name} "${PROJECT_SOURCE_DIR}/script/${USE_LEAK_CHECKER}.sh" "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
|
||||
else()
|
||||
add_test(${name} "${PROJECT_BINARY_DIR}/${project}" ${ARGN})
|
||||
endif()
|
||||
endfunction(ADD_CLAR_TEST)
|
||||
154
cmake/DefaultCFlags.cmake
Normal file
154
cmake/DefaultCFlags.cmake
Normal file
@@ -0,0 +1,154 @@
|
||||
# Platform specific compilation flags
|
||||
if(MSVC)
|
||||
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(NOT (MSVC_VERSION LESS 1900))
|
||||
# /guard:cf - Enable Control Flow Guard
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /guard:cf")
|
||||
endif()
|
||||
|
||||
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(WIN32_LEAKCHECK)
|
||||
set(GIT_WIN32_LEAKCHECK 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}")
|
||||
|
||||
if(NOT (MSVC_VERSION LESS 1900))
|
||||
# /GUARD:CF - Enable Control Flow Guard
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /GUARD:CF")
|
||||
endif()
|
||||
|
||||
# /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()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS AND LINK_WITH_STATIC_LIBRARIES)
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
|
||||
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(documentation-deprecated-sync)
|
||||
disable_warnings(missing-field-initializers)
|
||||
enable_warnings(missing-declarations)
|
||||
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)
|
||||
enable_warnings(c11-extensions)
|
||||
enable_warnings(c99-c11-compat)
|
||||
|
||||
# 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()
|
||||
endif()
|
||||
|
||||
# Ensure that MinGW provides the correct header files.
|
||||
if(WIN32 AND NOT CYGWIN)
|
||||
add_definitions(-DWIN32 -D_WIN32_WINNT=0x0600)
|
||||
endif()
|
||||
@@ -1,15 +1,15 @@
|
||||
MACRO(ENABLE_WARNINGS flag)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-W${flag})
|
||||
ENDMACRO()
|
||||
macro(ENABLE_WARNINGS flag)
|
||||
add_c_flag_if_supported(-W${flag})
|
||||
endmacro()
|
||||
|
||||
MACRO(DISABLE_WARNINGS flag)
|
||||
ADD_C_FLAG_IF_SUPPORTED(-Wno-${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()
|
||||
if(ENABLE_WERROR)
|
||||
if(MSVC)
|
||||
add_compile_options(-WX)
|
||||
else()
|
||||
add_c_flag_if_supported(-Werror)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -6,21 +6,21 @@
|
||||
# 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 ()
|
||||
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()
|
||||
if(CoreFoundation_FIND_REQUIRED AND NOT COREFOUNDATION_FOUND)
|
||||
message(FATAL_ERROR "CoreFoundation not found")
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
mark_as_advanced(
|
||||
COREFOUNDATION_INCLUDE_DIR
|
||||
COREFOUNDATION_LIBRARIES
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
# 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_MIT - set to TRUE 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
|
||||
@@ -25,300 +25,184 @@
|
||||
#
|
||||
|
||||
find_path(GSSAPI_ROOT_DIR
|
||||
NAMES
|
||||
include/gssapi.h
|
||||
include/gssapi/gssapi.h
|
||||
HINTS
|
||||
${_GSSAPI_ROOT_HINTS}
|
||||
PATHS
|
||||
${_GSSAPI_ROOT_PATHS}
|
||||
)
|
||||
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(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(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_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()
|
||||
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()
|
||||
# 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(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()
|
||||
|
||||
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)
|
||||
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()
|
||||
|
||||
find_path(GSSAPI_INCLUDE_DIR
|
||||
NAMES
|
||||
gssapi.h
|
||||
gssapi/gssapi.h
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/include
|
||||
${_GSSAPI_INCLUDEDIR}
|
||||
)
|
||||
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}
|
||||
)
|
||||
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(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(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}
|
||||
)
|
||||
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(GSSAPI_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${KRB5_LIBRARY}
|
||||
)
|
||||
endif (KRB5_LIBRARY)
|
||||
if(KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (K5CRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${K5CRYPTO_LIBRARY}
|
||||
)
|
||||
endif (K5CRYPTO_LIBRARY)
|
||||
if(K5CRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${K5CRYPTO_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${COM_ERR_LIBRARY}
|
||||
)
|
||||
endif (COM_ERR_LIBRARY)
|
||||
endif (GSSAPI_FLAVOR_MIT)
|
||||
if(COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (GSSAPI_FLAVOR_HEIMDAL)
|
||||
find_library(GSSAPI_LIBRARY
|
||||
NAMES
|
||||
gssapi
|
||||
PATHS
|
||||
${GSSAPI_ROOT_DIR}/lib
|
||||
${_GSSAPI_LIBDIR}
|
||||
)
|
||||
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(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(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(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(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(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(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(WIND_LIBRARY
|
||||
NAMES wind
|
||||
PATHS ${GSSAPI_ROOT_DIR}/lib ${_GSSAPI_LIBDIR})
|
||||
|
||||
find_library(ROKEN_LIBRARY
|
||||
NAMES
|
||||
roken
|
||||
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(GSSAPI_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${GSSAPI_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${KRB5_LIBRARY}
|
||||
)
|
||||
endif (KRB5_LIBRARY)
|
||||
if(KRB5_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${KRB5_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (HCRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HCRYPTO_LIBRARY}
|
||||
)
|
||||
endif (HCRYPTO_LIBRARY)
|
||||
if(HCRYPTO_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HCRYPTO_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${COM_ERR_LIBRARY}
|
||||
)
|
||||
endif (COM_ERR_LIBRARY)
|
||||
if(COM_ERR_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${COM_ERR_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (HEIMNTLM_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HEIMNTLM_LIBRARY}
|
||||
)
|
||||
endif (HEIMNTLM_LIBRARY)
|
||||
if(HEIMNTLM_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HEIMNTLM_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (HX509_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${HX509_LIBRARY}
|
||||
)
|
||||
endif (HX509_LIBRARY)
|
||||
if(HX509_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${HX509_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (ASN1_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${ASN1_LIBRARY}
|
||||
)
|
||||
endif (ASN1_LIBRARY)
|
||||
if(ASN1_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${ASN1_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (WIND_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${WIND_LIBRARY}
|
||||
)
|
||||
endif (WIND_LIBRARY)
|
||||
if(WIND_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY})
|
||||
endif()
|
||||
|
||||
if (ROKEN_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES
|
||||
${GSSAPI_LIBRARIES}
|
||||
${WIND_LIBRARY}
|
||||
)
|
||||
endif (ROKEN_LIBRARY)
|
||||
endif (GSSAPI_FLAVOR_HEIMDAL)
|
||||
if(ROKEN_LIBRARY)
|
||||
set(GSSAPI_LIBRARIES ${GSSAPI_LIBRARIES} ${WIND_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
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)
|
||||
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)
|
||||
|
||||
@@ -7,21 +7,21 @@
|
||||
# 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 ()
|
||||
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()
|
||||
if(GSS_FIND_REQUIRED AND NOT GSSFRAMEWORK_FOUND)
|
||||
message(FATAL_ERROR "CoreFoundation not found")
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
mark_as_advanced(
|
||||
GSSFRAMEWORK_INCLUDE_DIR
|
||||
GSSFRAMEWORK_LIBRARIES
|
||||
GSSFRAMEWORK_LDFLAGS
|
||||
|
||||
@@ -10,30 +10,30 @@
|
||||
# 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)
|
||||
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()
|
||||
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)
|
||||
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)
|
||||
mark_as_advanced(HTTP_PARSER_INCLUDE_DIR HTTP_PARSER_LIBRARY)
|
||||
|
||||
# Set standard variables
|
||||
IF (HTTP_PARSER_FOUND)
|
||||
SET(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
|
||||
if(HTTP_PARSER_FOUND)
|
||||
set(HTTP_PARSER_LIBRARIES ${HTTP_PARSER_LIBRARY})
|
||||
set(HTTP_PARSER_INCLUDE_DIRS ${HTTP_PARSER_INCLUDE_DIR})
|
||||
ENDIF()
|
||||
endif()
|
||||
@@ -6,40 +6,40 @@
|
||||
# ICONV_LIBRARIES - Link these to use Iconv
|
||||
#
|
||||
|
||||
IF(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
if(ICONV_INCLUDE_DIR AND ICONV_LIBRARIES)
|
||||
# Already in cache, be silent
|
||||
SET(ICONV_FIND_QUIETLY TRUE)
|
||||
ENDIF()
|
||||
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)
|
||||
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)
|
||||
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}")
|
||||
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()
|
||||
if(NOT ICONV_FIND_QUIETLY)
|
||||
message(STATUS "Found Iconv: ${ICONV_LIBRARIES}")
|
||||
endif()
|
||||
else()
|
||||
if(Iconv_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find Iconv")
|
||||
endif(Iconv_FIND_REQUIRED)
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
mark_as_advanced(
|
||||
ICONV_INCLUDE_DIR
|
||||
ICONV_LIBRARIES
|
||||
)
|
||||
|
||||
@@ -2,12 +2,12 @@
|
||||
# LIBSSH2_INCLUDE_DIR - the libssh2 include directory
|
||||
# LIBSSH2_LIBRARY - the libssh2 library name
|
||||
|
||||
FIND_PATH(LIBSSH2_INCLUDE_DIR libssh2.h)
|
||||
find_path(LIBSSH2_INCLUDE_DIR libssh2.h)
|
||||
|
||||
FIND_LIBRARY(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
|
||||
find_library(LIBSSH2_LIBRARY NAMES ssh2 libssh2)
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibSSH2
|
||||
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
|
||||
REQUIRED_VARS LIBSSH2_LIBRARY LIBSSH2_INCLUDE_DIR)
|
||||
|
||||
MARK_AS_ADVANCED(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
|
||||
mark_as_advanced(LIBSSH2_INCLUDE_DIR LIBSSH2_LIBRARY)
|
||||
|
||||
@@ -16,23 +16,22 @@
|
||||
# PCRE_FOUND - True if pcre found.
|
||||
|
||||
# Look for the header file.
|
||||
FIND_PATH(PCRE_INCLUDE_DIR NAMES pcreposix.h)
|
||||
find_path(PCRE_INCLUDE_DIR NAMES pcre.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PCRE_LIBRARY NAMES pcre)
|
||||
FIND_LIBRARY(PCRE_POSIX_LIBRARY NAMES pcreposix)
|
||||
find_library(PCRE_LIBRARY NAMES pcre)
|
||||
|
||||
# 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)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(PCRE DEFAULT_MSG PCRE_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)
|
||||
if(PCRE_FOUND)
|
||||
set(PCRE_LIBRARIES ${PCRE_LIBRARY})
|
||||
set(PCRE_INCLUDE_DIRS ${PCRE_INCLUDE_DIR})
|
||||
else(PCRE_FOUND)
|
||||
set(PCRE_LIBRARIES)
|
||||
set(PCRE_INCLUDE_DIRS)
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
|
||||
mark_as_advanced(PCRE_INCLUDE_DIRS PCRE_LIBRARIES)
|
||||
|
||||
@@ -16,22 +16,22 @@
|
||||
# PCRE2_FOUND - True if pcre found.
|
||||
|
||||
# Look for the header file.
|
||||
FIND_PATH(PCRE2_INCLUDE_DIR NAMES pcre2posix.h)
|
||||
find_path(PCRE2_INCLUDE_DIR NAMES pcre2.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(PCRE2_LIBRARY NAMES pcre2-8)
|
||||
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)
|
||||
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)
|
||||
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()
|
||||
|
||||
MARK_AS_ADVANCED(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
|
||||
mark_as_advanced(PCRE2_INCLUDE_DIRS PCRE2_LIBRARIES)
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
INCLUDE(FindPkgConfig)
|
||||
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()
|
||||
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)
|
||||
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()
|
||||
|
||||
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)
|
||||
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()
|
||||
message(STATUS " Resolved libraries: ${RESOLVED_LIBRARIES}")
|
||||
endfunction()
|
||||
|
||||
@@ -7,22 +7,22 @@
|
||||
# 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 ()
|
||||
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()
|
||||
if(Security_FIND_REQUIRED AND NOT SECURITY_FOUND)
|
||||
message(FATAL_ERROR "Security not found")
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
mark_as_advanced(
|
||||
SECURITY_INCLUDE_DIR
|
||||
SECURITY_LIBRARIES
|
||||
)
|
||||
|
||||
@@ -1,26 +1,20 @@
|
||||
INCLUDE(FeatureSummary)
|
||||
include(FeatureSummary)
|
||||
|
||||
CHECK_STRUCT_HAS_MEMBER ("struct stat" st_mtim "sys/types.h;sys/stat.h"
|
||||
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"
|
||||
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
|
||||
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
|
||||
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
|
||||
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()
|
||||
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")
|
||||
add_feature_info(nanoseconds USE_NSEC "support nanosecond precision file mtimes and ctimes")
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
INCLUDE(EnableWarnings)
|
||||
include(EnableWarnings)
|
||||
|
||||
IF (APPLE)
|
||||
if(APPLE)
|
||||
# We cannot simply CHECK_FUNCTION_EXISTS on macOS because
|
||||
# MACOSX_DEPLOYMENT_TARGET may be set to a version in the past
|
||||
# that doesn't have futimens. Instead we need to enable warnings
|
||||
# as errors, then check for the symbol existing in `sys/stat.h`,
|
||||
# then reset warnings as errors.
|
||||
ENABLE_WARNINGS(error)
|
||||
CHECK_SYMBOL_EXISTS(futimens sys/stat.h HAVE_FUTIMENS)
|
||||
DISABLE_WARNINGS(error)
|
||||
ELSE ()
|
||||
CHECK_FUNCTION_EXISTS(futimens HAVE_FUTIMENS)
|
||||
ENDIF ()
|
||||
enable_warnings(error)
|
||||
check_symbol_exists(futimens sys/stat.h HAVE_FUTIMENS)
|
||||
disable_warnings(error)
|
||||
else()
|
||||
check_function_exists(futimens HAVE_FUTIMENS)
|
||||
endif()
|
||||
|
||||
@@ -13,81 +13,74 @@
|
||||
# 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
|
||||
${MBEDTLS_ROOT_DIR}
|
||||
ENV MBEDTLS_ROOT_DIR)
|
||||
|
||||
SET(_MBEDTLS_ROOT_HINTS_AND_PATHS
|
||||
HINTS ${_MBEDTLS_ROOT_HINTS}
|
||||
PATHS ${_MBEDTLS_ROOT_PATHS}
|
||||
)
|
||||
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
|
||||
)
|
||||
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()
|
||||
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
|
||||
)
|
||||
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_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(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)
|
||||
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()
|
||||
message(STATUS " TLS: ${MBEDTLS_LIBRARY}")
|
||||
message(STATUS " X509: ${MBEDX509_LIBRARY}")
|
||||
message(STATUS " Crypto: ${MBEDCRYPTO_LIBRARY}")
|
||||
endif()
|
||||
else(MBEDTLS_FOUND)
|
||||
if(MBEDTLS_FIND_REQUIRED)
|
||||
message(FATAL_ERROR "Could not find mbedTLS")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
MARK_AS_ADVANCED(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY
|
||||
)
|
||||
mark_as_advanced(
|
||||
MBEDTLS_INCLUDE_DIR
|
||||
MBEDTLS_LIBRARY_DIR
|
||||
MBEDTLS_LIBRARIES
|
||||
MBEDTLS_LIBRARY
|
||||
MBEDX509_LIBRARY
|
||||
MBEDCRYPTO_LIBRARY)
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
# 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,
|
||||
# Visual Studio, so that you can navigate into the libgit2_tests 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()
|
||||
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 ${PROJECT_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()
|
||||
|
||||
@@ -2,76 +2,76 @@
|
||||
#
|
||||
|
||||
function(pkg_build_config)
|
||||
set(options)
|
||||
set(oneValueArgs NAME DESCRIPTION VERSION FILENAME LIBS_SELF)
|
||||
set(multiValueArgs LIBS PRIVATE_LIBS REQUIRES CFLAGS)
|
||||
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})
|
||||
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_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_DESCRIPTION)
|
||||
message(FATAL_ERROR "Missing DESCRIPTION argument")
|
||||
endif()
|
||||
|
||||
if (NOT DEFINED PKGCONFIG_VERSION)
|
||||
message(FATAL_ERROR "Missing VERSION 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"
|
||||
)
|
||||
# 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()
|
||||
# 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()
|
||||
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")
|
||||
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 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 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")
|
||||
# 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")
|
||||
# Install .pc file
|
||||
install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
|
||||
endfunction()
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
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()
|
||||
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,48 +1,48 @@
|
||||
INCLUDE(SanitizeBool)
|
||||
include(SanitizeBool)
|
||||
|
||||
# We try to find any packages our backends might use
|
||||
FIND_PACKAGE(GSSAPI)
|
||||
IF (CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
INCLUDE(FindGSSFramework)
|
||||
ENDIF()
|
||||
find_package(GSSAPI)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
include(FindGSSFramework)
|
||||
endif()
|
||||
|
||||
IF(USE_GSSAPI)
|
||||
if(USE_GSSAPI)
|
||||
# Auto-select GSS backend
|
||||
SanitizeBool(USE_GSSAPI)
|
||||
IF (USE_GSSAPI STREQUAL ON)
|
||||
IF (GSSFRAMEWORK_FOUND)
|
||||
SET(USE_GSSAPI "GSS.framework")
|
||||
ELSEIF(GSSAPI_FOUND)
|
||||
SET(USE_GSSAPI "gssapi")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to autodetect a usable GSS backend."
|
||||
sanitizebool(USE_GSSAPI)
|
||||
if(USE_GSSAPI STREQUAL ON)
|
||||
if(GSSFRAMEWORK_FOUND)
|
||||
set(USE_GSSAPI "GSS.framework")
|
||||
elseif(GSSAPI_FOUND)
|
||||
set(USE_GSSAPI "gssapi")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to autodetect a usable GSS backend."
|
||||
"Please pass the backend name explicitly (-DUSE_GSS=backend)")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check that we can find what's required for the selected backend
|
||||
IF (USE_GSSAPI STREQUAL "GSS.framework")
|
||||
IF (NOT GSSFRAMEWORK_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for GSS.framework backend, but it wasn't found")
|
||||
ENDIF()
|
||||
if(USE_GSSAPI 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})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSFRAMEWORK_LIBRARIES})
|
||||
|
||||
SET(GIT_GSSFRAMEWORK 1)
|
||||
ADD_FEATURE_INFO(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
|
||||
ELSEIF (USE_GSSAPI STREQUAL "gssapi")
|
||||
IF (NOT GSSAPI_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for gssapi GSS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
set(GIT_GSSFRAMEWORK 1)
|
||||
add_feature_info(SPNEGO GIT_GSSFRAMEWORK "SPNEGO authentication support (${USE_GSSAPI})")
|
||||
elseif(USE_GSSAPI 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})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${GSSAPI_LIBRARIES})
|
||||
|
||||
SET(GIT_GSSAPI 1)
|
||||
ADD_FEATURE_INFO(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
|
||||
ENDIF()
|
||||
ELSE()
|
||||
SET(GIT_GSSAPI 0)
|
||||
ADD_FEATURE_INFO(SPNEGO NO "SPNEGO authentication support")
|
||||
ENDIF()
|
||||
set(GIT_GSSAPI 1)
|
||||
add_feature_info(SPNEGO GIT_GSSAPI "SPNEGO authentication support (${USE_GSSAPI})")
|
||||
else()
|
||||
message(FATAL_ERROR "Asked for backend ${USE_GSSAPI} but it wasn't found")
|
||||
endif()
|
||||
else()
|
||||
set(GIT_GSSAPI 0)
|
||||
add_feature_info(SPNEGO NO "SPNEGO authentication support")
|
||||
endif()
|
||||
|
||||
19
cmake/SelectHTTPParser.cmake
Normal file
19
cmake/SelectHTTPParser.cmake
Normal file
@@ -0,0 +1,19 @@
|
||||
# Optional external dependency: http-parser
|
||||
if(USE_HTTP_PARSER STREQUAL "system")
|
||||
find_package(HTTPParser)
|
||||
|
||||
if(HTTP_PARSER_FOUND AND HTTP_PARSER_VERSION_MAJOR EQUAL 2)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${HTTP_PARSER_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${HTTP_PARSER_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lhttp_parser")
|
||||
add_feature_info(http-parser ON "http-parser support (system)")
|
||||
else()
|
||||
message(FATAL_ERROR "http-parser support was requested but not found")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "http-parser version 2 was not found or disabled; using bundled 3rd-party sources.")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/http-parser" "${PROJECT_BINARY_DIR}/deps/http-parser")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/http-parser")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:http-parser>")
|
||||
add_feature_info(http-parser ON "http-parser support (bundled)")
|
||||
endif()
|
||||
@@ -1,124 +1,124 @@
|
||||
INCLUDE(SanitizeBool)
|
||||
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()
|
||||
find_package(OpenSSL)
|
||||
find_package(mbedTLS)
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "Darwin")
|
||||
find_package(Security)
|
||||
find_package(CoreFoundation)
|
||||
endif()
|
||||
|
||||
IF(USE_HTTPS)
|
||||
if(USE_HTTPS)
|
||||
# Auto-select TLS backend
|
||||
SanitizeBool(USE_HTTPS)
|
||||
IF (USE_HTTPS STREQUAL ON)
|
||||
IF (SECURITY_FOUND)
|
||||
IF (SECURITY_HAS_SSLCREATECONTEXT)
|
||||
SET(USE_HTTPS "SecureTransport")
|
||||
ELSE()
|
||||
MESSAGE(STATUS "Security framework is too old, falling back to OpenSSL")
|
||||
SET(USE_HTTPS "OpenSSL")
|
||||
ENDIF()
|
||||
ELSEIF (WINHTTP)
|
||||
SET(USE_HTTPS "WinHTTP")
|
||||
ELSEIF(OPENSSL_FOUND)
|
||||
SET(USE_HTTPS "OpenSSL")
|
||||
ELSEIF(MBEDTLS_FOUND)
|
||||
SET(USE_HTTPS "mbedTLS")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
|
||||
sanitizebool(USE_HTTPS)
|
||||
if(USE_HTTPS STREQUAL ON)
|
||||
if(SECURITY_FOUND)
|
||||
if(SECURITY_HAS_SSLCREATECONTEXT)
|
||||
set(USE_HTTPS "SecureTransport")
|
||||
else()
|
||||
message(STATUS "Security framework is too old, falling back to OpenSSL")
|
||||
set(USE_HTTPS "OpenSSL")
|
||||
endif()
|
||||
elseif(USE_WINHTTP)
|
||||
set(USE_HTTPS "WinHTTP")
|
||||
elseif(OPENSSL_FOUND)
|
||||
set(USE_HTTPS "OpenSSL")
|
||||
elseif(MBEDTLS_FOUND)
|
||||
set(USE_HTTPS "mbedTLS")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to autodetect a usable HTTPS backend."
|
||||
"Please pass the backend name explicitly (-DUSE_HTTPS=backend)")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check that we can find what's required for the selected backend
|
||||
IF (USE_HTTPS 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()
|
||||
if(USE_HTTPS 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 (USE_HTTPS STREQUAL "OpenSSL")
|
||||
IF (NOT OPENSSL_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for OpenSSL TLS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
set(GIT_SECURE_TRANSPORT 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${SECURITY_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${COREFOUNDATION_LDFLAGS} ${SECURITY_LDFLAGS})
|
||||
elseif(USE_HTTPS 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(USE_HTTPS STREQUAL "mbedTLS")
|
||||
IF (NOT MBEDTLS_FOUND)
|
||||
MESSAGE(FATAL_ERROR "Asked for mbedTLS backend, but it wasn't found")
|
||||
ENDIF()
|
||||
set(GIT_OPENSSL 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${OPENSSL_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${OPENSSL_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${OPENSSL_LDFLAGS})
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "openssl")
|
||||
elseif(USE_HTTPS 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)
|
||||
if(NOT CERT_LOCATION)
|
||||
message(STATUS "Auto-detecting default certificates location")
|
||||
if(EXISTS "/usr/local/opt/openssl/bin/openssl")
|
||||
# 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_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
|
||||
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()
|
||||
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()
|
||||
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})
|
||||
set(GIT_MBEDTLS 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_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 (USE_HTTPS STREQUAL "WinHTTP")
|
||||
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
|
||||
elseif(USE_HTTPS STREQUAL "WinHTTP")
|
||||
# WinHTTP setup was handled in the WinHTTP-specific block above
|
||||
ELSEIF (USE_HTTPS STREQUAL "OpenSSL-Dynamic")
|
||||
SET(GIT_OPENSSL 1)
|
||||
SET(GIT_OPENSSL_DYNAMIC 1)
|
||||
LIST(APPEND LIBGIT2_LIBS dl)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
|
||||
ENDIF()
|
||||
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_OPENSSL 1)
|
||||
set(GIT_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
else()
|
||||
message(FATAL_ERROR "Asked for backend ${USE_HTTPS} but it wasn't found")
|
||||
endif()
|
||||
|
||||
SET(GIT_HTTPS 1)
|
||||
ADD_FEATURE_INFO(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
|
||||
ELSE()
|
||||
SET(GIT_HTTPS 0)
|
||||
ADD_FEATURE_INFO(HTTPS NO "")
|
||||
ENDIF()
|
||||
set(GIT_HTTPS 1)
|
||||
add_feature_info(HTTPS GIT_HTTPS "using ${USE_HTTPS}")
|
||||
else()
|
||||
set(GIT_HTTPS 0)
|
||||
add_feature_info(HTTPS NO "")
|
||||
endif()
|
||||
|
||||
@@ -1,62 +1,100 @@
|
||||
# Select a hash backend
|
||||
|
||||
INCLUDE(SanitizeBool)
|
||||
include(SanitizeBool)
|
||||
|
||||
# USE_SHA1=CollisionDetection(ON)/HTTPS/Generic/OFF
|
||||
sanitizebool(USE_SHA1)
|
||||
sanitizebool(USE_SHA256)
|
||||
|
||||
SanitizeBool(USE_SHA1)
|
||||
IF(USE_SHA1 STREQUAL ON)
|
||||
# sha1
|
||||
|
||||
if(USE_SHA1 STREQUAL ON)
|
||||
SET(USE_SHA1 "CollisionDetection")
|
||||
ELSEIF(USE_SHA1 STREQUAL "HTTPS")
|
||||
IF(USE_HTTPS STREQUAL "SecureTransport")
|
||||
SET(USE_SHA1 "CommonCrypto")
|
||||
ELSEIF(USE_HTTPS STREQUAL "WinHTTP")
|
||||
SET(USE_SHA1 "Win32")
|
||||
ELSEIF(USE_HTTPS)
|
||||
SET(USE_SHA1 ${USE_HTTPS})
|
||||
ELSE()
|
||||
SET(USE_SHA1 "CollisionDetection")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
elseif(USE_SHA1 STREQUAL "HTTPS")
|
||||
if(USE_HTTPS STREQUAL "SecureTransport")
|
||||
set(USE_SHA1 "CommonCrypto")
|
||||
elseif(USE_HTTPS STREQUAL "WinHTTP")
|
||||
set(USE_SHA1 "Win32")
|
||||
elseif(USE_HTTPS)
|
||||
set(USE_SHA1 ${USE_HTTPS})
|
||||
else()
|
||||
set(USE_SHA1 "CollisionDetection")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
IF(USE_SHA1 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(USE_SHA1 STREQUAL "OpenSSL")
|
||||
# OPENSSL_FOUND should already be set, we're checking USE_HTTPS
|
||||
if(USE_SHA1 STREQUAL "CollisionDetection")
|
||||
set(GIT_SHA1_COLLISIONDETECT 1)
|
||||
elseif(USE_SHA1 STREQUAL "OpenSSL")
|
||||
set(GIT_SHA1_OPENSSL 1)
|
||||
elseif(USE_SHA1 STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_SHA1_OPENSSL 1)
|
||||
set(GIT_SHA1_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
elseif(USE_SHA1 STREQUAL "CommonCrypto")
|
||||
set(GIT_SHA1_COMMON_CRYPTO 1)
|
||||
elseif(USE_SHA1 STREQUAL "mbedTLS")
|
||||
set(GIT_SHA1_MBEDTLS 1)
|
||||
elseif(USE_SHA1 STREQUAL "Win32")
|
||||
set(GIT_SHA1_WIN32 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
|
||||
endif()
|
||||
|
||||
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(USE_SHA1 STREQUAL "CommonCrypto")
|
||||
SET(GIT_SHA1_COMMON_CRYPTO 1)
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/common_crypto.*)
|
||||
ELSEIF(USE_SHA1 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})
|
||||
# sha256
|
||||
|
||||
if(USE_SHA256 STREQUAL ON AND USE_HTTPS)
|
||||
SET(USE_SHA256 "HTTPS")
|
||||
elseif(USE_SHA256 STREQUAL ON)
|
||||
SET(USE_SHA256 "Builtin")
|
||||
endif()
|
||||
|
||||
if(USE_SHA256 STREQUAL "HTTPS")
|
||||
if(USE_HTTPS STREQUAL "SecureTransport")
|
||||
set(USE_SHA256 "CommonCrypto")
|
||||
elseif(USE_HTTPS STREQUAL "WinHTTP")
|
||||
set(USE_SHA256 "Win32")
|
||||
elseif(USE_HTTPS)
|
||||
set(USE_SHA256 ${USE_HTTPS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_SHA256 STREQUAL "Builtin")
|
||||
set(GIT_SHA256_BUILTIN 1)
|
||||
elseif(USE_SHA256 STREQUAL "OpenSSL")
|
||||
set(GIT_SHA256_OPENSSL 1)
|
||||
elseif(USE_SHA256 STREQUAL "OpenSSL-Dynamic")
|
||||
set(GIT_SHA256_OPENSSL 1)
|
||||
set(GIT_SHA256_OPENSSL_DYNAMIC 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS dl)
|
||||
elseif(USE_SHA256 STREQUAL "CommonCrypto")
|
||||
set(GIT_SHA256_COMMON_CRYPTO 1)
|
||||
elseif(USE_SHA256 STREQUAL "mbedTLS")
|
||||
set(GIT_SHA256_MBEDTLS 1)
|
||||
elseif(USE_SHA256 STREQUAL "Win32")
|
||||
set(GIT_SHA256_WIN32 1)
|
||||
else()
|
||||
message(FATAL_ERROR "Asked for unknown SHA256 backend: ${USE_SHA256}")
|
||||
endif()
|
||||
|
||||
# add library requirements
|
||||
if(USE_SHA1 STREQUAL "OpenSSL" OR USE_SHA256 STREQUAL "OpenSSL")
|
||||
if(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lssl")
|
||||
else()
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "openssl")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_SHA1 STREQUAL "mbedTLS" OR USE_SHA256 STREQUAL "mbedTLS")
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${MBEDTLS_INCLUDE_DIR})
|
||||
list(APPEND LIBGIT2_SYSTEM_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(USE_SHA1 STREQUAL "Win32")
|
||||
SET(GIT_SHA1_WIN32 1)
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/win32.*)
|
||||
ELSEIF(USE_SHA1 STREQUAL "Generic")
|
||||
FILE(GLOB SRC_SHA1 hash/sha1/generic.*)
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Asked for unknown SHA1 backend: ${USE_SHA1}")
|
||||
ENDIF()
|
||||
list(APPEND LIBGIT2_PC_LIBS ${MBEDTLS_LIBRARIES})
|
||||
endif()
|
||||
|
||||
list(APPEND SRC_SHA1 "hash/sha1.h")
|
||||
list(SORT SRC_SHA1)
|
||||
# notify feature enablement
|
||||
|
||||
ADD_FEATURE_INFO(SHA ON "using ${USE_SHA1}")
|
||||
add_feature_info(SHA1 ON "using ${USE_SHA1}")
|
||||
add_feature_info(SHA256 ON "using ${USE_SHA256}")
|
||||
|
||||
51
cmake/SelectRegex.cmake
Normal file
51
cmake/SelectRegex.cmake
Normal file
@@ -0,0 +1,51 @@
|
||||
# Specify regular expression implementation
|
||||
find_package(PCRE)
|
||||
|
||||
if(REGEX_BACKEND STREQUAL "")
|
||||
check_symbol_exists(regcomp_l "regex.h;xlocale.h" HAVE_REGCOMP_L)
|
||||
|
||||
if(HAVE_REGCOMP_L)
|
||||
set(REGEX_BACKEND "regcomp_l")
|
||||
elseif(PCRE_FOUND)
|
||||
set(REGEX_BACKEND "pcre")
|
||||
else()
|
||||
set(REGEX_BACKEND "builtin")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(REGEX_BACKEND STREQUAL "regcomp_l")
|
||||
add_feature_info(regex ON "using system regcomp_l")
|
||||
set(GIT_REGEX_REGCOMP_L 1)
|
||||
elseif(REGEX_BACKEND STREQUAL "pcre2")
|
||||
find_package(PCRE2)
|
||||
|
||||
if(NOT PCRE2_FOUND)
|
||||
MESSAGE(FATAL_ERROR "PCRE2 support was requested but not found")
|
||||
endif()
|
||||
|
||||
add_feature_info(regex ON "using system PCRE2")
|
||||
set(GIT_REGEX_PCRE2 1)
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE2_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE2_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "libpcre2-8")
|
||||
elseif(REGEX_BACKEND STREQUAL "pcre")
|
||||
add_feature_info(regex ON "using system PCRE")
|
||||
set(GIT_REGEX_PCRE 1)
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${PCRE_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${PCRE_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "libpcre")
|
||||
elseif(REGEX_BACKEND STREQUAL "regcomp")
|
||||
add_feature_info(regex ON "using system regcomp")
|
||||
set(GIT_REGEX_REGCOMP 1)
|
||||
elseif(REGEX_BACKEND STREQUAL "builtin")
|
||||
add_feature_info(regex ON "using bundled PCRE")
|
||||
set(GIT_REGEX_BUILTIN 1)
|
||||
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/pcre" "${PROJECT_BINARY_DIR}/deps/pcre")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/pcre")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:pcre>)
|
||||
else()
|
||||
message(FATAL_ERROR "The REGEX_BACKEND option provided is not supported")
|
||||
endif()
|
||||
41
cmake/SelectSSH.cmake
Normal file
41
cmake/SelectSSH.cmake
Normal file
@@ -0,0 +1,41 @@
|
||||
# Optional external dependency: libssh2
|
||||
if(USE_SSH)
|
||||
find_pkglibraries(LIBSSH2 libssh2)
|
||||
if(NOT LIBSSH2_FOUND)
|
||||
find_package(LibSSH2)
|
||||
set(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_INCLUDE_DIR})
|
||||
get_filename_component(LIBSSH2_LIBRARY_DIRS "${LIBSSH2_LIBRARY}" DIRECTORY)
|
||||
set(LIBSSH2_LIBRARIES ${LIBSSH2_LIBRARY})
|
||||
set(LIBSSH2_LDFLAGS "-lssh2")
|
||||
endif()
|
||||
|
||||
if(NOT LIBSSH2_FOUND)
|
||||
message(FATAL_ERROR "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(LIBSSH2_FOUND)
|
||||
set(GIT_SSH 1)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${LIBSSH2_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${LIBSSH2_LIBRARIES})
|
||||
list(APPEND LIBGIT2_PC_LIBS ${LIBSSH2_LDFLAGS})
|
||||
|
||||
check_library_exists("${LIBSSH2_LIBRARIES}" libssh2_userauth_publickey_frommemory "${LIBSSH2_LIBRARY_DIRS}" HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
if(HAVE_LIBSSH2_MEMORY_CREDENTIALS)
|
||||
set(GIT_SSH_MEMORY_CREDENTIALS 1)
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "LIBSSH2 not found. Set CMAKE_PREFIX_PATH if it is installed outside of the default search path.")
|
||||
endif()
|
||||
|
||||
if(WIN32 AND EMBED_SSH_PATH)
|
||||
file(GLOB SSH_SRC "${EMBED_SSH_PATH}/src/*.c")
|
||||
list(SORT SSH_SRC)
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS ${SSH_SRC})
|
||||
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${EMBED_SSH_PATH}/include")
|
||||
file(WRITE "${EMBED_SSH_PATH}/src/libssh2_config.h" "#define HAVE_WINCNG\n#define LIBSSH2_WINCNG\n#include \"../win32/libssh2_config.h\"")
|
||||
set(GIT_SSH 1)
|
||||
endif()
|
||||
|
||||
add_feature_info(SSH GIT_SSH "SSH transport support")
|
||||
17
cmake/SelectWinHTTP.cmake
Normal file
17
cmake/SelectWinHTTP.cmake
Normal file
@@ -0,0 +1,17 @@
|
||||
if(WIN32 AND USE_WINHTTP)
|
||||
set(GIT_WINHTTP 1)
|
||||
|
||||
# Since MinGW does not come with headers or an import library for winhttp,
|
||||
# we have to include a private header and generate our own import library
|
||||
if(MINGW)
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/winhttp" "${PROJECT_BINARY_DIR}/deps/winhttp")
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS winhttp)
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/winhttp")
|
||||
else()
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS "winhttp")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lwinhttp")
|
||||
endif()
|
||||
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS "rpcrt4" "crypt32" "ole32")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lrpcrt4" "-lcrypt32" "-lole32")
|
||||
endif()
|
||||
34
cmake/SelectZlib.cmake
Normal file
34
cmake/SelectZlib.cmake
Normal file
@@ -0,0 +1,34 @@
|
||||
# Optional external dependency: zlib
|
||||
include(SanitizeBool)
|
||||
|
||||
SanitizeBool(USE_BUNDLED_ZLIB)
|
||||
if(USE_BUNDLED_ZLIB STREQUAL ON)
|
||||
set(USE_BUNDLED_ZLIB "Bundled")
|
||||
endif()
|
||||
|
||||
if(USE_BUNDLED_ZLIB STREQUAL "OFF")
|
||||
find_package(ZLIB)
|
||||
if(ZLIB_FOUND)
|
||||
list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS})
|
||||
list(APPEND LIBGIT2_SYSTEM_LIBS ${ZLIB_LIBRARIES})
|
||||
if(APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
|
||||
list(APPEND LIBGIT2_PC_LIBS "-lz")
|
||||
else()
|
||||
list(APPEND LIBGIT2_PC_REQUIRES "zlib")
|
||||
endif()
|
||||
add_feature_info(zlib ON "using system zlib")
|
||||
else()
|
||||
message(STATUS "zlib was not found; using bundled 3rd-party sources." )
|
||||
endif()
|
||||
endif()
|
||||
if(USE_BUNDLED_ZLIB STREQUAL "Chromium")
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/chromium-zlib" "${PROJECT_BINARY_DIR}/deps/chromium-zlib")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/chromium-zlib")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:chromium_zlib>)
|
||||
add_feature_info(zlib ON "using (Chromium) bundled zlib")
|
||||
elseif(USE_BUNDLED_ZLIB OR NOT ZLIB_FOUND)
|
||||
add_subdirectory("${PROJECT_SOURCE_DIR}/deps/zlib" "${PROJECT_BINARY_DIR}/deps/zlib")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/zlib")
|
||||
list(APPEND LIBGIT2_DEPENDENCY_OBJECTS $<TARGET_OBJECTS:zlib>)
|
||||
add_feature_info(zlib ON "using bundled zlib")
|
||||
endif()
|
||||
12
deps/chromium-zlib/CMakeLists.txt
vendored
12
deps/chromium-zlib/CMakeLists.txt
vendored
@@ -4,18 +4,18 @@
|
||||
# TODO: The Chromium build file (in deps/chromium-zlib/zlib/BUILD.gn) supports
|
||||
# more platforms (like ARM with NEON), more can be enabled as needed.
|
||||
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 3.11)
|
||||
cmake_minimum_required(VERSION 3.11)
|
||||
|
||||
include(FetchContent)
|
||||
include(FindGit)
|
||||
|
||||
# Ensure that the git binary is present to download the sources.
|
||||
find_package(Git)
|
||||
IF(NOT Git_FOUND)
|
||||
if(NOT Git_FOUND)
|
||||
message(FATAL_ERROR "git is required to download the Chromium zlib sources")
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
FetchContent_Populate(chromium_zlib_src
|
||||
fetchcontent_populate(chromium_zlib_src
|
||||
GIT_REPOSITORY https://chromium.googlesource.com/chromium/src/third_party/zlib.git
|
||||
GIT_TAG 2c183c9f93a328bfb3121284da13cf89a0f7e64a
|
||||
QUIET
|
||||
@@ -31,8 +31,8 @@ disable_warnings(missing-declarations)
|
||||
|
||||
# -O3 is also set by the Chromium configuration and has been deemed safe enough
|
||||
# for them.
|
||||
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -g -DNDEBUG")
|
||||
set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG")
|
||||
|
||||
# Common definitions.
|
||||
add_definitions(
|
||||
|
||||
62
deps/ntlmclient/CMakeLists.txt
vendored
62
deps/ntlmclient/CMakeLists.txt
vendored
@@ -1,37 +1,37 @@
|
||||
FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
|
||||
LIST(SORT SRC_NTLMCLIENT)
|
||||
file(GLOB SRC_NTLMCLIENT "ntlm.c" "ntlm.h" "util.c" "util.h")
|
||||
list(SORT SRC_NTLMCLIENT)
|
||||
|
||||
ADD_DEFINITIONS(-DNTLM_STATIC=1)
|
||||
add_definitions(-DNTLM_STATIC=1)
|
||||
|
||||
DISABLE_WARNINGS(implicit-fallthrough)
|
||||
disable_warnings(implicit-fallthrough)
|
||||
|
||||
IF(USE_ICONV)
|
||||
ADD_DEFINITIONS(-DUNICODE_ICONV=1)
|
||||
FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
|
||||
ELSE()
|
||||
ADD_DEFINITIONS(-DUNICODE_BUILTIN=1)
|
||||
FILE(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
|
||||
ENDIF()
|
||||
if(USE_ICONV)
|
||||
add_definitions(-DUNICODE_ICONV=1)
|
||||
file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_iconv.c" "unicode_iconv.h")
|
||||
else()
|
||||
add_definitions(-DUNICODE_BUILTIN=1)
|
||||
file(GLOB SRC_NTLMCLIENT_UNICODE "unicode_builtin.c" "unicode_builtin.h")
|
||||
endif()
|
||||
|
||||
IF(USE_HTTPS STREQUAL "SecureTransport")
|
||||
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
|
||||
if(USE_HTTPS STREQUAL "SecureTransport")
|
||||
add_definitions(-DCRYPT_COMMONCRYPTO)
|
||||
set(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c" "crypt_commoncrypto.h")
|
||||
# CC_MD4 has been deprecated in macOS 10.15.
|
||||
SET_SOURCE_FILES_PROPERTIES("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
|
||||
ELSEIF(USE_HTTPS STREQUAL "OpenSSL")
|
||||
ADD_DEFINITIONS(-DCRYPT_OPENSSL)
|
||||
INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
|
||||
ELSEIF(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
|
||||
ADD_DEFINITIONS(-DCRYPT_OPENSSL)
|
||||
ADD_DEFINITIONS(-DCRYPT_OPENSSL_DYNAMIC)
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
|
||||
ELSEIF(USE_HTTPS STREQUAL "mbedTLS")
|
||||
ADD_DEFINITIONS(-DCRYPT_MBEDTLS)
|
||||
INCLUDE_DIRECTORIES(${MBEDTLS_INCLUDE_DIR})
|
||||
SET(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
|
||||
ELSE()
|
||||
MESSAGE(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
|
||||
ENDIF()
|
||||
set_source_files_properties("crypt_commoncrypto.c" COMPILE_FLAGS "-Wno-deprecated")
|
||||
elseif(USE_HTTPS STREQUAL "OpenSSL")
|
||||
add_definitions(-DCRYPT_OPENSSL)
|
||||
include_directories(${OPENSSL_INCLUDE_DIR})
|
||||
set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
|
||||
elseif(USE_HTTPS STREQUAL "OpenSSL-Dynamic")
|
||||
add_definitions(-DCRYPT_OPENSSL)
|
||||
add_definitions(-DCRYPT_OPENSSL_DYNAMIC)
|
||||
set(SRC_NTLMCLIENT_CRYPTO "crypt_openssl.c" "crypt_openssl.h")
|
||||
elseif(USE_HTTPS STREQUAL "mbedTLS")
|
||||
add_definitions(-DCRYPT_MBEDTLS)
|
||||
include_directories(${MBEDTLS_INCLUDE_DIR})
|
||||
set(SRC_NTLMCLIENT_CRYPTO "crypt_mbedtls.c" "crypt_mbedtls.h")
|
||||
else()
|
||||
message(FATAL_ERROR "Unable to use libgit2's HTTPS backend (${USE_HTTPS}) for NTLM crypto")
|
||||
endif()
|
||||
|
||||
ADD_LIBRARY(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
|
||||
add_library(ntlmclient OBJECT ${SRC_NTLMCLIENT} ${SRC_NTLMCLIENT_UNICODE} ${SRC_NTLMCLIENT_CRYPTO})
|
||||
|
||||
4
deps/ntlmclient/crypt_openssl.c
vendored
4
deps/ntlmclient/crypt_openssl.c
vendored
@@ -44,7 +44,9 @@ static inline void HMAC_CTX_free(HMAC_CTX *ctx)
|
||||
|
||||
#endif
|
||||
|
||||
#if OPENSSL_VERSION_NUMBER >= 0x10100000L || defined(CRYPT_OPENSSL_DYNAMIC)
|
||||
#if (OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)) || \
|
||||
(defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER >= 0x03050000fL) || \
|
||||
defined(CRYPT_OPENSSL_DYNAMIC)
|
||||
|
||||
static inline void HMAC_CTX_cleanup(HMAC_CTX *ctx)
|
||||
{
|
||||
|
||||
8
deps/ntlmclient/ntlm.c
vendored
8
deps/ntlmclient/ntlm.c
vendored
@@ -930,10 +930,10 @@ const char *ntlm_client_target_domain_dns(ntlm_client *ntlm)
|
||||
}
|
||||
|
||||
#define EVEN_PARITY(a) \
|
||||
(!!((a) & 0x01ll) ^ !!((a) & 0x02ll) ^ \
|
||||
!!((a) & 0x04ll) ^ !!((a) & 0x08ll) ^ \
|
||||
!!((a) & 0x10ll) ^ !!((a) & 0x20ll) ^ \
|
||||
!!((a) & 0x40ll) ^ !!((a) & 0x80ll))
|
||||
(!!((a) & INT64_C(0x01)) ^ !!((a) & INT64_C(0x02)) ^ \
|
||||
!!((a) & INT64_C(0x04)) ^ !!((a) & INT64_C(0x08)) ^ \
|
||||
!!((a) & INT64_C(0x10)) ^ !!((a) & INT64_C(0x20)) ^ \
|
||||
!!((a) & INT64_C(0x40)) ^ !!((a) & INT64_C(0x80)))
|
||||
|
||||
static void generate_odd_parity(ntlm_des_block *block)
|
||||
{
|
||||
|
||||
8
deps/ntlmclient/ntlm.h
vendored
8
deps/ntlmclient/ntlm.h
vendored
@@ -30,7 +30,7 @@ typedef enum {
|
||||
NTLM_STATE_CHALLENGE = 1,
|
||||
NTLM_STATE_RESPONSE = 2,
|
||||
NTLM_STATE_ERROR = 3,
|
||||
NTLM_STATE_COMPLETE = 4,
|
||||
NTLM_STATE_COMPLETE = 4
|
||||
} ntlm_state;
|
||||
|
||||
typedef struct {
|
||||
@@ -122,7 +122,7 @@ struct ntlm_client {
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
NTLM_ENABLE_HOSTVERSION = (1 << 31),
|
||||
NTLM_ENABLE_HOSTVERSION = (1 << 31)
|
||||
} ntlm_client_internal_flags;
|
||||
|
||||
typedef enum {
|
||||
@@ -130,7 +130,7 @@ typedef enum {
|
||||
NTLM_TARGET_INFO_SERVER = 1,
|
||||
NTLM_TARGET_INFO_DOMAIN = 2,
|
||||
NTLM_TARGET_INFO_SERVER_DNS = 3,
|
||||
NTLM_TARGET_INFO_DOMAIN_DNS = 4,
|
||||
NTLM_TARGET_INFO_DOMAIN_DNS = 4
|
||||
} ntlm_target_info_type_t;
|
||||
|
||||
typedef enum {
|
||||
@@ -168,7 +168,7 @@ typedef enum {
|
||||
NTLM_NEGOTIATE_TARGET_INFO = 0x00800000,
|
||||
|
||||
/* Version information should be provided */
|
||||
NTLM_NEGOTIATE_VERSION = 0x01000000,
|
||||
NTLM_NEGOTIATE_VERSION = 0x01000000
|
||||
} ntlm_negotiate_t;
|
||||
|
||||
extern int ntlm_client_set_nonce(ntlm_client *ntlm, uint64_t nonce);
|
||||
|
||||
4
deps/ntlmclient/ntlmclient.h
vendored
4
deps/ntlmclient/ntlmclient.h
vendored
@@ -32,7 +32,7 @@ typedef enum {
|
||||
/**
|
||||
* The input provided to the function is missing or invalid.
|
||||
*/
|
||||
NTLM_CLIENT_ERROR_INVALID_INPUT = -2,
|
||||
NTLM_CLIENT_ERROR_INVALID_INPUT = -2
|
||||
} ntlm_error_code;
|
||||
|
||||
/*
|
||||
@@ -98,7 +98,7 @@ typedef enum {
|
||||
* its idea of its hostname in the challenge message. You may
|
||||
* then set the authentication target based on it.
|
||||
*/
|
||||
NTLM_CLIENT_DISABLE_REQUEST_TARGET = (1 << 4),
|
||||
NTLM_CLIENT_DISABLE_REQUEST_TARGET = (1 << 4)
|
||||
} ntlm_client_flags;
|
||||
|
||||
|
||||
|
||||
154
deps/pcre/CMakeLists.txt
vendored
154
deps/pcre/CMakeLists.txt
vendored
@@ -1,95 +1,95 @@
|
||||
INCLUDE(CheckIncludeFile)
|
||||
INCLUDE(CheckFunctionExists)
|
||||
INCLUDE(CheckTypeSize)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckTypeSize)
|
||||
|
||||
CHECK_INCLUDE_FILE(dirent.h HAVE_DIRENT_H)
|
||||
CHECK_INCLUDE_FILE(stdint.h HAVE_STDINT_H)
|
||||
CHECK_INCLUDE_FILE(inttypes.h HAVE_INTTYPES_H)
|
||||
CHECK_INCLUDE_FILE(sys/stat.h HAVE_SYS_STAT_H)
|
||||
CHECK_INCLUDE_FILE(sys/types.h HAVE_SYS_TYPES_H)
|
||||
CHECK_INCLUDE_FILE(unistd.h HAVE_UNISTD_H)
|
||||
CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
|
||||
check_include_file(dirent.h HAVE_DIRENT_H)
|
||||
check_include_file(stdint.h HAVE_STDINT_H)
|
||||
check_include_file(inttypes.h HAVE_INTTYPES_H)
|
||||
check_include_file(sys/stat.h HAVE_SYS_STAT_H)
|
||||
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
check_include_file(windows.h HAVE_WINDOWS_H)
|
||||
|
||||
CHECK_FUNCTION_EXISTS(bcopy HAVE_BCOPY)
|
||||
CHECK_FUNCTION_EXISTS(memmove HAVE_MEMMOVE)
|
||||
CHECK_FUNCTION_EXISTS(strerror HAVE_STRERROR)
|
||||
CHECK_FUNCTION_EXISTS(strtoll HAVE_STRTOLL)
|
||||
CHECK_FUNCTION_EXISTS(strtoq HAVE_STRTOQ)
|
||||
CHECK_FUNCTION_EXISTS(_strtoi64 HAVE__STRTOI64)
|
||||
check_function_exists(bcopy HAVE_BCOPY)
|
||||
check_function_exists(memmove HAVE_MEMMOVE)
|
||||
check_function_exists(strerror HAVE_STRERROR)
|
||||
check_function_exists(strtoll HAVE_STRTOLL)
|
||||
check_function_exists(strtoq HAVE_STRTOQ)
|
||||
check_function_exists(_strtoi64 HAVE__STRTOI64)
|
||||
|
||||
CHECK_TYPE_SIZE("long long" LONG_LONG)
|
||||
CHECK_TYPE_SIZE("unsigned long long" UNSIGNED_LONG_LONG)
|
||||
check_type_size("long long" LONG_LONG)
|
||||
check_type_size("unsigned long long" UNSIGNED_LONG_LONG)
|
||||
|
||||
DISABLE_WARNINGS(unused-function)
|
||||
DISABLE_WARNINGS(implicit-fallthrough)
|
||||
disable_warnings(unused-function)
|
||||
disable_warnings(implicit-fallthrough)
|
||||
|
||||
# User-configurable options
|
||||
|
||||
SET(SUPPORT_PCRE8 1)
|
||||
SET(PCRE_LINK_SIZE "2")
|
||||
SET(PCRE_PARENS_NEST_LIMIT "250")
|
||||
SET(PCRE_MATCH_LIMIT "10000000")
|
||||
SET(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
|
||||
SET(PCRE_NEWLINE "LF")
|
||||
SET(NO_RECURSE 1)
|
||||
SET(PCRE_POSIX_MALLOC_THRESHOLD "10")
|
||||
SET(BSR_ANYCRLF 0)
|
||||
set(SUPPORT_PCRE8 1)
|
||||
set(PCRE_LINK_SIZE "2")
|
||||
set(PCRE_PARENS_NEST_LIMIT "250")
|
||||
set(PCRE_MATCH_LIMIT "10000000")
|
||||
set(PCRE_MATCH_LIMIT_RECURSION "MATCH_LIMIT")
|
||||
set(PCRE_NEWLINE "LF")
|
||||
set(NO_RECURSE 1)
|
||||
set(PCRE_POSIX_MALLOC_THRESHOLD "10")
|
||||
set(BSR_ANYCRLF 0)
|
||||
|
||||
IF (MINGW)
|
||||
OPTION(NON_STANDARD_LIB_PREFIX
|
||||
"ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
|
||||
OFF)
|
||||
if(MINGW)
|
||||
option(NON_STANDARD_LIB_PREFIX
|
||||
"ON=Shared libraries built in mingw will be named pcre.dll, etc., instead of libpcre.dll, etc."
|
||||
OFF)
|
||||
|
||||
OPTION(NON_STANDARD_LIB_SUFFIX
|
||||
"ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
|
||||
OFF)
|
||||
ENDIF(MINGW)
|
||||
option(NON_STANDARD_LIB_SUFFIX
|
||||
"ON=Shared libraries built in mingw will be named libpcre-0.dll, etc., instead of libpcre.dll, etc."
|
||||
OFF)
|
||||
endif(MINGW)
|
||||
|
||||
# Prepare build configuration
|
||||
|
||||
SET(pcre_have_long_long 0)
|
||||
SET(pcre_have_ulong_long 0)
|
||||
set(pcre_have_long_long 0)
|
||||
set(pcre_have_ulong_long 0)
|
||||
|
||||
IF(HAVE_LONG_LONG)
|
||||
SET(pcre_have_long_long 1)
|
||||
ENDIF(HAVE_LONG_LONG)
|
||||
if(HAVE_LONG_LONG)
|
||||
set(pcre_have_long_long 1)
|
||||
endif(HAVE_LONG_LONG)
|
||||
|
||||
IF(HAVE_UNSIGNED_LONG_LONG)
|
||||
SET(pcre_have_ulong_long 1)
|
||||
ENDIF(HAVE_UNSIGNED_LONG_LONG)
|
||||
if(HAVE_UNSIGNED_LONG_LONG)
|
||||
set(pcre_have_ulong_long 1)
|
||||
endif(HAVE_UNSIGNED_LONG_LONG)
|
||||
|
||||
SET(NEWLINE "")
|
||||
set(NEWLINE "")
|
||||
|
||||
IF(PCRE_NEWLINE STREQUAL "LF")
|
||||
SET(NEWLINE "10")
|
||||
ENDIF(PCRE_NEWLINE STREQUAL "LF")
|
||||
IF(PCRE_NEWLINE STREQUAL "CR")
|
||||
SET(NEWLINE "13")
|
||||
ENDIF(PCRE_NEWLINE STREQUAL "CR")
|
||||
IF(PCRE_NEWLINE STREQUAL "CRLF")
|
||||
SET(NEWLINE "3338")
|
||||
ENDIF(PCRE_NEWLINE STREQUAL "CRLF")
|
||||
IF(PCRE_NEWLINE STREQUAL "ANY")
|
||||
SET(NEWLINE "-1")
|
||||
ENDIF(PCRE_NEWLINE STREQUAL "ANY")
|
||||
IF(PCRE_NEWLINE STREQUAL "ANYCRLF")
|
||||
SET(NEWLINE "-2")
|
||||
ENDIF(PCRE_NEWLINE STREQUAL "ANYCRLF")
|
||||
if(PCRE_NEWLINE STREQUAL "LF")
|
||||
set(NEWLINE "10")
|
||||
endif(PCRE_NEWLINE STREQUAL "LF")
|
||||
if(PCRE_NEWLINE STREQUAL "CR")
|
||||
set(NEWLINE "13")
|
||||
endif(PCRE_NEWLINE STREQUAL "CR")
|
||||
if(PCRE_NEWLINE STREQUAL "CRLF")
|
||||
set(NEWLINE "3338")
|
||||
endif(PCRE_NEWLINE STREQUAL "CRLF")
|
||||
if(PCRE_NEWLINE STREQUAL "ANY")
|
||||
set(NEWLINE "-1")
|
||||
endif(PCRE_NEWLINE STREQUAL "ANY")
|
||||
if(PCRE_NEWLINE STREQUAL "ANYCRLF")
|
||||
set(NEWLINE "-2")
|
||||
endif(PCRE_NEWLINE STREQUAL "ANYCRLF")
|
||||
|
||||
IF(NEWLINE STREQUAL "")
|
||||
MESSAGE(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
|
||||
ENDIF(NEWLINE STREQUAL "")
|
||||
if(NEWLINE STREQUAL "")
|
||||
message(FATAL_ERROR "The PCRE_NEWLINE variable must be set to one of the following values: \"LF\", \"CR\", \"CRLF\", \"ANY\", \"ANYCRLF\".")
|
||||
endif(NEWLINE STREQUAL "")
|
||||
|
||||
# Output files
|
||||
CONFIGURE_FILE(config.h.in
|
||||
configure_file(config.h.in
|
||||
${PROJECT_BINARY_DIR}/src/pcre/config.h
|
||||
@ONLY)
|
||||
|
||||
# Source code
|
||||
|
||||
SET(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
|
||||
set(PCRE_HEADERS ${PROJECT_BINARY_DIR}/src/pcre/config.h)
|
||||
|
||||
SET(PCRE_SOURCES
|
||||
set(PCRE_SOURCES
|
||||
pcre_byte_order.c
|
||||
pcre_chartables.c
|
||||
pcre_compile.c
|
||||
@@ -113,28 +113,28 @@ SET(PCRE_SOURCES
|
||||
pcre_xclass.c
|
||||
)
|
||||
|
||||
SET(PCREPOSIX_HEADERS pcreposix.h)
|
||||
set(PCREPOSIX_HEADERS pcreposix.h)
|
||||
|
||||
SET(PCREPOSIX_SOURCES pcreposix.c)
|
||||
set(PCREPOSIX_SOURCES pcreposix.c)
|
||||
|
||||
# Fix static compilation with MSVC: https://bugs.exim.org/show_bug.cgi?id=1681
|
||||
# This code was taken from the CMake wiki, not from WebM.
|
||||
|
||||
# Build setup
|
||||
|
||||
ADD_DEFINITIONS(-DHAVE_CONFIG_H)
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
|
||||
IF(MSVC)
|
||||
ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
|
||||
ENDIF(MSVC)
|
||||
if(MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS)
|
||||
endif(MSVC)
|
||||
|
||||
SET(CMAKE_INCLUDE_CURRENT_DIR 1)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR 1)
|
||||
|
||||
SET(targets)
|
||||
set(targets)
|
||||
|
||||
# Libraries
|
||||
# pcre
|
||||
INCLUDE_DIRECTORIES(${PROJECT_BINARY_DIR}/src/pcre)
|
||||
ADD_LIBRARY(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
|
||||
include_directories(${PROJECT_BINARY_DIR}/src/pcre)
|
||||
add_library(pcre OBJECT ${PCRE_HEADERS} ${PCRE_SOURCES} ${PCREPOSIX_SOURCES})
|
||||
|
||||
# end CMakeLists.txt
|
||||
|
||||
30
deps/winhttp/CMakeLists.txt
vendored
30
deps/winhttp/CMakeLists.txt
vendored
@@ -1,26 +1,24 @@
|
||||
FIND_PROGRAM(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
IF (NOT DLLTOOL)
|
||||
MESSAGE(FATAL_ERROR "Could not find dlltool command")
|
||||
ENDIF ()
|
||||
find_program(DLLTOOL dlltool CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
if(NOT DLLTOOL)
|
||||
message(FATAL_ERROR "Could not find dlltool command")
|
||||
endif()
|
||||
|
||||
SET(LIBWINHTTP_PATH "${libgit2_BINARY_DIR}/deps/winhttp")
|
||||
SET(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
|
||||
FILE(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
|
||||
set(LIBWINHTTP_PATH "${PROJECT_BINARY_DIR}/deps/winhttp")
|
||||
set(LIBWINHTTP_PATH ${LIBWINHTTP_PATH} PARENT_SCOPE)
|
||||
file(MAKE_DIRECTORY ${LIBWINHTTP_PATH})
|
||||
|
||||
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(WINHTTP_DEF "winhttp64.def")
|
||||
ELSE()
|
||||
else()
|
||||
set(WINHTTP_DEF "winhttp.def")
|
||||
ENDIF()
|
||||
endif()
|
||||
|
||||
ADD_CUSTOM_COMMAND(
|
||||
add_custom_command(
|
||||
OUTPUT ${LIBWINHTTP_PATH}/libwinhttp.a
|
||||
COMMAND ${DLLTOOL} -d ${WINHTTP_DEF} -k -D winhttp.dll -l libwinhttp.a
|
||||
DEPENDS ${WINHTTP_DEF}
|
||||
WORKING_DIRECTORY ${LIBWINHTTP_PATH}
|
||||
)
|
||||
WORKING_DIRECTORY ${LIBWINHTTP_PATH})
|
||||
|
||||
SET_SOURCE_FILES_PROPERTIES(
|
||||
set_source_files_properties(
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/src/transports/winhttp.c
|
||||
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a
|
||||
)
|
||||
PROPERTIES OBJECT_DEPENDS ${LIBWINHTTP_PATH}/libwinhttp.a)
|
||||
|
||||
63
docs/api-stability.md
Normal file
63
docs/api-stability.md
Normal file
@@ -0,0 +1,63 @@
|
||||
The maintainers of the libgit2 project believe that having a stable API
|
||||
to program against is important for our users and the ecosystem - whether
|
||||
you're building against the libgit2 C APIs directly, creating a wrapper to
|
||||
a managed language, or programming against one of those managed wrappers
|
||||
like LibGit2Sharp or Rugged.
|
||||
|
||||
Our API stability considerations are:
|
||||
|
||||
* Our standard API is considered stable through a major release.
|
||||
|
||||
* We define our "standard API" to be anything included in the "git2.h"
|
||||
header - in other words, anything defined in a header in the `git2`
|
||||
directory.
|
||||
|
||||
* APIs will maintain their signature and will not be removed within a
|
||||
major release, but new APIs may be added.
|
||||
|
||||
* Any APIs may be marked as deprecated within a major release, but will
|
||||
not be removed until the next major release (at the earliest). You
|
||||
may define `GIT_DEPRECATE_HARD` to produce compiler warnings if you
|
||||
target these deprecated APIs.
|
||||
|
||||
* We consider API compatibility to be against the C APIs. That means
|
||||
that we may use macros to keep API compatibility - for example, if we
|
||||
rename a structure from `git_widget_options` to `git_foobar_options`
|
||||
then we would `#define git_widget_options git_foobar_options` to retain
|
||||
API compatibility. Note that this does _not_ provide ABI compatibility.
|
||||
|
||||
* Our systems API is only considered stable through a _minor_ release.
|
||||
|
||||
* We define our "systems API" to be anything included in the `git2/sys`
|
||||
directory. These are not "standard" APIs but are mechanisms to extend
|
||||
libgit2 by adding new extensions - for example, a custom HTTPS transport,
|
||||
TLS engine, or merge strategy.
|
||||
|
||||
* Additionally, the cmake options and the resulting constants that it
|
||||
produces to be "systems API".
|
||||
|
||||
* Generally these mechanism are well defined and will not need significant
|
||||
changes, but are considered a part of the library itself and may need
|
||||
|
||||
* Systems API changes will be noted specially within a release's changelog.
|
||||
|
||||
* Our ABI is only considered stable through a _minor_ release.
|
||||
|
||||
* Our ABI consists of actual symbol names in the library, the function
|
||||
signatures, and the actual layout of structures. These are only
|
||||
stable within minor releases, they are not stable within major releases
|
||||
(yet).
|
||||
|
||||
* Since many FFIs use ABIs directly (for example, .NET P/Invoke or Rust),
|
||||
this instability is unfortunate.
|
||||
|
||||
* In a future major release, we will begin providing ABI stability
|
||||
throughout the major release cycle.
|
||||
|
||||
* ABI changes will be noted specially within a release's changelog.
|
||||
|
||||
* Point releases are _generally_ only for bugfixes, and generally do _not_
|
||||
include new features. This means that point releases generally do _not_
|
||||
include new APIs. Point releases will never break API, systems API or
|
||||
ABI compatibility.
|
||||
|
||||
63
docs/buffers.md
Normal file
63
docs/buffers.md
Normal file
@@ -0,0 +1,63 @@
|
||||
Memory allocation and ownership
|
||||
-------------------------------
|
||||
|
||||
Any library needs to _take_ data from users, and then _return_ data to
|
||||
users. With some types this is simple - integer parameters and return
|
||||
types are trivial. But with more complex data types, things are more
|
||||
complicated. Even something seemingly simple, like a C string, requires
|
||||
discipline: we cannot simple return an allocated hunk of memory for
|
||||
callers to `free`, since some systems have multiple allocators and users
|
||||
cannot necessarily reason about the allocator used and which corresponding
|
||||
deallocation function to call to free the memory.
|
||||
|
||||
## Objects
|
||||
|
||||
Most types in libgit2 are "opaque" types, which we treat as "objects" (even
|
||||
though C is "not an object oriented language"). You may create an object -
|
||||
for example, with `git_odb_new`, or libgit2 may return you an object as an
|
||||
"out" parameter - for example, with `git_repository_open`. With any of
|
||||
these objects, you should call their corresponding `_free` function (for
|
||||
example, `git_odb_free` or `git_repository_free`) when you are done using
|
||||
them.
|
||||
|
||||
## Structures
|
||||
|
||||
libgit2 will often take _input_ as structures (for example, options
|
||||
structures like `git_merge_options`). Rarely, libgit2 will return data in
|
||||
a structure. This is typically used for simpler data types, like `git_buf`
|
||||
and `git_strarray`. Users should allocate the structure themselves (either
|
||||
on the stack or the heap) and pass a pointer to it. Since libgit2 does not
|
||||
allocate the structure itself, only the data inside of it, the deallocation
|
||||
functions are suffixed with `_dispose` instead of `_free`, since they only
|
||||
free the data _inside_ the structure.
|
||||
|
||||
## Strings or continuous memory buffers (`git_buf`)
|
||||
|
||||
libgit2 typically _takes_ NUL-terminated strings ("C strings") with a
|
||||
`const char *`, and typically _takes_ raw data with a `const char *` and a
|
||||
corresponding `size_t` for its size. libgit2 typically _returns_ strings
|
||||
or raw data in a `git_buf` structure. The given data buffer will always be
|
||||
NUL terminated (even if it contains binary data) and the `size` member will
|
||||
always contain the size (in bytes) of the contents of the pointer (excluding
|
||||
the NUL terminator).
|
||||
|
||||
In other words, if a `git_buf` contains the string `foo` then the memory
|
||||
buffer will be { `f`, `o`, `o`, `\0` } and the size will be `3`.
|
||||
|
||||
Callers _must_ initialize the buffer with `GIT_BUF_INIT` (or by setting
|
||||
all the members to `0`) when it is created, before passing a pointer
|
||||
to the buffer to libgit2 for the first time.
|
||||
|
||||
Subsequent calls to libgit2 APIs that take a buffer can re-use a
|
||||
buffer that was previously used. The buffer will be cleared and grown
|
||||
to accommodate the new contents (if necessary). The new data will
|
||||
written into the buffer, overwriting the previous contents. This
|
||||
allows callers to reduce the number of allocations performed by the
|
||||
library.
|
||||
|
||||
Callers must call `git_buf_dispose` when they have finished.
|
||||
|
||||
Note that the deprecated `git_diff_format_email` API does not follow
|
||||
this behavior; subsequent calls will concatenate data to the buffer
|
||||
instead of rewriting it. Users should move to the new `git_email`
|
||||
APIs that follow the `git_buf` standards.
|
||||
@@ -1,3 +1,96 @@
|
||||
v1.4
|
||||
----
|
||||
|
||||
This is release v1.4.0, "Fisematenten". This release includes several new features and bugfixes, improves compatibility with git, and begins preparation for SHA256 support in a future release.
|
||||
|
||||
## What's Changed
|
||||
### New features
|
||||
* diff: update rename limit to 1000 to match git's behavior by @ethomson in https://github.com/libgit2/libgit2/pull/6092
|
||||
* odb: support checking for object existence without refresh by @joshtriplett in https://github.com/libgit2/libgit2/pull/6107
|
||||
* object: provide a low-level mechanism to validate whether a raw object is valid (`git_object_rawcontent_is_valid`) by @ethomson in https://github.com/libgit2/libgit2/pull/6128
|
||||
* blob: provide a function to identify binary content by @ethomson in https://github.com/libgit2/libgit2/pull/6142
|
||||
* status: add `rename_threshold` to `git_status_options`. by @arroz in https://github.com/libgit2/libgit2/pull/6158
|
||||
* remote: support `http.followRedirects` (`false` and `initial`) and follow initial redirects by default by @ethomson in https://github.com/libgit2/libgit2/pull/6175
|
||||
* remote: support scp style paths with ports (`[git@github.com:22]:libgit2/libgit2`) by @ethomson in https://github.com/libgit2/libgit2/pull/6167
|
||||
* win32: update git for windows configuration file location compatibility by @csware in https://github.com/libgit2/libgit2/pull/6151 and @ethomson in https://github.com/libgit2/libgit2/pull/6180
|
||||
* refs: speed up packed reference lookups when packed refs are sorted by @ccstolley in https://github.com/libgit2/libgit2/pull/6138
|
||||
* merge: support zdiff3 conflict styles by @ethomson in https://github.com/libgit2/libgit2/pull/6195
|
||||
* remote: support fetching by object id (using "+oid:ref" refspec syntax) by @ethomson in https://github.com/libgit2/libgit2/pull/6203
|
||||
* merge: callers can specify virtual-base building behavior and to optionally accept conflict markers as a resolution by @boretrk in https://github.com/libgit2/libgit2/pull/6204
|
||||
|
||||
### Bug fixes
|
||||
* Fix a gcc 11 warning in src/threadstate.c by @lhchavez in https://github.com/libgit2/libgit2/pull/6115
|
||||
* Fix a gcc 11 warning in src/thread.h by @lhchavez in https://github.com/libgit2/libgit2/pull/6116
|
||||
* cmake: re-enable WinHTTP by @ethomson in https://github.com/libgit2/libgit2/pull/6120
|
||||
* Fix repo init when template dir is non-existent by @ammgws in https://github.com/libgit2/libgit2/pull/6106
|
||||
* cmake: use project-specific root variable instead of CMAKE_SOURCE_DIR by @Qix- in https://github.com/libgit2/libgit2/pull/6146
|
||||
* Better revparse compatibility for at time notation by @yoichi in https://github.com/libgit2/libgit2/pull/6095
|
||||
* remotes: fix insteadOf/pushInsteadOf handling by @mkhl in https://github.com/libgit2/libgit2/pull/6101
|
||||
* git_commit_summary: ignore lines with spaces by @stforek in https://github.com/libgit2/libgit2/pull/6125
|
||||
* Config parsing by @csware in https://github.com/libgit2/libgit2/pull/6124
|
||||
* config: handle empty conditional in includeIf by @ethomson in https://github.com/libgit2/libgit2/pull/6165
|
||||
* #6154 git_status_list_new case insensitive fix by @arroz in https://github.com/libgit2/libgit2/pull/6159
|
||||
* futils_mktmp: don't use umask by @boretrk in https://github.com/libgit2/libgit2/pull/6178
|
||||
* revparse: support bare '@' by @ethomson in https://github.com/libgit2/libgit2/pull/6196
|
||||
* odb: check for write failures by @ethomson in https://github.com/libgit2/libgit2/pull/6206
|
||||
* push: Prepare pack before sending pack header. by @ccstolley in https://github.com/libgit2/libgit2/pull/6205
|
||||
* mktmp: improve our temp file creation by @ethomson in https://github.com/libgit2/libgit2/pull/6207
|
||||
* diff_file: fix crash if size of diffed file changes in workdir by @jorio in https://github.com/libgit2/libgit2/pull/6208
|
||||
* merge: comment conflicts lines in MERGE_MSG by @ethomson in https://github.com/libgit2/libgit2/pull/6197
|
||||
* Fix crashes in example programs on Windows (sprintf_s not compatible with snprintf) by @apnadkarni in https://github.com/libgit2/libgit2/pull/6212
|
||||
|
||||
### Code cleanups
|
||||
* Introduce `git_remote_connect_options` by @ethomson in https://github.com/libgit2/libgit2/pull/6161
|
||||
* hash: separate hashes and git_oid by @ethomson in https://github.com/libgit2/libgit2/pull/6082
|
||||
* `git_buf`: now a public-only API (`git_str` is our internal API) by @ethomson in https://github.com/libgit2/libgit2/pull/6078
|
||||
* cmake: cleanups and consistency by @ethomson in https://github.com/libgit2/libgit2/pull/6084
|
||||
* path: refactor utility path functions by @ethomson in https://github.com/libgit2/libgit2/pull/6104
|
||||
* str: git_str_free is never a function by @ethomson in https://github.com/libgit2/libgit2/pull/6111
|
||||
* cmake refactorings by @ethomson in https://github.com/libgit2/libgit2/pull/6112
|
||||
* Add missing-declarations warning globally by @ethomson in https://github.com/libgit2/libgit2/pull/6113
|
||||
* cmake: further refactorings by @ethomson in https://github.com/libgit2/libgit2/pull/6114
|
||||
* tag: set validity to 0 by default by @ethomson in https://github.com/libgit2/libgit2/pull/6119
|
||||
* util: minor cleanup and refactoring to the date class by @ethomson in https://github.com/libgit2/libgit2/pull/6121
|
||||
* Minor code cleanups by @ethomson in https://github.com/libgit2/libgit2/pull/6122
|
||||
* Fix a long long that crept past by @NattyNarwhal in https://github.com/libgit2/libgit2/pull/6094
|
||||
* remote: refactor insteadof application by @ethomson in https://github.com/libgit2/libgit2/pull/6147
|
||||
* ntmlclient: fix linking with libressl by @boretrk in https://github.com/libgit2/libgit2/pull/6157
|
||||
* c99: change single bit flags to unsigned by @boretrk in https://github.com/libgit2/libgit2/pull/6179
|
||||
* Fix typos by @rex4539 in https://github.com/libgit2/libgit2/pull/6164
|
||||
* diff_driver: split global_drivers array into separate elements by @boretrk in https://github.com/libgit2/libgit2/pull/6184
|
||||
* cmake: disable some gnu extensions by @boretrk in https://github.com/libgit2/libgit2/pull/6185
|
||||
* Disabling setting `CMAKE_FIND_LIBRARY_SUFFIXES` on Apple platforms. by @arroz in https://github.com/libgit2/libgit2/pull/6153
|
||||
* C90: add inline macro to xdiff and mbedtls by @boretrk in https://github.com/libgit2/libgit2/pull/6200
|
||||
* SHA256: early preparation by @ethomson in https://github.com/libgit2/libgit2/pull/6192
|
||||
|
||||
### CI improvements
|
||||
* tests: rename test runner to `libgit2_tests`, build option to `BUILD_TESTS`. by @ethomson in https://github.com/libgit2/libgit2/pull/6083
|
||||
* ci: only update docs on push by @ethomson in https://github.com/libgit2/libgit2/pull/6108
|
||||
* Pedantic header test by @boretrk in https://github.com/libgit2/libgit2/pull/6086
|
||||
* ci: build with ssh on nightly by @ethomson in https://github.com/libgit2/libgit2/pull/6148
|
||||
* ci: improve the name in CI runs by @ethomson in https://github.com/libgit2/libgit2/pull/6198
|
||||
|
||||
### Documentation improvements
|
||||
* Document that `git_odb` is thread-safe by @joshtriplett in https://github.com/libgit2/libgit2/pull/6109
|
||||
* Improve documentation by @punkymaniac in https://github.com/libgit2/libgit2/pull/6168
|
||||
|
||||
### Other changes
|
||||
* libgit2_clar is now libgit2_tests by @mkhl in https://github.com/libgit2/libgit2/pull/6100
|
||||
* Remove PSGit from Language Bindings section of README by @cestrand in https://github.com/libgit2/libgit2/pull/6150
|
||||
* COPYING: remove regex copyright, add PCRE copyright by @ethomson in https://github.com/libgit2/libgit2/pull/6187
|
||||
* meta: add a release configuration file by @ethomson in https://github.com/libgit2/libgit2/pull/6211
|
||||
|
||||
## New Contributors
|
||||
* @mkhl made their first contribution in https://github.com/libgit2/libgit2/pull/6100
|
||||
* @ammgws made their first contribution in https://github.com/libgit2/libgit2/pull/6106
|
||||
* @yoichi made their first contribution in https://github.com/libgit2/libgit2/pull/6095
|
||||
* @stforek made their first contribution in https://github.com/libgit2/libgit2/pull/6125
|
||||
* @cestrand made their first contribution in https://github.com/libgit2/libgit2/pull/6150
|
||||
* @rex4539 made their first contribution in https://github.com/libgit2/libgit2/pull/6164
|
||||
* @jorio made their first contribution in https://github.com/libgit2/libgit2/pull/6208
|
||||
|
||||
**Full Changelog**: https://github.com/libgit2/libgit2/compare/v1.3.0...v1.4.0
|
||||
|
||||
v1.3
|
||||
----
|
||||
|
||||
@@ -1963,3 +2056,8 @@ v0.22
|
||||
functions. This is not something which we can know to do. A
|
||||
last-resort convenience function is provided in sys/openssl.h,
|
||||
`git_openssl_set_locking()` which can be used to set the locking.
|
||||
|
||||
* `git_reference_*()` functions use mmap() + binary search for packed
|
||||
refs lookups when using the fs backend. Previously all entries were
|
||||
read into a hashtable, which could be slow for repositories with a
|
||||
large number of refs.
|
||||
|
||||
@@ -120,15 +120,15 @@ In addition to new tests, please ensure that your changes do not cause
|
||||
any other test failures. Running the entire test suite is helpful
|
||||
before you submit a pull request. When you build libgit2, the test
|
||||
suite will also be built. You can run most of the tests by simply running
|
||||
the resultant `libgit2_clar` binary. If you want to run a specific
|
||||
the resultant `libgit2_tests` binary. If you want to run a specific
|
||||
unit test, you can name it with the `-s` option. For example:
|
||||
|
||||
libgit2_clar -sstatus::worktree::long_filenames
|
||||
libgit2_tests -sstatus::worktree::long_filenames
|
||||
|
||||
Or you can run an entire class of tests. For example, to run all the
|
||||
worktree status tests:
|
||||
|
||||
libgit2_clar -sstatus::worktree
|
||||
libgit2_tests -sstatus::worktree
|
||||
|
||||
The default test run is fairly exhaustive, but it will exclude some
|
||||
unit tests by default: in particular, those that talk to network
|
||||
@@ -136,7 +136,7 @@ servers and the tests that manipulate the filesystem in onerous
|
||||
ways (and may need to have special privileges to run). To run the
|
||||
network tests:
|
||||
|
||||
libgit2_clar -ionline
|
||||
libgit2_tests -ionline
|
||||
|
||||
In addition, various tests may be enabled by environment variables,
|
||||
like the ones that write exceptionally large repositories or manipulate
|
||||
|
||||
@@ -21,7 +21,7 @@ critical failures (such as a packfile being corrupted, a loose object
|
||||
having the wrong access permissions, etc.) all of which will return -1.
|
||||
When the object lookup is successful, it will return 0.
|
||||
|
||||
If libgit2 was compiled with threads enabled (`-DTHREADSAFE=ON` when using
|
||||
If libgit2 was compiled with threads enabled (`-DUSE_THREADS=ON` when using
|
||||
CMake), then the error message will be kept in thread-local storage, so it
|
||||
will not be modified by other threads. If threads are not enabled, then
|
||||
the error message is in global data.
|
||||
|
||||
@@ -19,7 +19,7 @@ automated fuzz testing. libFuzzer only works with clang.
|
||||
and [`leak`/`address,leak`](https://clang.llvm.org/docs/LeakSanitizer.html).
|
||||
3. Create the cmake build environment and configure the build with the
|
||||
sanitizer chosen: `CC=/usr/bin/clang-6.0 CFLAGS="-fsanitize=address" cmake
|
||||
-DBUILD_CLAR=OFF -DBUILD_FUZZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..`.
|
||||
-DBUILD_TESTS=OFF -DBUILD_FUZZERS=ON -DCMAKE_BUILD_TYPE=RelWithDebInfo ..`.
|
||||
Note that building the fuzzer targets is incompatible with the
|
||||
tests and examples.
|
||||
4. Build libgit2: `cmake --build .`
|
||||
|
||||
@@ -80,4 +80,4 @@ and run it against our description file with the tip of `main` checked out.
|
||||
|
||||
cm doc api.docurium
|
||||
|
||||
It will start up a few proceses and write out the results as a new commit onto the `gh-pages` branch. That can be pushed to GitHub to update what will show up on our documentation reference site.
|
||||
It will start up a few processes and write out the results as a new commit onto the `gh-pages` branch. That can be pushed to GitHub to update what will show up on our documentation reference site.
|
||||
|
||||
@@ -21,6 +21,9 @@ There are some objects which are read-only/immutable and are thus safe
|
||||
to share across threads, such as references and configuration
|
||||
snapshots.
|
||||
|
||||
The `git_odb` object uses locking internally, and is thread-safe to use from
|
||||
multiple threads simultaneously.
|
||||
|
||||
Error messages
|
||||
--------------
|
||||
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
# examples: code usage examples of libgit2
|
||||
|
||||
FILE(GLOB LG2_SOURCES *.c *.h)
|
||||
ADD_EXECUTABLE(lg2 ${LG2_SOURCES})
|
||||
SET_TARGET_PROPERTIES(lg2 PROPERTIES C_STANDARD 90)
|
||||
file(GLOB SRC_EXAMPLES *.c *.h)
|
||||
|
||||
add_executable(lg2 ${SRC_EXAMPLES})
|
||||
set_target_properties(lg2 PROPERTIES C_STANDARD 90)
|
||||
|
||||
# Ensure that we do not use deprecated functions internally
|
||||
ADD_DEFINITIONS(-DGIT_DEPRECATE_HARD)
|
||||
add_definitions(-DGIT_DEPRECATE_HARD)
|
||||
|
||||
IF(WIN32 OR ANDROID)
|
||||
TARGET_LINK_LIBRARIES(lg2 git2)
|
||||
ELSE()
|
||||
TARGET_LINK_LIBRARIES(lg2 git2 pthread)
|
||||
ENDIF()
|
||||
target_include_directories(lg2 PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
|
||||
target_include_directories(lg2 SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
|
||||
if(WIN32 OR ANDROID)
|
||||
target_link_libraries(lg2 libgit2package)
|
||||
else()
|
||||
target_link_libraries(lg2 libgit2package pthread)
|
||||
endif()
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
|
||||
enum index_mode {
|
||||
INDEX_NONE,
|
||||
INDEX_ADD,
|
||||
INDEX_ADD
|
||||
};
|
||||
|
||||
struct index_options {
|
||||
@@ -110,22 +110,7 @@ int print_matched_cb(const char *path, const char *matched_pathspec, void *paylo
|
||||
return ret;
|
||||
}
|
||||
|
||||
void init_array(git_strarray *array, int argc, char **argv)
|
||||
{
|
||||
unsigned int i;
|
||||
|
||||
array->count = argc;
|
||||
array->strings = calloc(array->count, sizeof(char *));
|
||||
assert(array->strings != NULL);
|
||||
|
||||
for (i = 0; i < array->count; i++) {
|
||||
array->strings[i] = argv[i];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
void print_usage(void)
|
||||
static void print_usage(void)
|
||||
{
|
||||
fprintf(stderr, "usage: add [options] [--] file-spec [file-spec] [...]\n\n");
|
||||
fprintf(stderr, "\t-n, --dry-run dry run\n");
|
||||
|
||||
@@ -49,7 +49,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
|
||||
if (o.F) blameopts.flags |= GIT_BLAME_FIRST_PARENT;
|
||||
|
||||
/**
|
||||
* The commit range comes in "commitish" form. Use the rev-parse API to
|
||||
* The commit range comes in "committish" form. Use the rev-parse API to
|
||||
* nail down the end points.
|
||||
*/
|
||||
if (o.commitspec) {
|
||||
@@ -70,7 +70,7 @@ int lg2_blame(git_repository *repo, int argc, char *argv[])
|
||||
|
||||
/**
|
||||
* Get the raw data inside the blob for output. We use the
|
||||
* `commitish:path/to/file.txt` format to find it.
|
||||
* `committish:path/to/file.txt` format to find it.
|
||||
*/
|
||||
if (git_oid_is_zero(&blameopts.newest_commit))
|
||||
strcpy(spec, "HEAD");
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
* This does have:
|
||||
*
|
||||
* - Example of performing a git commit with a comment
|
||||
*
|
||||
*
|
||||
*/
|
||||
int lg2_commit(git_repository *repo, int argc, char **argv)
|
||||
{
|
||||
@@ -36,10 +36,10 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
|
||||
|
||||
git_oid commit_oid,tree_oid;
|
||||
git_tree *tree;
|
||||
git_index *index;
|
||||
git_index *index;
|
||||
git_object *parent = NULL;
|
||||
git_reference *ref = NULL;
|
||||
git_signature *signature;
|
||||
git_signature *signature;
|
||||
|
||||
/* Validate args */
|
||||
if (argc < 3 || strcmp(opt, "-m") != 0) {
|
||||
@@ -62,9 +62,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
|
||||
check_lg2(git_index_write(index), "Could not write index", NULL);;
|
||||
|
||||
check_lg2(git_tree_lookup(&tree, repo, &tree_oid), "Error looking up tree", NULL);
|
||||
|
||||
|
||||
check_lg2(git_signature_default(&signature, repo), "Error creating signature", NULL);
|
||||
|
||||
|
||||
check_lg2(git_commit_create_v(
|
||||
&commit_oid,
|
||||
repo,
|
||||
@@ -78,7 +78,9 @@ int lg2_commit(git_repository *repo, int argc, char **argv)
|
||||
|
||||
git_index_free(index);
|
||||
git_signature_free(signature);
|
||||
git_tree_free(tree);
|
||||
git_tree_free(tree);
|
||||
git_object_free(parent);
|
||||
git_reference_free(ref);
|
||||
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define snprintf sprintf_s
|
||||
#define snprintf _snprintf
|
||||
#define strcasecmp strcmpi
|
||||
#endif
|
||||
|
||||
|
||||
@@ -344,7 +344,7 @@ static void parse_opts(struct diff_options *o, int argc, char *argv[])
|
||||
static void diff_print_stats(git_diff *diff, struct diff_options *o)
|
||||
{
|
||||
git_diff_stats *stats;
|
||||
git_buf b = GIT_BUF_INIT_CONST(NULL, 0);
|
||||
git_buf b = GIT_BUF_INIT;
|
||||
git_diff_stats_format_t format = 0;
|
||||
|
||||
check_lg2(
|
||||
|
||||
@@ -17,7 +17,6 @@ int lg2_index_pack(git_repository *repo, int argc, char **argv)
|
||||
git_indexer *idx;
|
||||
git_indexer_progress stats = {0, 0};
|
||||
int error;
|
||||
char hash[GIT_OID_HEXSZ + 1] = {0};
|
||||
int fd;
|
||||
ssize_t read_bytes;
|
||||
char buf[512];
|
||||
@@ -61,8 +60,7 @@ int lg2_index_pack(git_repository *repo, int argc, char **argv)
|
||||
|
||||
printf("\rIndexing %u of %u\n", stats.indexed_objects, stats.total_objects);
|
||||
|
||||
git_oid_fmt(hash, git_indexer_hash(idx));
|
||||
puts(hash);
|
||||
puts(git_indexer_name(idx));
|
||||
|
||||
cleanup:
|
||||
close(fd);
|
||||
|
||||
@@ -27,7 +27,7 @@ enum subcmd {
|
||||
subcmd_remove,
|
||||
subcmd_rename,
|
||||
subcmd_seturl,
|
||||
subcmd_show,
|
||||
subcmd_show
|
||||
};
|
||||
|
||||
struct remote_opts {
|
||||
|
||||
@@ -38,7 +38,7 @@ enum {
|
||||
FORMAT_DEFAULT = 0,
|
||||
FORMAT_LONG = 1,
|
||||
FORMAT_SHORT = 2,
|
||||
FORMAT_PORCELAIN = 3,
|
||||
FORMAT_PORCELAIN = 3
|
||||
};
|
||||
|
||||
#define MAX_PATHSPEC 8
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
LINK_DIRECTORIES(${LIBGIT2_LIBDIRS})
|
||||
INCLUDE_DIRECTORIES(${LIBGIT2_INCLUDES})
|
||||
INCLUDE_DIRECTORIES(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
# fuzzers: libFuzzer and standalone fuzzing utilities
|
||||
|
||||
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
|
||||
ADD_C_FLAG(-fsanitize=fuzzer)
|
||||
ENDIF ()
|
||||
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
|
||||
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
|
||||
add_c_flag(-fsanitize=fuzzer)
|
||||
add_c_flag(-fsanitize=fuzzer-no-link)
|
||||
unset(CMAKE_REQUIRED_FLAGS)
|
||||
endif()
|
||||
|
||||
FILE(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
|
||||
FOREACH(fuzz_target_src ${SRC_FUZZ})
|
||||
STRING(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
|
||||
STRING(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
|
||||
file(GLOB SRC_FUZZERS RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)
|
||||
foreach(fuzz_target_src ${SRC_FUZZERS})
|
||||
string(REPLACE ".c" "" fuzz_target_name ${fuzz_target_src})
|
||||
string(REPLACE "_fuzzer" "" fuzz_name ${fuzz_target_name})
|
||||
|
||||
SET(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
|
||||
IF(USE_STANDALONE_FUZZERS)
|
||||
LIST(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
|
||||
ENDIF()
|
||||
ADD_EXECUTABLE(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
|
||||
SET_TARGET_PROPERTIES(${fuzz_target_name} PROPERTIES C_STANDARD 90)
|
||||
TARGET_LINK_LIBRARIES(${fuzz_target_name} ${LIBGIT2_LIBS})
|
||||
set(${fuzz_target_name}_SOURCES ${fuzz_target_src} ${LIBGIT2_OBJECTS})
|
||||
if(USE_STANDALONE_FUZZERS)
|
||||
list(APPEND ${fuzz_target_name}_SOURCES "standalone_driver.c")
|
||||
endif()
|
||||
add_executable(${fuzz_target_name} ${${fuzz_target_name}_SOURCES})
|
||||
set_target_properties(${fuzz_target_name} PROPERTIES C_STANDARD 90)
|
||||
|
||||
ADD_TEST(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
|
||||
ENDFOREACH()
|
||||
target_include_directories(${fuzz_target_name} PRIVATE ${LIBGIT2_INCLUDES} ${LIBGIT2_DEPENDENCY_INCLUDES})
|
||||
target_include_directories(${fuzz_target_name} SYSTEM PRIVATE ${LIBGIT2_SYSTEM_INCLUDES})
|
||||
|
||||
target_link_libraries(${fuzz_target_name} ${LIBGIT2_SYSTEM_LIBS})
|
||||
|
||||
add_test(${fuzz_target_name} "${CMAKE_CURRENT_BINARY_DIR}/${fuzz_target_name}" "${CMAKE_CURRENT_SOURCE_DIR}/corpora/${fuzz_name}")
|
||||
endforeach()
|
||||
|
||||
@@ -11,12 +11,14 @@
|
||||
|
||||
#include "git2.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "common.h"
|
||||
#include "str.h"
|
||||
#include "futils.h"
|
||||
#include "hash.h"
|
||||
#include "commit_graph.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
GIT_UNUSED(argc);
|
||||
@@ -33,7 +35,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
git_commit_graph_file file = {{0}};
|
||||
git_commit_graph_entry e;
|
||||
git_buf commit_graph_buf = GIT_BUF_INIT;
|
||||
git_str commit_graph_buf = GIT_STR_INIT;
|
||||
unsigned char hash[GIT_HASH_SHA1_SIZE];
|
||||
git_oid oid = {{0}};
|
||||
bool append_hash = false;
|
||||
|
||||
@@ -50,22 +53,24 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
size -= 4;
|
||||
|
||||
if (append_hash) {
|
||||
if (git_buf_init(&commit_graph_buf, size + sizeof(oid)) < 0)
|
||||
if (git_str_init(&commit_graph_buf, size + GIT_HASH_SHA1_SIZE) < 0)
|
||||
goto cleanup;
|
||||
if (git_hash_buf(&oid, data, size) < 0) {
|
||||
if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) {
|
||||
fprintf(stderr, "Failed to compute the SHA1 hash\n");
|
||||
abort();
|
||||
}
|
||||
memcpy(commit_graph_buf.ptr, data, size);
|
||||
memcpy(commit_graph_buf.ptr + size, &oid, sizeof(oid));
|
||||
memcpy(commit_graph_buf.ptr + size, hash, GIT_HASH_SHA1_SIZE);
|
||||
|
||||
memcpy(oid.id, hash, GIT_OID_RAWSZ);
|
||||
} else {
|
||||
git_buf_attach_notowned(&commit_graph_buf, (char *)data, size);
|
||||
git_str_attach_notowned(&commit_graph_buf, (char *)data, size);
|
||||
}
|
||||
|
||||
if (git_commit_graph_file_parse(
|
||||
&file,
|
||||
(const unsigned char *)git_buf_cstr(&commit_graph_buf),
|
||||
git_buf_len(&commit_graph_buf))
|
||||
(const unsigned char *)git_str_cstr(&commit_graph_buf),
|
||||
git_str_len(&commit_graph_buf))
|
||||
< 0)
|
||||
goto cleanup;
|
||||
|
||||
@@ -75,6 +80,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
||||
cleanup:
|
||||
git_commit_graph_file_close(&file);
|
||||
git_buf_dispose(&commit_graph_buf);
|
||||
git_str_dispose(&commit_graph_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
#include "git2.h"
|
||||
#include "config_backend.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
int foreach_cb(const git_config_entry *entry, void *payload)
|
||||
static int foreach_cb(const git_config_entry *entry, void *payload)
|
||||
{
|
||||
UNUSED(entry);
|
||||
UNUSED(payload);
|
||||
|
||||
BIN
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
Normal file
BIN
fuzzers/corpora/midx/666a779eed16847c6930a71c0547a34e52db409e
Normal file
Binary file not shown.
@@ -64,7 +64,7 @@ slack channel once you've registered.
|
||||
|
||||
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
|
||||
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**
|
||||
@@ -187,18 +187,18 @@ Once built, you can run the tests from the `build` directory with the command
|
||||
|
||||
Alternatively you can run the test suite directly using,
|
||||
|
||||
$ ./libgit2_clar
|
||||
$ ./libgit2_tests
|
||||
|
||||
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
|
||||
$ ./libgit2_tests -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
|
||||
$ ./libgit2_tests -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
|
||||
@@ -229,7 +229,7 @@ The following CMake variables are declared:
|
||||
- `LIB_INSTALL_DIR`: Where to install libraries to.
|
||||
- `INCLUDE_INSTALL_DIR`: 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)
|
||||
- `BUILD_TESTS`: Build [Clar](https://github.com/vmg/clar)-based test suite (defaults to ON)
|
||||
- `THREADSAFE`: Build libgit2 with threading support (defaults to ON)
|
||||
- `STDCALL`: Build libgit2 as `stdcall`. Turn off for `cdecl` (Windows; defaults to ON)
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@
|
||||
#include "git2/sys/transport.h"
|
||||
#include "futils.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
struct fuzzer_buffer {
|
||||
@@ -130,7 +132,7 @@ static int fuzzer_subtransport_new(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuzzer_subtransport_cb(
|
||||
static int fuzzer_subtransport_cb(
|
||||
git_smart_subtransport **out,
|
||||
git_transport *owner,
|
||||
void *payload)
|
||||
@@ -145,7 +147,7 @@ int fuzzer_subtransport_cb(
|
||||
return 0;
|
||||
}
|
||||
|
||||
int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
|
||||
static int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
|
||||
{
|
||||
git_smart_subtransport_definition def = {
|
||||
fuzzer_subtransport_cb,
|
||||
@@ -155,7 +157,7 @@ int fuzzer_transport_cb(git_transport **out, git_remote *owner, void *param)
|
||||
return git_transport_smart(out, owner, &def);
|
||||
}
|
||||
|
||||
void fuzzer_git_abort(const char *op)
|
||||
static void fuzzer_git_abort(const char *op)
|
||||
{
|
||||
const git_error *err = git_error_last();
|
||||
fprintf(stderr, "unexpected libgit error: %s: %s\n",
|
||||
|
||||
@@ -11,12 +11,13 @@
|
||||
|
||||
#include "git2.h"
|
||||
|
||||
#include "buffer.h"
|
||||
#include "common.h"
|
||||
#include "futils.h"
|
||||
#include "hash.h"
|
||||
#include "midx.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
{
|
||||
GIT_UNUSED(argc);
|
||||
@@ -33,7 +34,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
git_midx_file idx = {{0}};
|
||||
git_midx_entry e;
|
||||
git_buf midx_buf = GIT_BUF_INIT;
|
||||
git_str midx_buf = GIT_STR_INIT;
|
||||
unsigned char hash[GIT_HASH_SHA1_SIZE];
|
||||
git_oid oid = {{0}};
|
||||
bool append_hash = false;
|
||||
|
||||
@@ -50,19 +52,21 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
size -= 4;
|
||||
|
||||
if (append_hash) {
|
||||
if (git_buf_init(&midx_buf, size + sizeof(oid)) < 0)
|
||||
if (git_str_init(&midx_buf, size + GIT_HASH_SHA1_SIZE) < 0)
|
||||
goto cleanup;
|
||||
if (git_hash_buf(&oid, data, size) < 0) {
|
||||
if (git_hash_buf(hash, data, size, GIT_HASH_ALGORITHM_SHA1) < 0) {
|
||||
fprintf(stderr, "Failed to compute the SHA1 hash\n");
|
||||
abort();
|
||||
}
|
||||
memcpy(midx_buf.ptr, data, size);
|
||||
memcpy(midx_buf.ptr + size, &oid, sizeof(oid));
|
||||
memcpy(midx_buf.ptr + size, hash, GIT_HASH_SHA1_SIZE);
|
||||
|
||||
memcpy(oid.id, hash, GIT_OID_RAWSZ);
|
||||
} else {
|
||||
git_buf_attach_notowned(&midx_buf, (char *)data, size);
|
||||
git_str_attach_notowned(&midx_buf, (char *)data, size);
|
||||
}
|
||||
|
||||
if (git_midx_parse(&idx, (const unsigned char *)git_buf_cstr(&midx_buf), git_buf_len(&midx_buf)) < 0)
|
||||
if (git_midx_parse(&idx, (const unsigned char *)git_str_cstr(&midx_buf), git_str_len(&midx_buf)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
/* Search for any oid, just to exercise that codepath. */
|
||||
@@ -71,6 +75,6 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
|
||||
cleanup:
|
||||
git_midx_close(&idx);
|
||||
git_buf_dispose(&midx_buf);
|
||||
git_str_dispose(&midx_buf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include "git2.h"
|
||||
#include "object.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
|
||||
@@ -12,7 +12,9 @@
|
||||
#include "git2.h"
|
||||
#include "git2/sys/mempack.h"
|
||||
#include "common.h"
|
||||
#include "buffer.h"
|
||||
#include "str.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
static git_odb *odb = NULL;
|
||||
static git_odb_backend *mempack = NULL;
|
||||
@@ -53,7 +55,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
{
|
||||
git_indexer_progress stats = {0, 0};
|
||||
git_indexer *indexer = NULL;
|
||||
git_buf path = GIT_BUF_INIT;
|
||||
git_str path = GIT_STR_INIT;
|
||||
git_oid oid;
|
||||
bool append_hash = false;
|
||||
|
||||
@@ -92,26 +94,26 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size)
|
||||
fprintf(stderr, "Failed to compute the SHA1 hash\n");
|
||||
abort();
|
||||
}
|
||||
if (git_indexer_append(indexer, &oid, sizeof(oid), &stats) < 0) {
|
||||
if (git_indexer_append(indexer, &oid.id, GIT_OID_RAWSZ, &stats) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
if (git_indexer_commit(indexer, &stats) < 0)
|
||||
goto cleanup;
|
||||
|
||||
if (git_buf_printf(&path, "pack-%s.idx", git_oid_tostr_s(git_indexer_hash(indexer))) < 0)
|
||||
if (git_str_printf(&path, "pack-%s.idx", git_indexer_name(indexer)) < 0)
|
||||
goto cleanup;
|
||||
p_unlink(git_buf_cstr(&path));
|
||||
p_unlink(git_str_cstr(&path));
|
||||
|
||||
git_buf_clear(&path);
|
||||
git_str_clear(&path);
|
||||
|
||||
if (git_buf_printf(&path, "pack-%s.pack", git_oid_tostr_s(git_indexer_hash(indexer))) < 0)
|
||||
if (git_str_printf(&path, "pack-%s.pack", git_indexer_name(indexer)) < 0)
|
||||
goto cleanup;
|
||||
p_unlink(git_buf_cstr(&path));
|
||||
p_unlink(git_str_cstr(&path));
|
||||
|
||||
cleanup:
|
||||
git_mempack_reset(mempack);
|
||||
git_indexer_free(indexer);
|
||||
git_buf_dispose(&path);
|
||||
git_str_dispose(&path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,8 @@
|
||||
#include "patch.h"
|
||||
#include "patch_parse.h"
|
||||
|
||||
#include "standalone_driver.h"
|
||||
|
||||
#define UNUSED(x) (void)(x)
|
||||
|
||||
int LLVMFuzzerInitialize(int *argc, char ***argv)
|
||||
|
||||
@@ -11,12 +11,11 @@
|
||||
#include "futils.h"
|
||||
#include "path.h"
|
||||
|
||||
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
|
||||
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
|
||||
#include "standalone_driver.h"
|
||||
|
||||
static int run_one_file(const char *filename)
|
||||
{
|
||||
git_buf buf = GIT_BUF_INIT;
|
||||
git_str buf = GIT_STR_INIT;
|
||||
int error = 0;
|
||||
|
||||
if (git_futils_readbuffer(&buf, filename) < 0) {
|
||||
@@ -27,7 +26,7 @@ static int run_one_file(const char *filename)
|
||||
|
||||
LLVMFuzzerTestOneInput((const unsigned char *)buf.ptr, buf.size);
|
||||
exit:
|
||||
git_buf_dispose(&buf);
|
||||
git_str_dispose(&buf);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -52,7 +51,7 @@ int main(int argc, char **argv)
|
||||
fprintf(stderr, "Running %s against %s\n", argv[0], argv[1]);
|
||||
LLVMFuzzerInitialize(&argc, &argv);
|
||||
|
||||
if (git_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
|
||||
if (git_fs_path_dirload(&corpus_files, argv[1], 0, 0x0) < 0) {
|
||||
fprintf(stderr, "Failed to scan corpus directory '%s': %s\n",
|
||||
argv[1], git_error_last()->message);
|
||||
error = -1;
|
||||
|
||||
14
fuzzers/standalone_driver.h
Normal file
14
fuzzers/standalone_driver.h
Normal file
@@ -0,0 +1,14 @@
|
||||
/*
|
||||
* Copyright (C) the libgit2 contributors. All rights reserved.
|
||||
*
|
||||
* This file is part of libgit2, distributed under the GNU GPL v2 with
|
||||
* a Linking Exception. For full terms see the included COPYING file.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE_standalone_driver_h__
|
||||
#define INCLUDE_standalone_driver_h__
|
||||
|
||||
extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size);
|
||||
extern int LLVMFuzzerInitialize(int *argc, char ***argv);
|
||||
|
||||
#endif
|
||||
@@ -32,6 +32,8 @@ GIT_BEGIN_DECL
|
||||
*
|
||||
* @param delta The delta to be applied
|
||||
* @param payload User-specified payload
|
||||
* @return 0 if the delta is applied, < 0 if the apply process will be aborted
|
||||
* or > 0 if the delta will not be applied.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_apply_delta_cb)(
|
||||
const git_diff_delta *delta,
|
||||
@@ -48,6 +50,8 @@ typedef int GIT_CALLBACK(git_apply_delta_cb)(
|
||||
*
|
||||
* @param hunk The hunk to be applied
|
||||
* @param payload User-specified payload
|
||||
* @return 0 if the hunk is applied, < 0 if the apply process will be aborted
|
||||
* or > 0 if the hunk will not be applied.
|
||||
*/
|
||||
typedef int GIT_CALLBACK(git_apply_hunk_cb)(
|
||||
const git_diff_hunk *hunk,
|
||||
@@ -59,7 +63,7 @@ typedef enum {
|
||||
* Don't actually make changes, just test that the patch applies.
|
||||
* This is the equivalent of `git apply --check`.
|
||||
*/
|
||||
GIT_APPLY_CHECK = (1 << 0),
|
||||
GIT_APPLY_CHECK = (1 << 0)
|
||||
} git_apply_flags_t;
|
||||
|
||||
/**
|
||||
@@ -89,6 +93,16 @@ typedef struct {
|
||||
#define GIT_APPLY_OPTIONS_VERSION 1
|
||||
#define GIT_APPLY_OPTIONS_INIT {GIT_APPLY_OPTIONS_VERSION}
|
||||
|
||||
/**
|
||||
* Initialize git_apply_options structure
|
||||
*
|
||||
* Initialize a `git_apply_options` with default values. Equivalent to creating
|
||||
* an instance with GIT_APPLY_OPTIONS_INIT.
|
||||
*
|
||||
* @param opts The `git_apply_options` struct to initialize.
|
||||
* @param version The struct version; pass `GIT_APPLY_OPTIONS_VERSION`
|
||||
* @return 0 on success or -1 on failure.
|
||||
*/
|
||||
GIT_EXTERN(int) git_apply_options_init(git_apply_options *opts, unsigned int version);
|
||||
|
||||
/**
|
||||
@@ -127,7 +141,7 @@ typedef enum {
|
||||
* Apply the patch to both the working directory and the index.
|
||||
* This is the equivalent of `git apply --index`.
|
||||
*/
|
||||
GIT_APPLY_LOCATION_BOTH = 2,
|
||||
GIT_APPLY_LOCATION_BOTH = 2
|
||||
} git_apply_location_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -83,7 +83,7 @@ typedef enum {
|
||||
GIT_ATTR_VALUE_UNSPECIFIED = 0, /**< The attribute has been left unspecified */
|
||||
GIT_ATTR_VALUE_TRUE, /**< The attribute has been set */
|
||||
GIT_ATTR_VALUE_FALSE, /**< The attribute has been unset */
|
||||
GIT_ATTR_VALUE_STRING, /**< This attribute has a value */
|
||||
GIT_ATTR_VALUE_STRING /**< This attribute has a value */
|
||||
} git_attr_value_t;
|
||||
|
||||
/**
|
||||
@@ -177,6 +177,7 @@ typedef struct {
|
||||
* not have to exist, but if it does not, then it will be
|
||||
* treated as a plain file (not a directory).
|
||||
* @param name The name of the attribute to look up.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get(
|
||||
const char **value_out,
|
||||
@@ -199,6 +200,7 @@ GIT_EXTERN(int) git_attr_get(
|
||||
* not have to exist, but if it does not, then it will be
|
||||
* treated as a plain file (not a directory).
|
||||
* @param name The name of the attribute to look up.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_ext(
|
||||
const char **value_out,
|
||||
@@ -235,6 +237,7 @@ GIT_EXTERN(int) git_attr_get_ext(
|
||||
* it will be treated as a plain file (i.e. not a directory).
|
||||
* @param num_attr The number of attributes being looked up
|
||||
* @param names An array of num_attr strings containing attribute names.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_many(
|
||||
const char **values_out,
|
||||
@@ -259,6 +262,7 @@ GIT_EXTERN(int) git_attr_get_many(
|
||||
* it will be treated as a plain file (i.e. not a directory).
|
||||
* @param num_attr The number of attributes being looked up
|
||||
* @param names An array of num_attr strings containing attribute names.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_get_many_ext(
|
||||
const char **values_out,
|
||||
@@ -344,11 +348,16 @@ GIT_EXTERN(int) git_attr_cache_flush(
|
||||
* Add a macro definition.
|
||||
*
|
||||
* Macros will automatically be loaded from the top level `.gitattributes`
|
||||
* file of the repository (plus the build-in "binary" macro). This
|
||||
* file of the repository (plus the built-in "binary" macro). This
|
||||
* function allows you to add others. For example, to add the default
|
||||
* macro, you would call:
|
||||
*
|
||||
* git_attr_add_macro(repo, "binary", "-diff -crlf");
|
||||
*
|
||||
* @param repo The repository to add the macro in.
|
||||
* @param name The name of the macro.
|
||||
* @param values The value for the macro.
|
||||
* @return 0 or an error code.
|
||||
*/
|
||||
GIT_EXTERN(int) git_attr_add_macro(
|
||||
git_repository *repo,
|
||||
|
||||
@@ -73,7 +73,7 @@ typedef enum {
|
||||
GIT_BLAME_USE_MAILMAP = (1<<5),
|
||||
|
||||
/** Ignore whitespace differences */
|
||||
GIT_BLAME_IGNORE_WHITESPACE = (1<<6),
|
||||
GIT_BLAME_IGNORE_WHITESPACE = (1<<6)
|
||||
} git_blame_flag_t;
|
||||
|
||||
/**
|
||||
@@ -203,6 +203,9 @@ typedef struct git_blame git_blame;
|
||||
|
||||
/**
|
||||
* Gets the number of hunks that exist in the blame structure.
|
||||
*
|
||||
* @param blame The blame structure to query.
|
||||
* @return The number of hunks.
|
||||
*/
|
||||
GIT_EXTERN(uint32_t) git_blame_get_hunk_count(git_blame *blame);
|
||||
|
||||
|
||||
@@ -119,7 +119,7 @@ typedef enum {
|
||||
* When set, filters will be loaded from a `.gitattributes` file
|
||||
* in the specified commit.
|
||||
*/
|
||||
GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3),
|
||||
GIT_BLOB_FILTER_ATTRIBUTES_FROM_COMMIT = (1 << 3)
|
||||
} git_blob_filter_flag_t;
|
||||
|
||||
/**
|
||||
@@ -284,12 +284,25 @@ GIT_EXTERN(int) git_blob_create_from_buffer(
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_is_binary(const git_blob *blob);
|
||||
|
||||
/**
|
||||
* Determine if the given content is most certainly binary or not;
|
||||
* this is the same mechanism used by `git_blob_is_binary` but only
|
||||
* looking at raw data.
|
||||
*
|
||||
* @param data The blob data which content should be analyzed
|
||||
* @param len The length of the data
|
||||
* @return 1 if the content of the blob is detected
|
||||
* as binary; 0 otherwise.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_data_is_binary(const char *data, size_t len);
|
||||
|
||||
/**
|
||||
* Create an in-memory copy of a blob. The copy must be explicitly
|
||||
* free'd or it will leak.
|
||||
*
|
||||
* @param out Pointer to store the copy of the object
|
||||
* @param source Original object to copy
|
||||
* @return 0.
|
||||
*/
|
||||
GIT_EXTERN(int) git_blob_dup(git_blob **out, git_blob *source);
|
||||
|
||||
|
||||
@@ -34,6 +34,8 @@ GIT_BEGIN_DECL
|
||||
*
|
||||
* @param out Pointer where to store the underlying reference.
|
||||
*
|
||||
* @param repo the repository to create the branch in.
|
||||
*
|
||||
* @param branch_name Name for the branch; this name is
|
||||
* validated for consistency. It should also not conflict with
|
||||
* an already existing branch name.
|
||||
@@ -127,8 +129,8 @@ GIT_EXTERN(void) git_branch_iterator_free(git_branch_iterator *iter);
|
||||
* See `git_tag_create()` for rules about valid names.
|
||||
*
|
||||
* Note that if the move succeeds, the old reference object will not
|
||||
+ be valid anymore, and should be freed immediately by the user using
|
||||
+ `git_reference_free()`.
|
||||
* be valid anymore, and should be freed immediately by the user using
|
||||
* `git_reference_free()`.
|
||||
*
|
||||
* @param out New reference object for the updated name.
|
||||
*
|
||||
|
||||
@@ -23,110 +23,50 @@ GIT_BEGIN_DECL
|
||||
*
|
||||
* Sometimes libgit2 wants to return an allocated data buffer to the
|
||||
* caller and have the caller take responsibility for freeing that memory.
|
||||
* This can be awkward if the caller does not have easy access to the same
|
||||
* allocation functions that libgit2 is using. In those cases, libgit2
|
||||
* will fill in a `git_buf` and the caller can use `git_buf_dispose()` to
|
||||
* release it when they are done.
|
||||
* To make ownership clear in these cases, libgit2 uses `git_buf` to
|
||||
* return this data. Callers should use `git_buf_dispose()` to release
|
||||
* the memory when they are done.
|
||||
*
|
||||
* A `git_buf` may also be used for the caller to pass in a reference to
|
||||
* a block of memory they hold. In this case, libgit2 will not resize or
|
||||
* free the memory, but will read from it as needed.
|
||||
*
|
||||
* Some APIs may occasionally do something slightly unusual with a buffer,
|
||||
* such as setting `ptr` to a value that was passed in by the user. In
|
||||
* those cases, the behavior will be clearly documented by the API.
|
||||
* A `git_buf` contains a pointer to a NUL-terminated C string, and
|
||||
* the length of the string (not including the NUL terminator).
|
||||
*/
|
||||
typedef struct {
|
||||
/**
|
||||
* The buffer contents.
|
||||
*
|
||||
* `ptr` points to the start of the allocated memory. If it is NULL,
|
||||
* then the `git_buf` is considered empty and libgit2 will feel free
|
||||
* to overwrite it with new data.
|
||||
* The buffer contents. `ptr` points to the start of the buffer
|
||||
* being returned. The buffer's length (in bytes) is specified
|
||||
* by the `size` member of the structure, and contains a NUL
|
||||
* terminator at position `(size + 1)`.
|
||||
*/
|
||||
char *ptr;
|
||||
char *ptr;
|
||||
|
||||
/**
|
||||
* `asize` holds the known total amount of allocated memory if the `ptr`
|
||||
* was allocated by libgit2. It may be larger than `size`. If `ptr`
|
||||
* was not allocated by libgit2 and should not be resized and/or freed,
|
||||
* then `asize` will be set to zero.
|
||||
* This field is reserved and unused.
|
||||
*/
|
||||
size_t asize;
|
||||
size_t reserved;
|
||||
|
||||
/**
|
||||
* `size` holds the size (in bytes) of the data that is actually used.
|
||||
* The length (in bytes) of the buffer pointed to by `ptr`,
|
||||
* not including a NUL terminator.
|
||||
*/
|
||||
size_t size;
|
||||
} git_buf;
|
||||
|
||||
/**
|
||||
* Static initializer for git_buf from static buffer
|
||||
* Use to initialize a `git_buf` before passing it to a function that
|
||||
* will populate it.
|
||||
*/
|
||||
#define GIT_BUF_INIT_CONST(STR,LEN) { (char *)(STR), 0, (size_t)(LEN) }
|
||||
#define GIT_BUF_INIT { NULL, 0, 0 }
|
||||
|
||||
/**
|
||||
* Free the memory referred to by the git_buf.
|
||||
*
|
||||
* Note that this does not free the `git_buf` itself, just the memory
|
||||
* pointed to by `buffer->ptr`. This will not free the memory if it looks
|
||||
* like it was not allocated internally, but it will clear the buffer back
|
||||
* to the empty state.
|
||||
* pointed to by `buffer->ptr`.
|
||||
*
|
||||
* @param buffer The buffer to deallocate
|
||||
*/
|
||||
GIT_EXTERN(void) git_buf_dispose(git_buf *buffer);
|
||||
|
||||
/**
|
||||
* Resize the buffer allocation to make more space.
|
||||
*
|
||||
* This will attempt to grow the buffer to accommodate the target size.
|
||||
*
|
||||
* If the buffer refers to memory that was not allocated by libgit2 (i.e.
|
||||
* the `asize` field is zero), then `ptr` will be replaced with a newly
|
||||
* allocated block of data. Be careful so that memory allocated by the
|
||||
* caller is not lost. As a special variant, if you pass `target_size` as
|
||||
* 0 and the memory is not allocated by libgit2, this will allocate a new
|
||||
* buffer of size `size` and copy the external data into it.
|
||||
*
|
||||
* Currently, this will never shrink a buffer, only expand it.
|
||||
*
|
||||
* If the allocation fails, this will return an error and the buffer will be
|
||||
* marked as invalid for future operations, invaliding the contents.
|
||||
*
|
||||
* @param buffer The buffer to be resized; may or may not be allocated yet
|
||||
* @param target_size The desired available size
|
||||
* @return 0 on success, -1 on allocation failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_grow(git_buf *buffer, size_t target_size);
|
||||
|
||||
/**
|
||||
* Set buffer to a copy of some raw data.
|
||||
*
|
||||
* @param buffer The buffer to set
|
||||
* @param data The data to copy into the buffer
|
||||
* @param datalen The length of the data to copy into the buffer
|
||||
* @return 0 on success, -1 on allocation failure
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_set(
|
||||
git_buf *buffer, const void *data, size_t datalen);
|
||||
|
||||
/**
|
||||
* Check quickly if buffer looks like it contains binary data
|
||||
*
|
||||
* @param buf Buffer to check
|
||||
* @return 1 if buffer looks like non-text data
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_is_binary(const git_buf *buf);
|
||||
|
||||
/**
|
||||
* Check quickly if buffer contains a NUL byte
|
||||
*
|
||||
* @param buf Buffer to check
|
||||
* @return 1 if buffer contains a NUL byte
|
||||
*/
|
||||
GIT_EXTERN(int) git_buf_contains_nul(const git_buf *buf);
|
||||
|
||||
GIT_END_DECL
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -44,7 +44,7 @@ typedef enum git_cert_t {
|
||||
* information about the certificate. This is used when using
|
||||
* curl.
|
||||
*/
|
||||
GIT_CERT_STRARRAY,
|
||||
GIT_CERT_STRARRAY
|
||||
} git_cert_t;
|
||||
|
||||
/**
|
||||
@@ -82,7 +82,7 @@ typedef enum {
|
||||
/** SHA-256 is available */
|
||||
GIT_CERT_SSH_SHA256 = (1 << 2),
|
||||
/** Raw hostkey is available */
|
||||
GIT_CERT_SSH_RAW = (1 << 3),
|
||||
GIT_CERT_SSH_RAW = (1 << 3)
|
||||
} git_cert_ssh_t;
|
||||
|
||||
typedef enum {
|
||||
|
||||
@@ -182,7 +182,10 @@ typedef enum {
|
||||
* notifications; don't update the working directory or index.
|
||||
*/
|
||||
GIT_CHECKOUT_DRY_RUN = (1u << 24),
|
||||
|
||||
|
||||
/** Include common ancestor data in zdiff3 format for conflicts */
|
||||
GIT_CHECKOUT_CONFLICT_STYLE_ZDIFF3 = (1u << 25),
|
||||
|
||||
/**
|
||||
* THE FOLLOWING OPTIONS ARE NOT YET IMPLEMENTED
|
||||
*/
|
||||
@@ -190,7 +193,7 @@ typedef enum {
|
||||
/** Recursively checkout submodules with same options (NOT IMPLEMENTED) */
|
||||
GIT_CHECKOUT_UPDATE_SUBMODULES = (1u << 16),
|
||||
/** Recursively checkout submodules if HEAD moved in super repo (NOT IMPLEMENTED) */
|
||||
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17),
|
||||
GIT_CHECKOUT_UPDATE_SUBMODULES_IF_CHANGED = (1u << 17)
|
||||
|
||||
} git_checkout_strategy_t;
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef enum {
|
||||
* Bypass the git-aware transport, but do not try to use
|
||||
* hardlinks.
|
||||
*/
|
||||
GIT_CLONE_LOCAL_NO_LINKS,
|
||||
GIT_CLONE_LOCAL_NO_LINKS
|
||||
} git_clone_local_t;
|
||||
|
||||
/**
|
||||
@@ -74,8 +74,8 @@ typedef int GIT_CALLBACK(git_remote_create_cb)(
|
||||
void *payload);
|
||||
|
||||
/**
|
||||
* The signature of a function matchin git_repository_init, with an
|
||||
* aditional void * as callback payload.
|
||||
* The signature of a function matching git_repository_init, with an
|
||||
* additional void * as callback payload.
|
||||
*
|
||||
* Callers of git_clone my provide a function matching this signature
|
||||
* to override the repository creation and customization process
|
||||
|
||||
@@ -479,6 +479,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
|
||||
* to the commit and write it into the given repository.
|
||||
*
|
||||
* @param out the resulting commit id
|
||||
* @param repo the repository to create the commit in.
|
||||
* @param commit_content the content of the unsigned commit object
|
||||
* @param signature the signature to add to the commit. Leave `NULL`
|
||||
* to create a commit without adding a signature field.
|
||||
@@ -499,6 +500,7 @@ GIT_EXTERN(int) git_commit_create_with_signature(
|
||||
*
|
||||
* @param out Pointer to store the copy of the commit
|
||||
* @param source Original commit to copy
|
||||
* @return 0
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_dup(git_commit **out, git_commit *source);
|
||||
|
||||
|
||||
@@ -121,6 +121,17 @@ GIT_BEGIN_DECL
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_version(int *major, int *minor, int *rev);
|
||||
|
||||
/**
|
||||
* Return the prerelease state of the libgit2 library currently being
|
||||
* used. For nightly builds during active development, this will be
|
||||
* "alpha". Releases may have a "beta" or release candidate ("rc1",
|
||||
* "rc2", etc) prerelease. For a final release, this function returns
|
||||
* NULL.
|
||||
*
|
||||
* @return the name of the prerelease state or NULL
|
||||
*/
|
||||
GIT_EXTERN(const char *) git_libgit2_prerelease(void);
|
||||
|
||||
/**
|
||||
* Combinations of these values describe the features with which libgit2
|
||||
* was compiled
|
||||
@@ -147,7 +158,7 @@ typedef enum {
|
||||
* If set, libgit2 was built with support for sub-second resolution in file
|
||||
* modification times.
|
||||
*/
|
||||
GIT_FEATURE_NSEC = (1 << 3),
|
||||
GIT_FEATURE_NSEC = (1 << 3)
|
||||
} git_feature_t;
|
||||
|
||||
/**
|
||||
@@ -167,6 +178,9 @@ typedef enum {
|
||||
* - GIT_FEATURE_SSH
|
||||
* Libgit2 supports the SSH protocol for network operations. This requires
|
||||
* the libssh2 library to be found when compiling libgit2
|
||||
*
|
||||
* - GIT_FEATURE_NSEC
|
||||
* Libgit2 supports the sub-second resolution in file modification times.
|
||||
*/
|
||||
GIT_EXTERN(int) git_libgit2_features(void);
|
||||
|
||||
@@ -211,7 +225,9 @@ typedef enum {
|
||||
GIT_OPT_SET_ODB_PACKED_PRIORITY,
|
||||
GIT_OPT_SET_ODB_LOOSE_PRIORITY,
|
||||
GIT_OPT_GET_EXTENSIONS,
|
||||
GIT_OPT_SET_EXTENSIONS
|
||||
GIT_OPT_SET_EXTENSIONS,
|
||||
GIT_OPT_GET_OWNER_VALIDATION,
|
||||
GIT_OPT_SET_OWNER_VALIDATION
|
||||
} git_libgit2_opt_t;
|
||||
|
||||
/**
|
||||
@@ -449,6 +465,14 @@ typedef enum {
|
||||
* > to support repositories with the `noop` extension but does want
|
||||
* > to support repositories with the `newext` extension.
|
||||
*
|
||||
* opts(GIT_OPT_GET_OWNER_VALIDATION, int *enabled)
|
||||
* > Gets the owner validation setting for repository
|
||||
* > directories.
|
||||
*
|
||||
* opts(GIT_OPT_SET_OWNER_VALIDATION, int enabled)
|
||||
* > Set that repository directories should be owned by the current
|
||||
* > user. The default is to validate ownership.
|
||||
*
|
||||
* @param option Option key
|
||||
* @param ... value to set the option
|
||||
* @return 0 on success, <0 on failure
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user