diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 37b5071..8fcd549 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -23,10 +23,10 @@ jobs: image: datadog/docker-library:httpd-datadog-ci-28219c0ef3e00f1e3d5afcab61a73a5e9bd2a9b957d7545556711cce2a6262cd steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - with: - submodules: true - name: Add cloned repo as safe run: sh -c "git config --global --add safe.directory $PWD" + - name: Init required submodules + run: git submodule update --init --depth=1 deps/dd-trace-cpp deps/nginx-datadog - name: Configure run: cmake --preset=ci-dev -B build . - name: Build diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d58326..7a7539b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,10 +9,10 @@ jobs: image: datadog/docker-library:httpd-datadog-ci-28219c0ef3e00f1e3d5afcab61a73a5e9bd2a9b957d7545556711cce2a6262cd steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - with: - submodules: true - name: Add cloned repo as safe run: sh -c "git config --global --add safe.directory $PWD" + - name: Init required submodules + run: git submodule update --init --depth=1 deps/dd-trace-cpp deps/nginx-datadog - name: Configure run: cmake --preset ci-release -B build . - name: Build diff --git a/.github/workflows/system-tests.yml b/.github/workflows/system-tests.yml index b9b0051..72414ee 100644 --- a/.github/workflows/system-tests.yml +++ b/.github/workflows/system-tests.yml @@ -23,10 +23,10 @@ jobs: image: datadog/docker-library:httpd-datadog-ci-28219c0ef3e00f1e3d5afcab61a73a5e9bd2a9b957d7545556711cce2a6262cd steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - with: - submodules: true - name: Add cloned repo as safe run: sh -c "git config --global --add safe.directory $PWD" + - name: Init required submodules + run: git submodule update --init --depth=1 deps/dd-trace-cpp deps/nginx-datadog - name: Configure run: cmake --preset=ci-dev -B build . - name: Build diff --git a/.gitmodules b/.gitmodules index d88c1b8..52a8a84 100644 --- a/.gitmodules +++ b/.gitmodules @@ -5,3 +5,6 @@ path = deps/nginx-datadog url = ../httpd-datadog.git branch = mirror-nginx-datadog +[submodule "deps/inject-browser-sdk"] + path = deps/inject-browser-sdk + url = ../inject-browser-sdk.git diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f0afad..59ef466 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,23 +23,6 @@ if (NOT HTTPD_SRC_DIR) endif () include(cmake/utils.cmake) -include(cmake/deps/fmt.cmake) - -if (HTTPD_DATADOG_ENABLE_RUM) - include(FetchContent) - - set(INJECT_BROWSER_SDK_GIT_REF "49245e1c6ed8275990bb910125187e0aaad09e3d" CACHE STRING - "Git tag/branch for inject-browser-sdk") - - FetchContent_Declare( - InjectBrowserSDK - GIT_REPOSITORY https://github.com/DataDog/inject-browser-sdk.git - GIT_TAG ${INJECT_BROWSER_SDK_GIT_REF} - ) - FetchContent_MakeAvailable(InjectBrowserSDK) - - include(cmake/deps/rapidjson.cmake) -endif () add_library(httpd INTERFACE) target_include_directories( diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0794211..63d4b27 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,12 +2,14 @@ ## Fork, Clone, Branch and Create your PR -When cloning the repo, you have to initialize the submodules: +When cloning the repo, initialize the submodules you need. For a standard build: ```sh -git submodule update --init --recursive +git submodule update --init deps/dd-trace-cpp deps/nginx-datadog ``` +The `deps/inject-browser-sdk` submodule is a private repo and is only required when building with `-DHTTPD_DATADOG_ENABLE_RUM=ON`. If you have access, use `--recursive` instead to pull it as well. + ### Rules - Follow the pattern of what you already see in the code. - Follow the coding style. diff --git a/cmake/deps/fmt.cmake b/cmake/deps/fmt.cmake index 829b9aa..6563674 100644 --- a/cmake/deps/fmt.cmake +++ b/cmake/deps/fmt.cmake @@ -4,15 +4,9 @@ FetchContent_Declare( fmt GIT_REPOSITORY https://github.com/fmtlib/fmt.git GIT_TAG 10.2.1 + EXCLUDE_FROM_ALL ) -FetchContent_GetProperties(fmt) -if(NOT fmt_POPULATED) - FetchContent_Populate(fmt) - - set(BUILD_SHARED_LIBS OFF) - set(CMAKE_POSITION_INDEPENDENT_CODE ON) - - add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR} EXCLUDE_FROM_ALL) -endif() - +set(BUILD_SHARED_LIBS OFF) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) +FetchContent_MakeAvailable(fmt) diff --git a/deps/CMakeLists.txt b/deps/CMakeLists.txt index 1181b4d..da207da 100644 --- a/deps/CMakeLists.txt +++ b/deps/CMakeLists.txt @@ -1,6 +1,22 @@ +include(${CMAKE_SOURCE_DIR}/cmake/deps/fmt.cmake) + add_subdirectory(dd-trace-cpp) # Force POSITION_INDEPENDENT_CODE (PIC) because mod_datadog.so is loaded via # dlopen, but dd-trace-cpp sets this based on BUILD_SHARED_LIBS, whereas we # link with the static library. set_target_properties(dd-trace-cpp-objects PROPERTIES POSITION_INDEPENDENT_CODE ON) + +if (HTTPD_DATADOG_ENABLE_RUM) + if (NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/inject-browser-sdk/CMakeLists.txt") + message(FATAL_ERROR + "deps/inject-browser-sdk submodule is not initialized. " + "Run: git submodule update --init --recursive") + endif () + # mod_datadog/CMakeLists.txt references ${injectbrowsersdk_SOURCE_DIR}, which + # FetchContent used to set; replicate it for the submodule layout. + set(injectbrowsersdk_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/inject-browser-sdk" CACHE INTERNAL "") + add_subdirectory(inject-browser-sdk EXCLUDE_FROM_ALL) + + include(${CMAKE_SOURCE_DIR}/cmake/deps/rapidjson.cmake) +endif () diff --git a/deps/inject-browser-sdk b/deps/inject-browser-sdk new file mode 160000 index 0000000..49245e1 --- /dev/null +++ b/deps/inject-browser-sdk @@ -0,0 +1 @@ +Subproject commit 49245e1c6ed8275990bb910125187e0aaad09e3d