diff --git a/.devcontainer b/.devcontainer new file mode 160000 index 00000000000..1eda63a7910 --- /dev/null +++ b/.devcontainer @@ -0,0 +1 @@ +Subproject commit 1eda63a791063c7ab99c5946c47c4d98906b019b diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json deleted file mode 100644 index bc6344b93df..00000000000 --- a/.devcontainer/devcontainer.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "postCreateCommand": "bash .devcontainer/setup.sh" -} diff --git a/.devcontainer/setup.sh b/.devcontainer/setup.sh deleted file mode 100755 index c328bf3b98b..00000000000 --- a/.devcontainer/setup.sh +++ /dev/null @@ -1,9 +0,0 @@ -#!/bin/sh -set -e - -sudo apt-get update -sudo apt-get -y --no-install-recommends install cmake - -mkdir build -cd build -cmake .. \ No newline at end of file diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index 38b4a044a6f..27167354804 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -1,9 +1,6 @@ name: "CodeQL" -on: - workflow_dispatch: - schedule: - - cron: '21 3 * * 1' +on: [workflow_dispatch] env: docker-registry: docker.pkg.github.com diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 572f025444a..407a45bf881 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,12 +2,7 @@ # main and maintenance branches. name: CI Build -on: - push: - branches: [ main, maint/* ] - pull_request: - branches: [ main, maint/* ] - workflow_dispatch: +on: [workflow_dispatch] env: docker-registry: docker.pkg.github.com diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 47ebf464d11..f7b76bde163 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -1,10 +1,7 @@ # Nightly build for the main branch across multiple targets. name: Nightly Build -on: - workflow_dispatch: - schedule: - - cron: '15 1 * * *' +on: [workflow_dispatch] env: docker-registry: docker.pkg.github.com diff --git a/.github/workflows/xpbuild.yml b/.github/workflows/xpbuild.yml new file mode 100644 index 00000000000..169ff5269c8 --- /dev/null +++ b/.github/workflows/xpbuild.yml @@ -0,0 +1,30 @@ +name: Build +on: + push: + branches: [ "dev" ] + pull_request: + branches: [ "dev" ] + workflow_dispatch: +jobs: + linux: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.06 + with: + cmake-workflow-preset: Linux + runon: ubuntu-latest + secrets: inherit + linux-arm64: + uses: externpro/externpro/.github/workflows/build-linux.yml@25.06 + with: + cmake-workflow-preset: Linux + runon: ubuntu-24.04-arm + secrets: inherit + macos: + uses: externpro/externpro/.github/workflows/build-macos.yml@25.06 + with: + cmake-workflow-preset: Darwin + secrets: inherit + windows: + uses: externpro/externpro/.github/workflows/build-windows.yml@25.06 + with: + cmake-workflow-preset: Windows + secrets: inherit diff --git a/.github/workflows/xprelease.yml b/.github/workflows/xprelease.yml new file mode 100644 index 00000000000..146191466e2 --- /dev/null +++ b/.github/workflows/xprelease.yml @@ -0,0 +1,20 @@ +name: Release +on: + workflow_dispatch: + inputs: + workflow_run_url: + description: 'URL of the workflow run containing artifacts to upload (e.g., https://github.com/owner/repo/actions/runs/123456789)' + required: true + type: string +jobs: + # Upload build artifacts as release assets + release-from-build: + uses: externpro/externpro/.github/workflows/release-from-build.yml@25.06 + with: + workflow_run_url: ${{ github.event.inputs.workflow_run_url }} + artifact_pattern: "*.tar.xz" + permissions: + contents: write + id-token: write + attestations: write + secrets: inherit diff --git a/.gitignore b/.gitignore index 1b482f038af..30a563a46cb 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,7 @@ CMakeSettings.json .vs .idea +# externpro +.env +_bld*/ +docker-compose.override.yml diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..18932abfb9a --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule ".devcontainer"] + path = .devcontainer + url = https://github.com/externpro/externpro diff --git a/CMakeLists.txt b/CMakeLists.txt index 2940775bf3c..4fc94543d47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,7 +11,9 @@ # Install: # > cmake --build . --target install -CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5.1...3.31) + +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES .devcontainer/cmake/xproinc.cmake) project(libgit2 VERSION "1.3.0" LANGUAGES C) @@ -33,13 +35,25 @@ INCLUDE(IdeSplitSources) INCLUDE(FeatureSummary) INCLUDE(EnableWarnings) include(xpflags) -if(DEFINED XP_NAMESPACE) - set(XP_OPT_INSTALL EXCLUDE_FROM_ALL) - set(nameSpace NAMESPACE ${XP_NAMESPACE}::) -endif() +set(targetsFile ${PROJECT_NAME}-targets) if(NOT DEFINED XP_INSTALL_CMAKEDIR) set(XP_INSTALL_CMAKEDIR ${CMAKE_INSTALL_DATADIR}/cmake) endif() +if(DEFINED XP_NAMESPACE) + set(XP_OPT_INSTALL FALSE) + set(nameSpace NAMESPACE ${XP_NAMESPACE}::) + set(USE_CMAKE_ICONV ON) + string(JOIN "\n" EXT1 + "if(APPLE)" + " find_package(Iconv REQUIRED)" + "endif()" + "" + ) + xpPackageDevel(TARGETS_FILE ${targetsFile} DEPS libssh2 LIBRARIES ${XP_NAMESPACE}::git2) +else() + set(XP_OPT_INSTALL TRUE) + set(USE_CMAKE_ICONV OFF) +endif() # Build options # diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 00000000000..f82cfdd2cf6 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,8 @@ +{ + "version": 8, + "include": [ + ".devcontainer/cmake/presets/xpLinuxNinja.json", + ".devcontainer/cmake/presets/xpDarwinNinja.json", + ".devcontainer/cmake/presets/xpWindowsVs2022.json" + ] +} diff --git a/CMakePresetsBase.json b/CMakePresetsBase.json new file mode 100644 index 00000000000..9d1bf48aaca --- /dev/null +++ b/CMakePresetsBase.json @@ -0,0 +1,23 @@ +{ + "version": 8, + "configurePresets": [ + { + "name": "config-base", + "hidden": true, + "binaryDir": "${sourceDir}/_bld-${presetName}", + "cacheVariables": { + "BUILD_CLAR": "OFF", + "BUILD_SHARED_LIBS": "OFF", + "REGEX_BACKEND": "builtin", + "THREADSAFE": "ON", + "XP_NAMESPACE": "xpro" + } + } + ], + "buildPresets": [ + { + "name": "build-base", + "hidden": true + } + ] +} diff --git a/cmake/PkgBuildConfig.cmake b/cmake/PkgBuildConfig.cmake index 3ff153f26bb..1d7501e4ce3 100644 --- a/cmake/PkgBuildConfig.cmake +++ b/cmake/PkgBuildConfig.cmake @@ -72,6 +72,8 @@ function(pkg_build_config) endif() file(APPEND "${PKGCONFIG_FILE}" "Cflags: -I\${includedir} ${PKGCONFIG_CFLAGS}\n") + if(XP_OPT_INSTALL) # Install .pc file - install(FILES "${PKGCONFIG_FILE}" ${XP_OPT_INSTALL} DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + install(FILES "${PKGCONFIG_FILE}" DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") + endif() endfunction() diff --git a/cmake/SelectHTTPSBackend.cmake b/cmake/SelectHTTPSBackend.cmake index 7bc8f8b9d9f..05ce2e62f80 100644 --- a/cmake/SelectHTTPSBackend.cmake +++ b/cmake/SelectHTTPSBackend.cmake @@ -1,11 +1,9 @@ INCLUDE(SanitizeBool) # We try to find any packages our backends might use -if(COMMAND xpFindPkg) - xpFindPkg(PKGS openssl) +FIND_PACKAGE(OpenSSL) +if(TARGET xpro::crypto AND NOT DEFINED OPENSSL_INCLUDE_DIR) get_target_property(OPENSSL_INCLUDE_DIR xpro::crypto INTERFACE_INCLUDE_DIRECTORIES) -else() - FIND_PACKAGE(OpenSSL) endif() FIND_PACKAGE(mbedTLS) IF (CMAKE_SYSTEM_NAME MATCHES "Darwin") diff --git a/docker-compose.sh b/docker-compose.sh new file mode 120000 index 00000000000..85f182f0be7 --- /dev/null +++ b/docker-compose.sh @@ -0,0 +1 @@ +.devcontainer/compose.pro.sh \ No newline at end of file diff --git a/docker-compose.yml b/docker-compose.yml new file mode 120000 index 00000000000..46c1f8918f2 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1 @@ +.devcontainer/compose.bld.yml \ No newline at end of file diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e3eecf3b03f..1f0b839c0d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -203,11 +203,9 @@ IF(USE_BUNDLED_ZLIB STREQUAL ON) ENDIF() IF(USE_BUNDLED_ZLIB STREQUAL "OFF") - if(COMMAND xpFindPkg) - xpFindPkg(PKGS zlib) - get_target_property(ZLIB_INCLUDE_DIRS ${ZLIB_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES) - else() - FIND_PACKAGE(ZLIB) + FIND_PACKAGE(ZLIB) + if(NOT DEFINED ZLIB_INCLUDE_DIRS) + get_target_property(ZLIB_INCLUDE_DIRS ${ZLIB_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES) endif() IF(ZLIB_FOUND) LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ZLIB_INCLUDE_DIRS}) @@ -236,8 +234,8 @@ ENDIF() # Optional external dependency: libssh2 IF (USE_SSH) - if(COMMAND xpFindPkg) - xpFindPkg(PKGS libssh2) + if(COMMAND xpFindPkg) # externpro dependency provider + find_package(libssh2) get_target_property(LIBSSH2_INCLUDE_DIRS ${LIBSSH2_LIBRARIES} INTERFACE_INCLUDE_DIRECTORIES) else() FIND_PKGLIBRARIES(LIBSSH2 libssh2) @@ -280,12 +278,26 @@ INCLUDE(SelectGSSAPI) # Optional external dependency: iconv IF (USE_ICONV) - FIND_PACKAGE(Iconv) + IF (USE_CMAKE_ICONV) + LIST(REMOVE_ITEM CMAKE_MODULE_PATH "${libgit2_SOURCE_DIR}/cmake/") + FIND_PACKAGE(Iconv) + LIST(APPEND CMAKE_MODULE_PATH "${libgit2_SOURCE_DIR}/cmake/") + INCLUDE(FindIconv) # populate the ICONV_* variables + # Iconv_INCLUDE_DIR (cmake) and ICONV_INCLUDE_DIR (libgit2) + # are assumed to be the same below... it was true on my system + ELSE() + FIND_PACKAGE(Iconv) + ENDIF() ENDIF() IF (ICONV_FOUND) SET(GIT_USE_ICONV 1) LIST(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR}) - LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES}) + if(USE_CMAKE_ICONV AND TARGET Iconv::Iconv) + # Iconv::Iconv avoids hard-coded build system paths in targetsFile + LIST(APPEND LIBGIT2_LIBS Iconv::Iconv) + else() + LIST(APPEND LIBGIT2_LIBS ${ICONV_LIBRARIES}) + endif() LIST(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) ENDIF() ADD_FEATURE_INFO(iconv GIT_USE_ICONV "iconv encoding conversion support") @@ -435,12 +447,11 @@ IF (MSVC_IDE) ENDIF () # Install -set(LIBGIT2_TARGETS_FILE ${PROJECT_NAME}-targets) -INSTALL(TARGETS git2 EXPORT ${LIBGIT2_TARGETS_FILE} +INSTALL(TARGETS git2 EXPORT ${targetsFile} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} ) INSTALL(DIRECTORY ${libgit2_SOURCE_DIR}/include/git2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) INSTALL(FILES ${libgit2_SOURCE_DIR}/include/git2.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -install(EXPORT ${LIBGIT2_TARGETS_FILE} DESTINATION ${XP_INSTALL_CMAKEDIR} ${nameSpace}) +install(EXPORT ${targetsFile} DESTINATION ${XP_INSTALL_CMAKEDIR} ${nameSpace})