diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 8ca763ace..bbb2ea93d 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -31,7 +31,6 @@ pipeline { choice(name: 'AGENT_LOG_LEVEL', choices: LOG_LEVELS, description: "Agent's log level") choice(name: 'TESTS_LOG_LEVEL', choices: LOG_LEVELS, description: "Tests' log level") booleanParam(name: 'INCLUDE_TESTING', defaultValue: true, description: 'Should the testing stages be included?') - booleanParam(name: 'ADD_LIBUNWIND_DEPENDENCY', defaultValue: false, description: 'Should Alpine (.apk) build have dependency on libunwind (to be able to log C call stack on crash)?') } stages { stage('Initializing'){ @@ -84,7 +83,7 @@ pipeline { } } } - stage('Build binaries and basic testing') { + stage('Build binaries') { options { skipDefaultCheckout() } when { beforeAgent true @@ -94,50 +93,116 @@ pipeline { matrix { agent { label 'ubuntu-18.04 && immutable' } axes { + axis { + name 'BUILD_ARCHITECTURE' + values 'linux-x86-64', 'linuxmusl-x86-64' + } + } + + stages { + stage('Build PHP extension') { + steps { + initWorkspace(context: "Build-${BUILD_ARCHITECTURE}") { + sh script: "BUILD_ARCHITECTURE=${BUILD_ARCHITECTURE} make -f .ci/Makefile build", label: 'build' + } + withGithubNotify(context: "Build-${BUILD_ARCHITECTURE}") { + dir("${BASE_DIR}"){ + stash includes: "agent/native/_build/${BUILD_ARCHITECTURE}-release/ext/elastic_apm-*", name: "built-extensions-${BUILD_ARCHITECTURE}" + } + } + } + } + } + } + } + stage('PHP tests of extension') { + options { skipDefaultCheckout() } + when { + beforeAgent true + expression { return env.ONLY_DOCS == "false" } + } + failFast false + matrix { + agent { label 'ubuntu-18.04 && immutable' } + axes { + axis { + name 'BUILD_ARCHITECTURE' + values 'linux-x86-64', 'linuxmusl-x86-64' + } axis { name 'PHP_VERSION' // Make sure list of PHP versions supported by the Elastic APM PHP Agent is in sync. // See the comment in .ci/shared.sh values '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' } - axis { - name 'DOCKERFILE' - values 'Dockerfile', 'Dockerfile.alpine' - } } + stages { - stage('Build PHP extension') { + stage('Execute phpt tests') { + when { + beforeAgent true + expression { return params.INCLUDE_TESTING } + } steps { - echo "params.INCLUDE_TESTING: ${params.INCLUDE_TESTING}" - echo "params.ADD_LIBUNWIND_DEPENDENCY: ${params.ADD_LIBUNWIND_DEPENDENCY}" - initWorkspace(context: "Build-${PHP_VERSION}") { + initWorkspace(context: "PHPT-${PHP_VERSION}", tab: "tests") { // When running in the CI with multiple parallel stages // the access could be considered as a DDOS attack. - retryWithSleep(retries: 3, seconds: 5, backoff: true) { - sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} ADD_LIBUNWIND_DEPENDENCY=${params.ADD_LIBUNWIND_DEPENDENCY} make -f .ci/Makefile prepare", label: 'prepare docker image' + retryWithSleep(retries: 3, seconds: 45, backoff: true) { + sh script: "BUILD_ARCHITECTURE=${BUILD_ARCHITECTURE} PHP_VERSION=${PHP_VERSION} make -f .ci/Makefile prepare", label: 'prepare docker image' } - sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} make -f .ci/Makefile build", label: 'build' + unstash "built-extensions-${BUILD_ARCHITECTURE}" + sh script: "BUILD_ARCHITECTURE=${BUILD_ARCHITECTURE} PHP_VERSION=${PHP_VERSION} make -f .ci/Makefile run-phpt-tests", label: 'run-phpt-tests' } } } + } + } + } + stage('Static analysis and tests') { + options { skipDefaultCheckout() } + when { + beforeAgent true + expression { return env.ONLY_DOCS == "false" } + } + failFast false + matrix { + agent { label 'ubuntu-18.04 && immutable' } + axes { + axis { + name 'PHP_VERSION' + // Make sure list of PHP versions supported by the Elastic APM PHP Agent is in sync. + // See the comment in .ci/shared.sh + values '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' + } + axis { + name 'DOCKERFILE' + values 'Dockerfile', 'Dockerfile.alpine' + } + } + stages { stage('Static analysis and unit tests') { when { beforeAgent true expression { return params.INCLUDE_TESTING } } steps { + echo "params.INCLUDE_TESTING: ${params.INCLUDE_TESTING}" echo "params.AGENT_LOG_LEVEL: ${params.AGENT_LOG_LEVEL}" echo "params.AGENT_LOG_LEVEL == null: " + (params.AGENT_LOG_LEVEL == null) echo "params.TESTS_LOG_LEVEL: ${params.TESTS_LOG_LEVEL}" echo "params.TESTS_LOG_LEVEL == null: " + (params.TESTS_LOG_LEVEL == null) echo "addEnvVarsFromParams([]): " + addEnvVarsFromParams([]) - withGithubNotify(context: "Static-Check-Unit-Tests-${PHP_VERSION}", tab: 'tests') { + + initWorkspace(context: "Static-Check-Unit-Tests-${PHP_VERSION}", tab: "tests") { withEnv(addEnvVarsFromParams([])) { echo "env.ELASTIC_APM_LOG_LEVEL: ${env.ELASTIC_APM_LOG_LEVEL}" echo "env.TESTS_LOG_LEVEL: ${env.TESTS_LOG_LEVEL}" - dir("${BASE_DIR}"){ - sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} make -f .ci/Makefile static-check-unit-test", label: 'static-check-unit-test' + + retryWithSleep(retries: 3, seconds: 45, backoff: true) { + sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} make -f .ci/Makefile prepare", label: 'prepare docker image' } + + sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} make -f .ci/Makefile static-check-unit-test", label: 'static-check-unit-test' } } } @@ -147,16 +212,6 @@ pipeline { } } } - stage('Build parts for packages') { - steps { - withGithubNotify(context: "Generate-For-Package-${PHP_VERSION}") { - dir("${BASE_DIR}"){ - sh script: "PHP_VERSION=${PHP_VERSION} DOCKERFILE=${DOCKERFILE} ADD_LIBUNWIND_DEPENDENCY=${params.ADD_LIBUNWIND_DEPENDENCY} make -f .ci/Makefile generate-for-package", label: 'generate-for-package' - stash includes: 'src/ext/modules/*.so', name: "generate-for-package-${PHP_VERSION}-${DOCKERFILE}" - } - } - } - } } } } @@ -374,10 +429,9 @@ pipeline { */ def packageGeneration(def args = [:]) { def local = args.get('local', false) - args.versions.each { version -> - unstash "generate-for-package-${version}-Dockerfile" - unstash "generate-for-package-${version}-Dockerfile.alpine" - } + unstash "built-extensions-linux-x86-64" + unstash "built-extensions-linuxmusl-x86-64" + if (local) { // VERSION=1.0.0 is needed to override the current version. // current version is >1.0.0, and this is the way we can @@ -387,7 +441,8 @@ def packageGeneration(def args = [:]) { sh script: "mv build/packages build/local", label: 'prepare-local-upgrade-agent' } else { // Archive the so files to be downloaded if possible. - archiveArtifacts(allowEmptyArchive: true, artifacts: 'src/ext/modules/*.so') + archiveArtifacts(allowEmptyArchive: true, artifacts: 'agent/native/_build/*-release/ext/elastic_apm-*') + sh script: "make -C packaging package", label: 'package' sh script: "make -C packaging info", label: 'package info' // checksum files are regenerated by the signing component in the internal-ci instance. @@ -419,8 +474,10 @@ def packageWorkspace(def args = [:], Closure body){ unstash (args.shouldUseSignedBinaries ? env.SIGNED_ARTIFACTS : 'package') // When running in the CI sometimes the docker build might fail for // some environmental issues, let's retry - retryWithSleep(retries: 3, seconds: 5, backoff: true) { - sh script: "PHP_VERSION=${PHP_VERSION} make -C packaging ${args.prepareGoal}", label: "${args.prepareGoal} for ${PHP_VERSION}" + retryWithSleep(retries: 3, seconds: 45, backoff: true) { + if (args.prepareGoal != null) { + sh script: "PHP_VERSION=${PHP_VERSION} make -C packaging ${args.prepareGoal}", label: "${args.prepareGoal} for ${PHP_VERSION}" + } } body() } @@ -546,7 +603,6 @@ def addEnvVarsFromParams(def withEnvList) { if (params.TESTS_LOG_LEVEL != null && !params.TESTS_LOG_LEVEL.equals(LOG_LEVEL_NOT_SET)) { withEnvList.add('ELASTIC_APM_PHP_TESTS_LOG_LEVEL=' + params.TESTS_LOG_LEVEL) } - withEnvList.add('ADD_LIBUNWIND_DEPENDENCY=' + params.ADD_LIBUNWIND_DEPENDENCY) return withEnvList } @@ -574,7 +630,6 @@ def buildLabel(def args = [:]) { def lifecycleTesting(def args = [:]) { runTestingCommand( args + [ - prepareGoal: "prepare-${args.linuxPackageType}", testingCommand: "make -C packaging ${args.linuxPackageType}-lifecycle-testing" ] ) @@ -583,7 +638,6 @@ def lifecycleTesting(def args = [:]) { def lifecycleTestingOnProdServerKind(def args = [:]) { runTestingCommand( args + [ - prepareGoal: "prepare-${args.linuxPackageType}-${args.prodServerKind}", testingCommand: "make -C packaging ${args.linuxPackageType}-lifecycle-testing-in-${args.prodServerKind}", ] ) @@ -592,7 +646,6 @@ def lifecycleTestingOnProdServerKind(def args = [:]) { def phpUpgradeTesting(def args = [:]) { runTestingCommand( args + [ - prepareGoal: "prepare-${args.linuxPackageType}", testingCommand: "PHP_VERSION=${args.phpVersion} make -C packaging ${args.linuxPackageType}-php-upgrade-testing" ] ) diff --git a/.ci/Makefile b/.ci/Makefile index 2ecfbef6b..3047a5686 100644 --- a/.ci/Makefile +++ b/.ci/Makefile @@ -1,3 +1,10 @@ +ifeq ($(DOCKERFILE),) + ifeq ($(BUILD_ARCHITECTURE), linuxmusl-x86-64) + DOCKERFILE := Dockerfile.alpine + else + DOCKERFILE := Dockerfile + endif +endif SHELL=/bin/bash -o pipefail MAKEFLAGS += --no-print-directory @@ -6,15 +13,20 @@ PHP_VERSION ?= 7.2 DOCKERFILE ?= Dockerfile LOOPS ?= 50 SUFFIX := -ADD_LIBUNWIND_DEPENDENCY_BUILD_ARG_OPT:= ifeq ($(DOCKERFILE), Dockerfile.alpine) ## This is only required to tag the docker images used for building/testing this project SUFFIX := -alpine - ADD_LIBUNWIND_DEPENDENCY_BUILD_ARG_OPT:=--build-arg ADD_LIBUNWIND_DEPENDENCY=${ADD_LIBUNWIND_DEPENDENCY} +endif + +CONAN_USER_HOME:=/tmp/conan_user_home +MAP_CONAN_HOME_TO_DOCKER_HOST_CMD_LINE_ARG:= +ifdef MAP_CONAN_HOME_TO_DOCKER_HOST + MAP_CONAN_HOME_TO_DOCKER_HOST_CMD_LINE_ARG:=-v "${MAP_CONAN_HOME_TO_DOCKER_HOST}:$(CONAN_USER_HOME)" endif CURRENT_UID := $(shell id -u) CURRENT_GID := $(shell id -g) +CURRENT_USER_HOME := $(shell echo ~) .PHONY: help .DEFAULT_GOAL := help @@ -26,19 +38,24 @@ prepare: ## Build docker image for building and testing the project @echo "::group::$@" # Helping to group logs in GitHub actions docker build \ --build-arg PHP_VERSION=${PHP_VERSION} \ - ${ADD_LIBUNWIND_DEPENDENCY_BUILD_ARG_OPT} \ --tag $(IMAGE):${PHP_VERSION}$(SUFFIX) \ -f ${DOCKERFILE} . @echo "::endgroup::" .PHONY: build -build: prepare ## Build the project +build: @echo "::group::$@" # Helping to group logs in GitHub actions # docker as the current user docker run --rm -t \ -u $(CURRENT_UID):$(CURRENT_GID) \ - -v $(PWD):/app \ - $(IMAGE):${PHP_VERSION}$(SUFFIX) + -v $(PWD):/source \ + ${MAP_CONAN_HOME_TO_DOCKER_HOST_CMD_LINE_ARG} \ + -w /source/agent/native \ + -e CONAN_USER_HOME=$(CONAN_USER_HOME) \ + elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-$(BUILD_ARCHITECTURE)-0.0.2 \ + sh -c "cmake --preset $(BUILD_ARCHITECTURE)-release \ + && cmake --build --preset $(BUILD_ARCHITECTURE)-release \ + && /source/agent/native/_build/$(BUILD_ARCHITECTURE)-release/ext/unit_tests/unit_tests" @echo "::endgroup::" .PHONY: static-check-unit-test @@ -52,15 +69,16 @@ static-check-unit-test: prepare ## Test the static check and unit tests /app/.ci/static-check-unit-test.sh @echo "::endgroup::" -.PHONY: generate-for-package -generate-for-package: prepare ## Generate the agent extension for the package +.PHONY: run-phpt-tests +run-phpt-tests: prepare ## Runs phpt tests @echo "::group::$@" # Helping to group logs in GitHub actions # docker as the current user docker run --rm -t \ + -e CHOWN_RESULTS_UID=$(CURRENT_UID) -e CHOWN_RESULTS_GID=$(CURRENT_GID) \ + -e BUILD_ARCHITECTURE=$(BUILD_ARCHITECTURE) \ -v $(PWD):/app \ - -u $(CURRENT_UID):$(CURRENT_GID) \ $(IMAGE):${PHP_VERSION}$(SUFFIX) \ - /app/.ci/generate-for-package.sh + /app/.ci/run-phpt-tests.sh @echo "::endgroup::" .PHONY: interactive @@ -75,6 +93,7 @@ component-test: prepare ## Run component-test @echo "::group::$@" # Helping to group logs in GitHub actions # docker as root to install the extension docker run -t --rm \ + -e BUILD_ARCHITECTURE=$(BUILD_ARCHITECTURE) \ -v $(PWD):/app \ $(IMAGE):${PHP_VERSION}$(SUFFIX) \ sh -c '/app/.ci/component-test.sh' diff --git a/.ci/bump_version.sh b/.ci/bump_version.sh index 269b1b261..d432cbe19 100755 --- a/.ci/bump_version.sh +++ b/.ci/bump_version.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -xe -sed -i.bck "s#\(VERSION = \).*;#\1'${VERSION}';#g" src/ElasticApm/ElasticApm.php -sed -i.bck "s#\(PHP_ELASTIC_APM_VERSION\).*#\1 \"${VERSION}\"#g" src/ext/elastic_apm_version.h +sed -i.bck "s#\(VERSION = \).*;#\1'${VERSION}';#g" agent/php/ElasticApm/ElasticApm.php +sed -i.bck "s#\(PHP_ELASTIC_APM_VERSION\).*#\1 \"${VERSION}\"#g" agent/native/ext/elastic_apm_version.h -git add src/ElasticApm/ElasticApm.php src/ext/elastic_apm_version.h +git add agent/php/ElasticApm/ElasticApm.php agent/native/ext/elastic_apm_version.h diff --git a/.ci/component-test.sh b/.ci/component-test.sh index fabb3584b..6a11971fa 100755 --- a/.ci/component-test.sh +++ b/.ci/component-test.sh @@ -4,12 +4,32 @@ set -xe -o pipefail # Disable Elastic APM for any process outside the component tests to prevent noise in the logs export ELASTIC_APM_ENABLED=false +APP_FOLDER=/app +PHP_API=$(php -i | grep -i 'PHP API' | sed -e 's#.* =>##g' | awk '{print $1}') +PHP_EXECUTABLE=$(which php) + +echo "BUILD ARCHITECTURE: $BUILD_ARCHITECTURE" + +if [ -z "${BUILD_ARCHITECTURE}" ] +then + echo "\$BUILD_ARCHITECTURE is not specified, assuming linux-x86-64" + BUILD_ARCHITECTURE=linux-x86-64 +fi +echo "BUILD ARCHITECTURE: $BUILD_ARCHITECTURE" + + + +AGENT_EXTENSION_DIR=$APP_FOLDER/agent/native/_build/$BUILD_ARCHITECTURE-release/ext +AGENT_EXTENSION=$AGENT_EXTENSION_DIR/elastic_apm-$PHP_API.so + +mkdir -p $APP_FOLDER/build + + PHP_INI=/usr/local/etc/php/php.ini -make install -echo 'extension=elastic_apm.so' > ${PHP_INI} -echo 'elastic_apm.bootstrap_php_part_file=/app/src/bootstrap_php_part.php' >> ${PHP_INI} +echo "extension=${AGENT_EXTENSION}" > ${PHP_INI} +echo "elastic_apm.bootstrap_php_part_file=${APP_FOLDER}/agent/php/bootstrap_php_part.php" >> ${PHP_INI} php -m -cd /app +cd "${APP_FOLDER}" # Install 3rd party dependencies composer install @@ -28,5 +48,5 @@ fi # Run component tests mkdir -p ./build/ -composer run-script run_component_tests 2>&1 | tee /app/build/run_component_tests_output.txt +composer run-script run_component_tests 2>&1 | tee ${APP_FOLDER}/build/run_component_tests_output.txt diff --git a/.ci/generate-for-package.sh b/.ci/generate-for-package.sh deleted file mode 100755 index b83f9d0d7..000000000 --- a/.ci/generate-for-package.sh +++ /dev/null @@ -1,32 +0,0 @@ -#!/usr/bin/env bash - -set -exo pipefail - -HYPHEN="-" -MODULES_DIR=/app/src/ext/modules -NAME=elastic_apm -## Prepare context where to copy the previous generated so files -GENERATED_DIR=$(mktemp -d /tmp/dirXXXXXX) -find "${MODULES_DIR}" -name "*${HYPHEN}*.so" -exec cp {} ${GENERATED_DIR} \; -ls -l ${GENERATED_DIR} - -## If alpine then add another suffix -if grep -q -i alpine /etc/os-release; then - SUFFIX=${HYPHEN}alpine -fi - -## Generate so file -make clean -make - -## Fetch PHP api version to be added to the so file that has been generated -PHP_API=$(php -i | grep -i 'PHP API' | sed -e 's#.* =>##g' | awk '{print $1}') - -## Rename so file with the PHP api -mv "${MODULES_DIR}/${NAME}.so" "${MODULES_DIR}/${NAME}${HYPHEN}${PHP_API}${SUFFIX}.so" - -## Remove la files -find "${MODULES_DIR}" -name "*.la" -print0 | xargs -0 rm -f - -## Restore previous so files. -find "${GENERATED_DIR}" -name "*${HYPHEN}*.so" -exec cp -f {} ${MODULES_DIR}/ \; diff --git a/.ci/run-phpt-tests.sh b/.ci/run-phpt-tests.sh new file mode 100755 index 000000000..9c3a42fdd --- /dev/null +++ b/.ci/run-phpt-tests.sh @@ -0,0 +1,97 @@ +#!/usr/bin/env bash +set -xe + +## Location for the generated test report files +APP_FOLDER=/app + + +## Fetch PHP api version to be added to the so file that has been generated +PHP_API=$(php -i | grep -i 'PHP API' | sed -e 's#.* =>##g' | awk '{print $1}') +PHP_EXECUTABLE=$(which php) + +thisScriptDir="$( dirname "${BASH_SOURCE[0]}" )" +thisScriptDir="$( realpath "${thisScriptDir}" )" +source "${thisScriptDir}/shared.sh" + +function onScriptExit () { + if [ -n "${scriptFinishedSuccessfully}" ] && [ "${scriptFinishedSuccessfully}" == "true" ] ; then + local shouldPrintTheMostRecentSyslogFile=false + else + local shouldPrintTheMostRecentSyslogFile=true + fi + + copySyslogFilesAndPrintTheMostRecentOne ${shouldPrintTheMostRecentSyslogFile} + if [ -n "${CHOWN_RESULTS_UID}" ] && [ -n "${CHOWN_RESULTS_GID}" ]; then + chown --recursive "${CHOWN_RESULTS_UID}:${CHOWN_RESULTS_GID}" "${APP_FOLDER}" + fi +} + +trap onScriptExit EXIT + +ensureSyslogIsRunning + +if [ -z "$BUILD_ARCHITECTURE" ] +then + echo "\$BUILD_ARCHITECTURE is not specified, assuming linux-x86-64" + BUILD_ARCHITECTURE=linux-x86-64 +fi +echo "BUILD ARCHITECTURE: $BUILD_ARCHITECTURE" + + +cd $APP_FOLDER/agent/native/ext +mkdir -p $APP_FOLDER/build + +AGENT_EXTENSION_DIR=$APP_FOLDER/agent/native/_build/$BUILD_ARCHITECTURE-release/ext +AGENT_EXTENSION=$AGENT_EXTENSION_DIR/elastic_apm-$PHP_API.so + +ls -al $AGENT_EXTENSION_DIR + +RUN_TESTS=./tests/run-tests.php + +#Disable agent for auxiliary PHP processes to reduce noise in logs +export ELASTIC_APM_ENABLED=false +for phptFile in ./tests/*.phpt; do + msg="Running tests in \`${phptFile}' ..." + echo "${msg}" + this_script_name="$( basename "${BASH_SOURCE[0]}" )" + logger -t "${this_script_name}" "${msg}" + + # Disable exit-on-error + # set +e + TESTS="--show-all ${phptFile}" + + + top_srcdir=$APP_FOLDER/agent/native/ext + + INI_FILE=`php -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null` + + if test "$INI_FILE"; then + egrep -h -v $PHP_DEPRECATED_DIRECTIVES_REGEX "$INI_FILE" > /tmp/tmp-php.ini + else + echo > /tmp/tmp-php.ini + fi + + TEST_PHP_SRCDIR=$top_srcdir TEST_PHP_EXECUTABLE=$PHP_EXECUTABLE $PHP_EXECUTABLE -n -c /tmp/tmp-php.ini $PHP_TEST_SETTINGS $RUN_TESTS -n -c /tmp/tmp-php.ini -d extension_dir=$AGENT_EXTENSION_DIR -d extension=$AGENT_EXTENSION $PHP_TEST_SHARED_EXTENSIONS $TESTS + exitCode=$? + rm /tmp/tmp-php.ini + + + if [ ${exitCode} -ne 0 ] ; then + echo "Tests in \`${phptFile}' failed" + phptFileName="${phptFile%.phpt}" + cat "${phptFileName}.log" + cat "${phptFileName}.out" + exit 1 + fi + + # Re-enable exit-on-error + set -e +done + + +# Re-enable exit-on-error +set -e + +cd $APP_FOLDER + +scriptFinishedSuccessfully=true \ No newline at end of file diff --git a/.ci/static-check-unit-test.sh b/.ci/static-check-unit-test.sh index 037a23c8c..d2c485f69 100755 --- a/.ci/static-check-unit-test.sh +++ b/.ci/static-check-unit-test.sh @@ -27,83 +27,6 @@ trap onScriptExit EXIT ensureSyslogIsRunning - -PHP_EXECUTABLE=$(which php) - -RUN_TESTS=$APP_FOLDER/src/ext/tests/run-tests.php -AGENT_EXTENSION_DIR=$APP_FOLDER/src/ext/modules -AGENT_EXTENSION=$AGENT_EXTENSION_DIR/elastic_apm.so - -# ## This runs PHPT -# # Disable agent for auxiliary PHP processes to reduce noise in logs -export ELASTIC_APM_ENABLED=true -for phptFile in ./tests/*.phpt; do - msg="Running tests in \`${phptFile}' ..." - echo "${msg}" - this_script_name="$( basename "${BASH_SOURCE[0]}" )" - logger -t "${this_script_name}" "${msg}" - - # Disable exit-on-error - # set +e - TESTS="--show-all ${phptFile}" - - INI_FILE=`php -d 'display_errors=stderr' -r 'echo php_ini_loaded_file();' 2> /dev/null` - - if test "$INI_FILE"; then - egrep -h -v $PHP_DEPRECATED_DIRECTIVES_REGEX "$INI_FILE" > /tmp/tmp-php.ini - else - echo > /tmp/tmp-php.ini - fi - - TEST_PHP_SRCDIR=$APP_FOLDER/src/ext TEST_PHP_EXECUTABLE=$PHP_EXECUTABLE $PHP_EXECUTABLE -n -c /tmp/tmp-php.ini $PHP_TEST_SETTINGS $RUN_TESTS -n -c /tmp/tmp-php.ini -d extension_dir=$AGENT_EXTENSION_DIR -d extension=$AGENT_EXTENSION $PHP_TEST_SHARED_EXTENSIONS $TESTS - exitCode=$? - rm /tmp/tmp-php.ini - - - if [ ${exitCode} -ne 0 ] ; then - echo "Tests in \`${phptFile}' failed" - phptFileName="${phptFile%.phpt}" - cat "${phptFileName}.log" - cat "${phptFileName}.out" - exit 1 - fi - - # Re-enable exit-on-error - set -e -done - -# Disable exit-on-error -set +e -## Run cmocka tests -function buildAndRunUnitTests () { - pushd /app/src/ext/unit_tests - for buildType in Debug Release - do - cmake -DCMAKE_BUILD_TYPE=${buildType} . - make - ./unit_tests - unitTestsExitCode=$? - if [ ${unitTestsExitCode} -ne 0 ] ; then - popd - return ${unitTestsExitCode} - fi - done - popd -} -buildAndRunUnitTests -## Save errorlevel to be reported later on -ret=$? - -## Manipulate JUnit report without multiple testsuites entries. -for file in "${BUILD_FOLDER}"/*-unit-tests-junit.xml; do - sed -i.bck ':begin;$!N;s#\n##;tbegin;P;D' "${file}" -done - -## Return the error if any -if [ $ret -ne 0 ] ; then - exit 1 -fi - # Re-enable exit-on-error set -e diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 1414d4007..0c6b7113e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -12,44 +12,41 @@ on: jobs: build: + name: build-agent-library runs-on: ubuntu-latest timeout-minutes: 30 strategy: fail-fast: false matrix: - php-version: - - "7.2" - - "7.3" - - "7.4" - - "8.0" - - "8.1" - - "8.2" - dockerfile: - - "Dockerfile" - - "Dockerfile.alpine" + arch: + - "linux-x86-64" + - "linuxmusl-x86-64" env: - PHP_VERSION: ${{ matrix.php-version }} - DOCKERFILE: ${{ matrix.dockerfile }} + BUILD_ARCHITECTURE: ${{ matrix.arch }} steps: - uses: actions/checkout@v3 - name: Build run: make -f .ci/Makefile build - - name: Build parts for packages - run: make -f .ci/Makefile generate-for-package - uses: actions/upload-artifact@v3 with: - name: package-parts - path: src/ext/modules/*.so - generate-packages: + name: package-parts-${{ matrix.arch }} + path: | + agent/native/_build/${{ matrix.arch }}-release/ext/elastic_apm*.so + agent/native/_build/${{ matrix.arch }}-release/ext/elastic_apm*.debug + build-packages: runs-on: ubuntu-latest needs: - - test + - build steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 with: - name: package-parts - path: src/ext/modules + name: package-parts-linux-x86-64 + path: agent/native/_build/linux-x86-64-release/ext + - uses: actions/download-artifact@v3 + with: + name: package-parts-linuxmusl-x86-64 + path: agent/native/_build/linuxmusl-x86-64-release/ext - name: package run: make -C packaging package - name: package info diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d43d5c058..643f29e57 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -24,7 +24,62 @@ concurrency: cancel-in-progress: ${{ github.ref != 'refs/heads/main' }} jobs: - test: + build: + name: build-agent-library + runs-on: ubuntu-latest + timeout-minutes: 30 + strategy: + fail-fast: false + matrix: + arch: + - "linux-x86-64" + - "linuxmusl-x86-64" + env: + BUILD_ARCHITECTURE: ${{ matrix.arch }} + steps: + - uses: actions/checkout@v3 + - name: Build + run: make -f .ci/Makefile build + - uses: actions/upload-artifact@v3 + with: + name: package-parts-${{ matrix.arch }} + path: | + agent/native/_build/${{ matrix.arch }}-release/ext/elastic_apm*.so + agent/native/_build/${{ matrix.arch }}-release/ext/elastic_apm*.debug + phpt-tests: + name: phpt-tests + runs-on: ubuntu-latest + needs: + - build + timeout-minutes: 10 + strategy: + fail-fast: false + matrix: + php-version: + - "7.2" + - "7.3" + - "7.4" + - "8.0" + - "8.1" + - "8.2" + arch: + - "linux-x86-64" + - "linuxmusl-x86-64" + env: + PHP_VERSION: ${{ matrix.php-version }} + BUILD_ARCHITECTURE: ${{ matrix.arch }} + steps: + - uses: actions/checkout@v3 + - name: Prepare + run: make -f .ci/Makefile prepare + - uses: actions/download-artifact@v3 + with: + name: package-parts-${{ matrix.arch }} + path: agent/native/_build/${{ matrix.arch }}-release/ext/ + - name: phpt-unit-tests + run: make -f .ci/Makefile run-phpt-tests + + static-checks-unit-tests: name: static-checks-unit-tests runs-on: ubuntu-latest timeout-minutes: 30 @@ -48,16 +103,8 @@ jobs: - uses: actions/checkout@v3 - name: Prepare run: make -f .ci/Makefile prepare - - name: Build - run: make -f .ci/Makefile build - name: Static Check / Unit tests run: make -f .ci/Makefile static-check-unit-test - - name: Build parts for packages - run: make -f .ci/Makefile generate-for-package - - uses: actions/upload-artifact@v3 - with: - name: package-parts - path: src/ext/modules/*.so - if: success() || failure() name: Prepare Upload run: >- @@ -74,13 +121,19 @@ jobs: build-packages: runs-on: ubuntu-latest needs: - - test + - build + - static-checks-unit-tests + - phpt-tests steps: - uses: actions/checkout@v3 - uses: actions/download-artifact@v3 with: - name: package-parts - path: src/ext/modules + name: package-parts-linux-x86-64 + path: agent/native/_build/linux-x86-64-release/ext + - uses: actions/download-artifact@v3 + with: + name: package-parts-linuxmusl-x86-64 + path: agent/native/_build/linuxmusl-x86-64-release/ext - name: package run: make -C packaging package - name: package info @@ -106,7 +159,6 @@ jobs: needs: - build-packages - generate-test-packages-matrix - - test runs-on: ubuntu-latest strategy: max-parallel: 20 @@ -128,9 +180,13 @@ jobs: - uses: actions/download-artifact@v3 with: - name: package-parts - path: src/ext/modules - + name: package-parts-linux-x86-64 + path: agent/native/_build/linux-x86-64-release/ext + - uses: actions/download-artifact@v3 + with: + name: package-parts-linuxmusl-x86-64 + path: agent/native/_build/linuxmusl-x86-64-release/ext + - if: ${{ env.TESTING_TYPE == 'lifecycle' }} name: lifecycle test run: | diff --git a/.gitignore b/.gitignore index 2ba19e6cd..118068d19 100644 --- a/.gitignore +++ b/.gitignore @@ -45,3 +45,6 @@ z_local* # Temporary files _TEMP/ + +# Native build folder +agent/native/_build/ diff --git a/DEVELOPMENT.md b/DEVELOPMENT.md index 4865d4199..93a0f4022 100644 --- a/DEVELOPMENT.md +++ b/DEVELOPMENT.md @@ -1,41 +1,58 @@ # Local development - -## Build/package +## Build and package ### Using the docker approach If you don't want to install any of the dependencies you might need to compile and install the library then you can use the Dockerfile. ```bash -## To prepare the build docker container +## To compile the library for all supported PHP releases for glibc Linux distributions +BUILD_ARCHITECTURE=linux-x86-64 make -f .ci/Makefile build + +## To compile the library for all supported PHP releases for musl libc Linux distributions +BUILD_ARCHITECTURE=linuxmusl-x86-64 make -f .ci/Makefile build + +## To prepare the docker container for testing PHP_VERSION=7.2 make -f .ci/Makefile prepare -## To compile the library -PHP_VERSION=7.2 make -f .ci/Makefile build +## To run PHP tests of native extension (phpt) +BUILD_ARCHITECTURE=linux-x86-64 PHP_VERSION=7.2 make -f .ci/Makefile run-phpt-tests ## To run the unit test and static check PHP_VERSION=7.2 make -f .ci/Makefile static-check-unit-test -## To generate the agent extension with the existing PHP API -PHP_VERSION=7.2 make -f .ci/Makefile generate-for-package - ## To run the component tests -PHP_VERSION=7.2 make -f .ci/Makefile component-test +BUILD_ARCHITECTURE=linux-x86-64 PHP_VERSION=7.2 make -f .ci/Makefile component-test ## To release given the GITHUB_TOKEN and TAG_NAME, it creates a draft release GITHUB_TOKEN=**** TAG_NAME=v1.0.0 make -f .ci/Makefile draft-release -## To generate the agent extension with the existing PHP API for alpine -PHP_VERSION=7.2 DOCKERFILE=Dockerfile.alpine make -f .ci/Makefile generate-for-package - ## Help goal will provide further details make -f .ci/Makefile help ``` + _NOTE_: * `PHP_VERSION` can be set to a different PHP version. -* Alpine specific binaries can be generated if using `DOCKERFILE=Dockerfile.alpine` +* For testing of Alpine specific binaries you must run "prepare" task with `DOCKERFILE=Dockerfile.alpine` environment variable set to build proper docker image. + +### Local development with direct calls to cmake inside docker container +\ +If you want to make local development easier, you can call build directly via docker commands.\ +All you need to do is mount the path with the sources to the `/source` directory inside the container.\ +\ +To further speed up build, it is a good idea to mount the local conan cache so that it uses a folder outside the container. The location is arbitrary, but should preferably point outside the source folder. This is optional, if you omit it, conan will place the cache inside the container in the `/home/build/.conan` folder. +\ +Make sure to always use the latest version of the image you are using for the build. You can find the current version inside the `.ci/Makefile` in `build:` section + +```bash +# this will build agent for linux-x86-64 +docker run -v "/path/to/your/apm-agent-php:/source" -v "/path/to/your/conan:/home/build/.conan:rw" -w /source/agent/native elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linux-x86-64-0.0.2 sh -c "cmake --preset linux-x86-64-release && cmake --build --preset linux-x86-64-release" +# this will build agent for linuxmusl-x86-64 +docker run -v "/path/to/your/apm-agent-php:/source" -v "/path/to/your/conan:/home/build/.conan:rw" -w /source/agent/native elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linuxmusl-x86-64-0.0.2 sh -c "cmake --preset linuxmusl-x86-64-release && cmake --build --preset linuxmusl-x86-64-release" + +``` To generate the packages then you can use the `packaging/Dockerfile`, see the below commands: @@ -98,3 +115,59 @@ Jenkins build parameters can be used to run build+test CI pipeline with a custom - Go to `Build with Parameters` - Select log level for agent and/or tests' infrastructure - Click `Build` + + +# Updating docker images used for building and testing +## Building and updating docker images used to build the agent extension + +If you want to update images used to build native extension, you need to go into `agent/native/building/dockerized` folder and modify Dockerfile stored in images folder. In this moment, there are two Dockerfiles: +`Dockerfile_musl` for Linux x86_64 with musl libc implementation and `Dockerfile_glibc` for all other x86_64 distros with glibc implementation. +Then you need to increment image version in `docker-compose.yml`. Remember to update Dockerfiles for all architectures, if needed. To build new images, you just need to call: +```bash +docker-compose build +``` +It will build images for all supported architectures. As a result you should get summary like this: +```bash +Successfully tagged elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linux-x86-64-0.0.1 +Successfully tagged elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linuxmusl-x86-64-0.0.1 +``` + +To test freshly built images, you need to udate image version in `build:` task in ```.ci/Makefile``` and run build task described in [Build/package](#build-and-package) +) + +\ +If everything works as you expected, you just need to push new image to dockerhub by calling: +```bash +docker push elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linux-x86-64-0.0.1 +``` + +## Building and updating docker images used to execute tests +If you want to update images used for testing, you need to go into `packaging/test` folder and modify Dockerfiles stored in folders: +|Folder name|Usage| +|-|-| +|alpine|Testing of apk packages| +|centos|Testing of rpm packages| +|ubuntu|Testing of deb packages| +|ubuntu/apache|Tesing of deb packages with Apache/mod_php| +|ubuntu/fpm|Tesing of deb packages with Apache/php-fpm| + +Then you need to increment image version in `docker-compose.yml`.\ +To build new images, you just need to call: +```bash +docker-compose build +``` +It will build and tag images for all test scenarios. As a result you should get summary like this: +```bash +Successfully tagged elasticobservability/apm-agent-php-dev:packages-test-apk-php-7.2-0.0.1 +... +``` + +\ +To test freshly built images, you need to udate images version in ```packaging/Makefile```. Note that one particular image can be specified multiple times inside this file. Please check carefully that you have updated all the places where the image has been used + +\ +If everything works as you expected, you just need to push new image to dockerhub by calling: +```bash +docker push elasticobservability/apm-agent-php-dev:packages-test-apk-php-7.2-0.0.1 +``` +It should be done for all images you modified. diff --git a/Dockerfile b/Dockerfile index 0192f164b..a7f193e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,14 +3,9 @@ FROM php:${PHP_VERSION}-fpm-buster RUN apt-get -qq update \ && apt-get -qq -y --no-install-recommends install \ - autoconf \ - build-essential \ - curl \ - libcmocka-dev \ - libcurl4-openssl-dev \ - libsqlite3-dev \ procps \ rsyslog \ + curl \ unzip \ wget \ && rm -rf /var/lib/apt/lists/* @@ -23,32 +18,15 @@ RUN docker-php-ext-install \ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -RUN wget -q https://github.com/Kitware/CMake/releases/download/v3.20.5/cmake-3.20.5-Linux-x86_64.tar.gz -O /tmp/cmake.tar.gz \ - && mkdir /usr/bin/cmake \ - && tar -xpf /tmp/cmake.tar.gz --strip-components=1 -C /usr/bin/cmake \ - && rm /tmp/cmake.tar.gz - -ENV PATH="/usr/bin/cmake/bin:${PATH}" - -WORKDIR /app/src/ext +WORKDIR /app/agent/native/ext ENV REPORT_EXIT_STATUS=1 ENV TEST_PHP_DETAILED=1 ENV NO_INTERACTION=1 ENV TEST_PHP_JUNIT=/app/build/junit.xml -ENV CMOCKA_MESSAGE_OUTPUT=XML -ENV CMOCKA_XML_FILE=/app/build/${PHP_VERSION}-%g-unit-tests-junit.xml - -# C call stack capture should be supported on non-Alpine by default -ENV ELASTIC_APM_ASSUME_CAN_CAPTURE_C_STACK_TRACE=true # Disable agent for auxiliary PHP processes to reduce noise in logs ENV ELASTIC_APM_ENABLED=false -CMD phpize \ - && CFLAGS="-std=gnu99" ./configure --enable-elastic_apm \ - && make clean \ - && make - # Create a link to extensions directory to make it easier accessible (paths are different between php releases) RUN ln -s `find /usr/local/lib/php/extensions/ -name opcache.so | head -n1 | xargs dirname` /tmp/extensions diff --git a/Dockerfile.alpine b/Dockerfile.alpine index edb74f61a..5235c2da8 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -3,26 +3,14 @@ FROM php:${PHP_VERSION}-fpm-alpine RUN apk update \ && apk add \ - autoconf \ bash \ - build-base \ - cmake \ - cmocka-dev \ - curl \ - curl-dev \ - git \ logrotate \ procps \ rsyslog \ - sqlite-dev \ - unzip \ - util-linux - -ARG ADD_LIBUNWIND_DEPENDENCY=false -RUN echo "ADD_LIBUNWIND_DEPENDENCY: ${ADD_LIBUNWIND_DEPENDENCY}" -ENV ADD_LIBUNWIND_DEPENDENCY=${ADD_LIBUNWIND_DEPENDENCY} -RUN if [[ "${ADD_LIBUNWIND_DEPENDENCY}" = "true" ]] ; then apk add libunwind-dev ; fi -ENV ELASTIC_APM_ASSUME_CAN_CAPTURE_C_STACK_TRACE=${ADD_LIBUNWIND_DEPENDENCY} + util-linux \ + curl \ + git \ + unzip RUN docker-php-ext-install \ mysqli \ @@ -32,25 +20,15 @@ RUN docker-php-ext-install \ COPY --from=composer:latest /usr/bin/composer /usr/bin/composer -WORKDIR /app/src/ext +WORKDIR /app/agent/native/ext ENV REPORT_EXIT_STATUS=1 ENV TEST_PHP_DETAILED=1 ENV NO_INTERACTION=1 ENV TEST_PHP_JUNIT=/app/build/junit.xml -ENV CMOCKA_MESSAGE_OUTPUT=XML -ENV CMOCKA_XML_FILE=/app/build/alpine-${PHP_VERSION}-%g-unit-tests-junit.xml # Disable agent for auxiliary PHP processes to reduce noise in logs ENV ELASTIC_APM_ENABLED=false -CMD export CFLAGS="-std=gnu99 ${CFLAGS}" ; \ - if [[ "${ADD_LIBUNWIND_DEPENDENCY}" = "true" ]] ; then export LDFLAGS="-lunwind ${LDFLAGS}" ; fi ; \ - echo "CFLAGS: ${CFLAGS}, ADD_LIBUNWIND_DEPENDENCY: ${ADD_LIBUNWIND_DEPENDENCY}, LDFLAGS: ${LDFLAGS}" ; \ - phpize \ - && ./configure --enable-elastic_apm \ - && make clean \ - && make - # Create a link to extensions directory to make it easier accessible (paths are different between php releases) RUN ln -s `find /usr/local/lib/php/extensions/ -name opcache.so | head -n1 | xargs dirname` /tmp/extensions diff --git a/agent/native/CMakeLists.txt b/agent/native/CMakeLists.txt new file mode 100644 index 000000000..a6cb90e4a --- /dev/null +++ b/agent/native/CMakeLists.txt @@ -0,0 +1,110 @@ +cmake_minimum_required(VERSION 3.26.0) + +# set path for our local includes +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/building/cmake") + +#include(elastic_get_git_version) +#elastic_get_git_version(_ELASTIC_PROJECT_VERSION _ELASTIC_SIMPLE_VERSION _ELASTIC_PROJECT_REVISION) + +#message(STATUS "Project version: ${_ELASTIC_PROJECT_VERSION} (${_ELASTIC_SIMPLE_VERSION}) / ${_ELASTIC_PROJECT_REVISION}") + +project("apm-agent-php" +#TODO need to handle versioning somehow and generate C++ and PHP version automatically + # VERSION "${_ELASTIC_PROJECT_VERSION}" + VERSION "1.0" + LANGUAGES C CXX +) + +set(RELEASE_BUILD false) +set(DEBUG_BUILD false) +if(CMAKE_BUILD_TYPE STREQUAL "Release") + set(RELEASE_BUILD true) +elseif(CMAKE_BUILD_TYPE STREQUAL "Debug") + set(DEBUG_BUILD true) +else() + message(FATAL_ERROR "Build type not supported: ${CMAKE_BUILD_TYPE}") +endif() + +# Detect Alpine/MUSLC build +if(EXISTS /etc/alpine-release) + set(MUSL_BUILD true) +endif() + +if ((NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") OR (NOT ${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")) + message(FATAL_ERROR "System or architecture not supported") +endif() + +include(elastic_set_default_build_options) + +message(STATUS "Detected ${CMAKE_CXX_COMPILER_ID} compiler version: ${CMAKE_CXX_COMPILER_VERSION}") + +include(elastic_conan_installer) + +# Install project dependencies + +set(_supported_php_versions 72 73 74 80 81 82) + +function(get_php_api_from_release php_version ret_val) + block(SCOPE_FOR VARIABLES) + set(_php_release_72 20170718) + set(_php_release_73 20180731) + set(_php_release_74 20190902) + set(_php_release_80 20200930) + set(_php_release_81 20210902) + set(_php_release_82 20220829) + + set(${ret_val} ${_php_release_${php_version}}) + return(PROPAGATE ${ret_val}) + endblock() +endfunction() + + +message(STATUS "Creating dependencies from local directories") + +# build pkgconf from local reciepe because default one rely on unstable sources host, we're fetching from github tag +elastic_conan_create( + PATH ${CMAKE_SOURCE_DIR}/building/dependencies/pkgconf + REFERENCE pkgconf/1.9.3@elastic/local + PROFILE ${_CONAN_PROFILE} + ) + +elastic_conan_alias( + REFERENCE pkgconf/1.9.3 + TARGET pkgconf/1.9.3@elastic/local +) + +foreach(_php_version ${_supported_php_versions}) + elastic_conan_create( + PATH ${CMAKE_SOURCE_DIR}/building/dependencies/php${_php_version} + REFERENCE php-headers-${_php_version}/1.0@elastic/local + PROFILE ${_CONAN_PROFILE} + ) +endforeach() + + + +# TODO implement multiarray with mapping of library->version + +set(dependencies + "libcurl/8.0.1" + "cmocka/1.1.5@" + "libunwind/1.6.2" +) + +foreach(_php_version ${_supported_php_versions}) + list(APPEND dependencies "php-headers-${_php_version}/1.0@elastic/local") +endforeach() + +conan_cmake_run(REQUIRES ${dependencies} + OPTIONS Pkg/*:shared=False + libcurl:shared=True + libcurl:with_libssh2=True + BUILD missing + PROFILE ${_CONAN_PROFILE} + PROFILE_BUILD ${_CONAN_PROFILE} + DEBUG_PROFILE ${_CONAN_PROFILE} + RELEASE_PROFILE ${_CONAN_PROFILE} + BASIC_SETUP CMAKE_TARGETS UPDATE NO_OUTPUT_DIRS + ) + +add_subdirectory(ext) diff --git a/agent/native/CMakePresets.json b/agent/native/CMakePresets.json new file mode 100644 index 000000000..bd824af46 --- /dev/null +++ b/agent/native/CMakePresets.json @@ -0,0 +1,159 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "default", + "hidden": true, + "displayName": "Default Config", + "description": "Default build using Makefiles", + "generator": "Unix Makefiles", + "binaryDir": "${sourceDir}/_build/${presetName}", + "environment": { + "MY_ENVIRONMENT_VARIABLE": "Test", + "PATH": "$env{HOME}/ninja/bin:$penv{PATH}" + } + }, + { + "name": "binutils", + "hidden": true, + "environment": { + "PATH": "/opt/binutils-2.40/bin:$penv{PATH}" + } + }, + { + "name": "gcc", + "hidden": true, + "environment": { + "COMPILER_HOME_PATH": "/opt/gcc-12.2.0" + }, + "cacheVariables": { + "CMAKE_C_COMPILER": { + "type": "STRING", + "value": "$env{COMPILER_HOME_PATH}/bin/gcc" + }, + "CMAKE_CXX_COMPILER": { + "type": "STRING", + "value": "$env{COMPILER_HOME_PATH}/bin/g++" + } + } + }, + { + "name": "debug", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Debug" + } + } + }, + { + "name": "release", + "hidden": true, + "cacheVariables": { + "CMAKE_BUILD_TYPE": { + "type": "STRING", + "value": "Release" + } + } + }, + { + "name": "os-type-unix", + "hidden": true, + "inherits": [ + "default", + "gcc" + ], + "generator": "Unix Makefiles" + }, + { + "name": "linux-x86-64-release", + "inherits": [ + "os-type-unix", + "release", + "binutils" + ] + }, + { + "name": "linux-x86-64-debug", + "inherits": [ + "os-type-unix", + "debug", + "binutils" + ] + }, + { + "name": "linuxmusl-x86-64-release", + "inherits": [ + "os-type-unix", + "release", + "binutils" + ] + }, + { + "name": "linuxmusl-x86-64-debug", + "inherits": [ + "os-type-unix", + "debug", + "binutils" + ] + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + }, + { + "name": "release", + "hidden": true, + "configuration": "Release" + }, + { + "name": "debug", + "hidden": true, + "configuration": "Debug" + }, + { + "name": "linux-x86-64-debug", + "configurePreset": "linux-x86-64-debug", + "inherits": [ + "debug" + ] + }, + { + "name": "linux-x86-64-release", + "configurePreset": "linux-x86-64-release", + "inherits": [ + "release" + ] + }, + { + "name": "linuxmusl-x86-64-debug", + "configurePreset": "linuxmusl-x86-64-debug", + "inherits": [ + "debug" + ] + }, + { + "name": "linuxmusl-x86-64-release", + "configurePreset": "linuxmusl-x86-64-release", + "inherits": [ + "release" + ] + } + ], + "testPresets": [ + { + "name": "default", + "configurePreset": "default", + "output": {"outputOnFailure": true}, + "execution": {"noTestsAction": "error", "stopOnFailure": true} + } + ] + } diff --git a/agent/native/building/cmake/conan.cmake b/agent/native/building/cmake/conan.cmake new file mode 100644 index 000000000..1ba78638b --- /dev/null +++ b/agent/native/building/cmake/conan.cmake @@ -0,0 +1,1038 @@ +# The MIT License (MIT) + +# Copyright (c) 2018 JFrog + +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: + +# The above copyright notice and this permission notice shall be included in all +# copies or substantial portions of the Software. + +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +# SOFTWARE. + + + +# This file comes from: https://github.com/conan-io/cmake-conan. Please refer +# to this repository for issues and documentation. + +# Its purpose is to wrap and launch Conan C/C++ Package Manager when cmake is called. +# It will take CMake current settings (os, compiler, compiler version, architecture) +# and translate them to conan settings for installing and retrieving dependencies. + +# It is intended to facilitate developers building projects that have conan dependencies, +# but it is only necessary on the end-user side. It is not necessary to create conan +# packages, in fact it shouldn't be use for that. Check the project documentation. + +# version: 0.18.1 + +# modified to distinguish ABI of glibc and musl - force downloaded packages to build locally + +include(CMakeParseArguments) + +function(_get_msvc_ide_version result) + set(${result} "" PARENT_SCOPE) + if(NOT MSVC_VERSION VERSION_LESS 1400 AND MSVC_VERSION VERSION_LESS 1500) + set(${result} 8 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1500 AND MSVC_VERSION VERSION_LESS 1600) + set(${result} 9 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1600 AND MSVC_VERSION VERSION_LESS 1700) + set(${result} 10 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1700 AND MSVC_VERSION VERSION_LESS 1800) + set(${result} 11 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1800 AND MSVC_VERSION VERSION_LESS 1900) + set(${result} 12 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1900 AND MSVC_VERSION VERSION_LESS 1910) + set(${result} 14 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1910 AND MSVC_VERSION VERSION_LESS 1920) + set(${result} 15 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1920 AND MSVC_VERSION VERSION_LESS 1930) + set(${result} 16 PARENT_SCOPE) + elseif(NOT MSVC_VERSION VERSION_LESS 1930 AND MSVC_VERSION VERSION_LESS 1940) + set(${result} 17 PARENT_SCOPE) + else() + message(FATAL_ERROR "Conan: Unknown MSVC compiler version [${MSVC_VERSION}]") + endif() +endfunction() + +macro(_conan_detect_build_type) + conan_parse_arguments(${ARGV}) + + if(ARGUMENTS_BUILD_TYPE) + set(_CONAN_SETTING_BUILD_TYPE ${ARGUMENTS_BUILD_TYPE}) + elseif(CMAKE_BUILD_TYPE) + set(_CONAN_SETTING_BUILD_TYPE ${CMAKE_BUILD_TYPE}) + else() + message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") + endif() + + string(TOUPPER ${_CONAN_SETTING_BUILD_TYPE} _CONAN_SETTING_BUILD_TYPE_UPPER) + if (_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "DEBUG") + set(_CONAN_SETTING_BUILD_TYPE "Debug") + elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELEASE") + set(_CONAN_SETTING_BUILD_TYPE "Release") + elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "RELWITHDEBINFO") + set(_CONAN_SETTING_BUILD_TYPE "RelWithDebInfo") + elseif(_CONAN_SETTING_BUILD_TYPE_UPPER STREQUAL "MINSIZEREL") + set(_CONAN_SETTING_BUILD_TYPE "MinSizeRel") + endif() +endmacro() + +macro(_conan_check_system_name) + #handle -s os setting + if(CMAKE_SYSTEM_NAME AND NOT CMAKE_SYSTEM_NAME STREQUAL "Generic") + #use default conan os setting if CMAKE_SYSTEM_NAME is not defined + set(CONAN_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) + if(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") + set(CONAN_SYSTEM_NAME Macos) + endif() + if(${CMAKE_SYSTEM_NAME} STREQUAL "QNX") + set(CONAN_SYSTEM_NAME Neutrino) + endif() + set(CONAN_SUPPORTED_PLATFORMS Windows Linux Macos Android iOS FreeBSD WindowsStore WindowsCE watchOS tvOS FreeBSD SunOS AIX Arduino Emscripten Neutrino) + list (FIND CONAN_SUPPORTED_PLATFORMS "${CONAN_SYSTEM_NAME}" _index) + if (${_index} GREATER -1) + #check if the cmake system is a conan supported one + set(_CONAN_SETTING_OS ${CONAN_SYSTEM_NAME}) + else() + message(FATAL_ERROR "cmake system ${CONAN_SYSTEM_NAME} is not supported by conan. Use one of ${CONAN_SUPPORTED_PLATFORMS}") + endif() + endif() +endmacro() + +macro(_conan_check_language) + get_property(_languages GLOBAL PROPERTY ENABLED_LANGUAGES) + if (";${_languages};" MATCHES ";CXX;") + set(LANGUAGE CXX) + set(USING_CXX 1) + elseif (";${_languages};" MATCHES ";C;") + set(LANGUAGE C) + set(USING_CXX 0) + else () + message(FATAL_ERROR "Conan: Neither C or C++ was detected as a language for the project. Unabled to detect compiler version.") + endif() +endmacro() + +macro(_conan_detect_compiler) + + conan_parse_arguments(${ARGV}) + + if(ARGUMENTS_ARCH) + set(_CONAN_SETTING_ARCH ${ARGUMENTS_ARCH}) + endif() + + if(USING_CXX) + set(_CONAN_SETTING_COMPILER_CPPSTD ${CMAKE_CXX_STANDARD}) + endif() + + if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) + # using GCC + # TODO: Handle other params + string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) + list(GET VERSION_LIST 0 MAJOR) + list(GET VERSION_LIST 1 MINOR) + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + if(${MAJOR} GREATER 4) + set(COMPILER_VERSION ${MAJOR}) + endif() + set(_CONAN_SETTING_COMPILER gcc) + set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) + if (USING_CXX) + conan_cmake_detect_unix_libcxx(_LIBCXX) + set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) + endif () + elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Intel) + string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) + list(GET VERSION_LIST 0 MAJOR) + list(GET VERSION_LIST 1 MINOR) + set(COMPILER_VERSION ${MAJOR}.${MINOR}) + set(_CONAN_SETTING_COMPILER intel) + set(_CONAN_SETTING_COMPILER_VERSION ${COMPILER_VERSION}) + if (USING_CXX) + conan_cmake_detect_unix_libcxx(_LIBCXX) + set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) + endif () + elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL AppleClang) + # using AppleClang + string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) + list(GET VERSION_LIST 0 MAJOR) + list(GET VERSION_LIST 1 MINOR) + set(_CONAN_SETTING_COMPILER apple-clang) + set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) + if (USING_CXX) + conan_cmake_detect_unix_libcxx(_LIBCXX) + set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) + endif () + elseif (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang + AND NOT "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" + AND NOT "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC") + + string(REPLACE "." ";" VERSION_LIST ${CMAKE_${LANGUAGE}_COMPILER_VERSION}) + list(GET VERSION_LIST 0 MAJOR) + list(GET VERSION_LIST 1 MINOR) + set(_CONAN_SETTING_COMPILER clang) + set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}.${MINOR}) + if(APPLE) + cmake_policy(GET CMP0025 APPLE_CLANG_POLICY) + if(NOT APPLE_CLANG_POLICY STREQUAL NEW) + message(STATUS "Conan: APPLE and Clang detected. Assuming apple-clang compiler. Set CMP0025 to avoid it") + set(_CONAN_SETTING_COMPILER apple-clang) + endif() + endif() + if(${_CONAN_SETTING_COMPILER} STREQUAL clang AND ${MAJOR} GREATER 7) + set(_CONAN_SETTING_COMPILER_VERSION ${MAJOR}) + endif() + if (USING_CXX) + conan_cmake_detect_unix_libcxx(_LIBCXX) + set(_CONAN_SETTING_COMPILER_LIBCXX ${_LIBCXX}) + endif () + elseif(${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL MSVC + OR (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL Clang + AND "${CMAKE_${LANGUAGE}_COMPILER_FRONTEND_VARIANT}" STREQUAL "MSVC" + AND "${CMAKE_${LANGUAGE}_SIMULATE_ID}" STREQUAL "MSVC")) + + set(_VISUAL "Visual Studio") + _get_msvc_ide_version(_VISUAL_VERSION) + if("${_VISUAL_VERSION}" STREQUAL "") + message(FATAL_ERROR "Conan: Visual Studio not recognized") + else() + set(_CONAN_SETTING_COMPILER ${_VISUAL}) + set(_CONAN_SETTING_COMPILER_VERSION ${_VISUAL_VERSION}) + endif() + + if(NOT _CONAN_SETTING_ARCH) + if (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "64") + set(_CONAN_SETTING_ARCH x86_64) + elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "^ARM") + message(STATUS "Conan: Using default ARM architecture from MSVC") + set(_CONAN_SETTING_ARCH armv6) + elseif (MSVC_${LANGUAGE}_ARCHITECTURE_ID MATCHES "86") + set(_CONAN_SETTING_ARCH x86) + else () + message(FATAL_ERROR "Conan: Unknown MSVC architecture [${MSVC_${LANGUAGE}_ARCHITECTURE_ID}]") + endif() + endif() + + conan_cmake_detect_vs_runtime(_vs_runtime ${ARGV}) + message(STATUS "Conan: Detected VS runtime: ${_vs_runtime}") + set(_CONAN_SETTING_COMPILER_RUNTIME ${_vs_runtime}) + + if (CMAKE_GENERATOR_TOOLSET) + set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) + elseif(CMAKE_VS_PLATFORM_TOOLSET AND (CMAKE_GENERATOR STREQUAL "Ninja")) + set(_CONAN_SETTING_COMPILER_TOOLSET ${CMAKE_VS_PLATFORM_TOOLSET}) + endif() + else() + message(FATAL_ERROR "Conan: compiler setup not recognized") + endif() + +endmacro() + +function(conan_cmake_settings result) + #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER}) + #message(STATUS "COMPILER " ${CMAKE_CXX_COMPILER_ID}) + #message(STATUS "VERSION " ${CMAKE_CXX_COMPILER_VERSION}) + #message(STATUS "FLAGS " ${CMAKE_LANG_FLAGS}) + #message(STATUS "LIB ARCH " ${CMAKE_CXX_LIBRARY_ARCHITECTURE}) + #message(STATUS "BUILD TYPE " ${CMAKE_BUILD_TYPE}) + #message(STATUS "GENERATOR " ${CMAKE_GENERATOR}) + #message(STATUS "GENERATOR WIN64 " ${CMAKE_CL_64}) + + message(STATUS "Conan: Automatic detection of conan settings from cmake") + + conan_parse_arguments(${ARGV}) + + _conan_detect_build_type(${ARGV}) + + _conan_check_system_name() + + _conan_check_language() + + _conan_detect_compiler(${ARGV}) + + # If profile is defined it is used + if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND ARGUMENTS_DEBUG_PROFILE) + set(_APPLIED_PROFILES ${ARGUMENTS_DEBUG_PROFILE}) + elseif(CMAKE_BUILD_TYPE STREQUAL "Release" AND ARGUMENTS_RELEASE_PROFILE) + set(_APPLIED_PROFILES ${ARGUMENTS_RELEASE_PROFILE}) + elseif(CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo" AND ARGUMENTS_RELWITHDEBINFO_PROFILE) + set(_APPLIED_PROFILES ${ARGUMENTS_RELWITHDEBINFO_PROFILE}) + elseif(CMAKE_BUILD_TYPE STREQUAL "MinSizeRel" AND ARGUMENTS_MINSIZEREL_PROFILE) + set(_APPLIED_PROFILES ${ARGUMENTS_MINSIZEREL_PROFILE}) + elseif(ARGUMENTS_PROFILE) + set(_APPLIED_PROFILES ${ARGUMENTS_PROFILE}) + endif() + + foreach(ARG ${_APPLIED_PROFILES}) + set(_SETTINGS ${_SETTINGS} -pr=${ARG}) + endforeach() + foreach(ARG ${ARGUMENTS_PROFILE_BUILD}) + conan_check(VERSION 1.24.0 REQUIRED DETECT_QUIET) + set(_SETTINGS ${_SETTINGS} -pr:b=${ARG}) + endforeach() + + if(NOT _SETTINGS OR ARGUMENTS_PROFILE_AUTO STREQUAL "ALL") + set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version + compiler.runtime compiler.libcxx compiler.toolset) + endif() + + # remove any manually specified settings from the autodetected settings + foreach(ARG ${ARGUMENTS_SETTINGS}) + string(REGEX MATCH "[^=]*" MANUAL_SETTING "${ARG}") + message(STATUS "Conan: ${MANUAL_SETTING} was added as an argument. Not using the autodetected one.") + list(REMOVE_ITEM ARGUMENTS_PROFILE_AUTO "${MANUAL_SETTING}") + endforeach() + + # Automatic from CMake + foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) + string(TOUPPER ${ARG} _arg_name) + string(REPLACE "." "_" _arg_name ${_arg_name}) + if(_CONAN_SETTING_${_arg_name}) + set(_SETTINGS ${_SETTINGS} -s ${ARG}=${_CONAN_SETTING_${_arg_name}}) + endif() + endforeach() + + + # Hack to distinguish glibc and musl: https://github.com/conan-io/conan/issues/3972#issuecomment-464703892 + if (${CMAKE_${LANGUAGE}_COMPILER_ID} STREQUAL GNU) + if (EXISTS "/etc/alpine-release" AND _CONAN_SETTING_OS STREQUAL "Linux") + set(_SETTINGS ${_SETTINGS} -s compiler.libc=musl -s os.distro=Alpine) + else() + set(_SETTINGS ${_SETTINGS} -s compiler.libc=glibc -s os.distro=Centos7) + endif() + endif() + + foreach(ARG ${ARGUMENTS_SETTINGS}) + set(_SETTINGS ${_SETTINGS} -s ${ARG}) + endforeach() + + message(STATUS "Conan: Settings= ${_SETTINGS}") + + set(${result} ${_SETTINGS} PARENT_SCOPE) +endfunction() + + +function(conan_cmake_detect_unix_libcxx result) + # Take into account any -stdlib in compile options + get_directory_property(compile_options DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_OPTIONS) + string(GENEX_STRIP "${compile_options}" compile_options) + + # Take into account any _GLIBCXX_USE_CXX11_ABI in compile definitions + get_directory_property(defines DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} COMPILE_DEFINITIONS) + string(GENEX_STRIP "${defines}" defines) + + foreach(define ${defines}) + if(define MATCHES "_GLIBCXX_USE_CXX11_ABI") + if(define MATCHES "^-D") + set(compile_options ${compile_options} "${define}") + else() + set(compile_options ${compile_options} "-D${define}") + endif() + endif() + endforeach() + + # add additional compiler options ala cmRulePlaceholderExpander::ExpandRuleVariable + set(EXPAND_CXX_COMPILER ${CMAKE_CXX_COMPILER}) + if(CMAKE_CXX_COMPILER_ARG1) + # CMake splits CXX="foo bar baz" into CMAKE_CXX_COMPILER="foo", CMAKE_CXX_COMPILER_ARG1="bar baz" + # without this, ccache, winegcc, or other wrappers might lose all their arguments + separate_arguments(SPLIT_CXX_COMPILER_ARG1 NATIVE_COMMAND ${CMAKE_CXX_COMPILER_ARG1}) + list(APPEND EXPAND_CXX_COMPILER ${SPLIT_CXX_COMPILER_ARG1}) + endif() + + if(CMAKE_CXX_COMPILE_OPTIONS_TARGET AND CMAKE_CXX_COMPILER_TARGET) + # without --target= we may be calling the wrong underlying GCC + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_TARGET}${CMAKE_CXX_COMPILER_TARGET}") + endif() + + if(CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN AND CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN) + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_EXTERNAL_TOOLCHAIN}${CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN}") + endif() + + if(CMAKE_CXX_COMPILE_OPTIONS_SYSROOT) + # without --sysroot= we may find the wrong #include + if(CMAKE_SYSROOT_COMPILE) + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT_COMPILE}") + elseif(CMAKE_SYSROOT) + list(APPEND EXPAND_CXX_COMPILER "${CMAKE_CXX_COMPILE_OPTIONS_SYSROOT}${CMAKE_SYSROOT}") + endif() + endif() + + separate_arguments(SPLIT_CXX_FLAGS NATIVE_COMMAND ${CMAKE_CXX_FLAGS}) + + if(CMAKE_OSX_SYSROOT) + set(xcode_sysroot_option "--sysroot=${CMAKE_OSX_SYSROOT}") + endif() + + execute_process( + COMMAND ${CMAKE_COMMAND} -E echo "#include " + COMMAND ${EXPAND_CXX_COMPILER} ${SPLIT_CXX_FLAGS} -x c++ ${xcode_sysroot_option} ${compile_options} -E -dM - + OUTPUT_VARIABLE string_defines + ) + + if(string_defines MATCHES "#define __GLIBCXX__") + # Allow -D_GLIBCXX_USE_CXX11_ABI=ON/OFF as argument to cmake + if(DEFINED _GLIBCXX_USE_CXX11_ABI) + if(_GLIBCXX_USE_CXX11_ABI) + set(${result} libstdc++11 PARENT_SCOPE) + return() + else() + set(${result} libstdc++ PARENT_SCOPE) + return() + endif() + endif() + + if(string_defines MATCHES "#define _GLIBCXX_USE_CXX11_ABI 1\n") + set(${result} libstdc++11 PARENT_SCOPE) + else() + # Either the compiler is missing the define because it is old, and so + # it can't use the new abi, or the compiler was configured to use the + # old abi by the user or distro (e.g. devtoolset on RHEL/CentOS) + set(${result} libstdc++ PARENT_SCOPE) + endif() + else() + set(${result} libc++ PARENT_SCOPE) + endif() +endfunction() + +function(conan_cmake_detect_vs_runtime result) + + conan_parse_arguments(${ARGV}) + if(ARGUMENTS_BUILD_TYPE) + set(build_type "${ARGUMENTS_BUILD_TYPE}") + elseif(CMAKE_BUILD_TYPE) + set(build_type "${CMAKE_BUILD_TYPE}") + else() + message(FATAL_ERROR "Please specify in command line CMAKE_BUILD_TYPE (-DCMAKE_BUILD_TYPE=Release)") + endif() + + if(build_type) + string(TOUPPER "${build_type}" build_type) + endif() + set(variables CMAKE_CXX_FLAGS_${build_type} CMAKE_C_FLAGS_${build_type} CMAKE_CXX_FLAGS CMAKE_C_FLAGS) + foreach(variable ${variables}) + if(NOT "${${variable}}" STREQUAL "") + string(REPLACE " " ";" flags "${${variable}}") + foreach (flag ${flags}) + if("${flag}" STREQUAL "/MD" OR "${flag}" STREQUAL "/MDd" OR "${flag}" STREQUAL "/MT" OR "${flag}" STREQUAL "/MTd") + string(SUBSTRING "${flag}" 1 -1 runtime) + set(${result} "${runtime}" PARENT_SCOPE) + return() + endif() + endforeach() + endif() + endforeach() + if("${build_type}" STREQUAL "DEBUG") + set(${result} "MDd" PARENT_SCOPE) + else() + set(${result} "MD" PARENT_SCOPE) + endif() +endfunction() + +function(_collect_settings result) + set(ARGUMENTS_PROFILE_AUTO arch build_type compiler compiler.version + compiler.runtime compiler.libcxx compiler.toolset + compiler.cppstd) + foreach(ARG ${ARGUMENTS_PROFILE_AUTO}) + string(TOUPPER ${ARG} _arg_name) + string(REPLACE "." "_" _arg_name ${_arg_name}) + if(_CONAN_SETTING_${_arg_name}) + set(detected_setings ${detected_setings} ${ARG}=${_CONAN_SETTING_${_arg_name}}) + endif() + endforeach() + set(${result} ${detected_setings} PARENT_SCOPE) +endfunction() + +function(conan_cmake_autodetect detected_settings) + _conan_detect_build_type(${ARGV}) + _conan_check_system_name() + _conan_check_language() + _conan_detect_compiler(${ARGV}) + _collect_settings(collected_settings) + set(${detected_settings} ${collected_settings} PARENT_SCOPE) +endfunction() + +macro(conan_parse_arguments) + set(options BASIC_SETUP CMAKE_TARGETS UPDATE KEEP_RPATHS NO_LOAD NO_OUTPUT_DIRS OUTPUT_QUIET NO_IMPORTS SKIP_STD) + set(oneValueArgs CONANFILE ARCH BUILD_TYPE INSTALL_FOLDER OUTPUT_FOLDER CONAN_COMMAND) + set(multiValueArgs DEBUG_PROFILE RELEASE_PROFILE RELWITHDEBINFO_PROFILE MINSIZEREL_PROFILE + PROFILE REQUIRES OPTIONS IMPORTS SETTINGS BUILD ENV GENERATORS PROFILE_AUTO + INSTALL_ARGS CONFIGURATION_TYPES PROFILE_BUILD BUILD_REQUIRES) + cmake_parse_arguments(ARGUMENTS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) +endmacro() + +function(old_conan_cmake_install) + # Calls "conan install" + # Argument BUILD is equivalant to --build={missing, PkgName,...} or + # --build when argument is 'BUILD all' (which builds all packages from source) + # Argument CONAN_COMMAND, to specify the conan path, e.g. in case of running from source + # cmake does not identify conan as command, even if it is +x and it is in the path + conan_parse_arguments(${ARGV}) + + if(CONAN_CMAKE_MULTI) + set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake_multi) + else() + set(ARGUMENTS_GENERATORS ${ARGUMENTS_GENERATORS} cmake) + endif() + + set(CONAN_BUILD_POLICY "") + foreach(ARG ${ARGUMENTS_BUILD}) + if(${ARG} STREQUAL "all") + set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build) + break() + else() + set(CONAN_BUILD_POLICY ${CONAN_BUILD_POLICY} --build=${ARG}) + endif() + endforeach() + if(ARGUMENTS_CONAN_COMMAND) + set(CONAN_CMD ${ARGUMENTS_CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + set(CONAN_OPTIONS "") + if(ARGUMENTS_CONANFILE) + if(IS_ABSOLUTE ${ARGUMENTS_CONANFILE}) + set(CONANFILE ${ARGUMENTS_CONANFILE}) + else() + set(CONANFILE ${CMAKE_CURRENT_SOURCE_DIR}/${ARGUMENTS_CONANFILE}) + endif() + else() + set(CONANFILE ".") + endif() + foreach(ARG ${ARGUMENTS_OPTIONS}) + set(CONAN_OPTIONS ${CONAN_OPTIONS} -o=${ARG}) + endforeach() + if(ARGUMENTS_UPDATE) + set(CONAN_INSTALL_UPDATE --update) + endif() + if(ARGUMENTS_NO_IMPORTS) + set(CONAN_INSTALL_NO_IMPORTS --no-imports) + endif() + set(CONAN_INSTALL_FOLDER "") + if(ARGUMENTS_INSTALL_FOLDER) + set(CONAN_INSTALL_FOLDER -if=${ARGUMENTS_INSTALL_FOLDER}) + endif() + set(CONAN_OUTPUT_FOLDER "") + if(ARGUMENTS_OUTPUT_FOLDER) + set(CONAN_OUTPUT_FOLDER -of=${ARGUMENTS_OUTPUT_FOLDER}) + endif() + foreach(ARG ${ARGUMENTS_GENERATORS}) + set(CONAN_GENERATORS ${CONAN_GENERATORS} -g=${ARG}) + endforeach() + foreach(ARG ${ARGUMENTS_ENV}) + set(CONAN_ENV_VARS ${CONAN_ENV_VARS} -e=${ARG}) + endforeach() + set(conan_args install ${CONANFILE} ${settings} ${CONAN_ENV_VARS} ${CONAN_GENERATORS} ${CONAN_BUILD_POLICY} ${CONAN_INSTALL_UPDATE} ${CONAN_INSTALL_NO_IMPORTS} ${CONAN_OPTIONS} ${CONAN_INSTALL_FOLDER} ${ARGUMENTS_INSTALL_ARGS}) + + string (REPLACE ";" " " _conan_args "${conan_args}") + message(STATUS "Conan executing: ${CONAN_CMD} ${_conan_args}") + + if(ARGUMENTS_OUTPUT_QUIET) + execute_process(COMMAND ${CONAN_CMD} ${conan_args} + RESULT_VARIABLE return_code + OUTPUT_VARIABLE conan_output + ERROR_VARIABLE conan_output + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + else() + execute_process(COMMAND ${CONAN_CMD} ${conan_args} + RESULT_VARIABLE return_code + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + endif() + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + +endfunction() + +function(conan_cmake_install) + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + + set(installOptions UPDATE NO_IMPORTS OUTPUT_QUIET ERROR_QUIET) + set(installOneValueArgs PATH_OR_REFERENCE REFERENCE REMOTE LOCKFILE LOCKFILE_OUT LOCKFILE_NODE_ID INSTALL_FOLDER OUTPUT_FOLDER) + set(installMultiValueArgs GENERATOR BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE + PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) + cmake_parse_arguments(ARGS "${installOptions}" "${installOneValueArgs}" "${installMultiValueArgs}" ${ARGN}) + foreach(arg ${installOptions}) + if(ARGS_${arg}) + set(${arg} ${${arg}} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${installOneValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "REMOTE") + set(flag "--remote") + elseif("${arg}" STREQUAL "LOCKFILE") + set(flag "--lockfile") + elseif("${arg}" STREQUAL "LOCKFILE_OUT") + set(flag "--lockfile-out") + elseif("${arg}" STREQUAL "LOCKFILE_NODE_ID") + set(flag "--lockfile-node-id") + elseif("${arg}" STREQUAL "INSTALL_FOLDER") + set(flag "--install-folder") + elseif("${arg}" STREQUAL "OUTPUT_FOLDER") + set(flag "--output-folder") + endif() + set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${installMultiValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "GENERATOR") + set(flag "--generator") + elseif("${arg}" STREQUAL "BUILD") + set(flag "--build") + elseif("${arg}" STREQUAL "ENV") + set(flag "--env") + elseif("${arg}" STREQUAL "ENV_HOST") + set(flag "--env:host") + elseif("${arg}" STREQUAL "ENV_BUILD") + set(flag "--env:build") + elseif("${arg}" STREQUAL "OPTIONS") + set(flag "--options") + elseif("${arg}" STREQUAL "OPTIONS_HOST") + set(flag "--options:host") + elseif("${arg}" STREQUAL "OPTIONS_BUILD") + set(flag "--options:build") + elseif("${arg}" STREQUAL "PROFILE") + set(flag "--profile") + elseif("${arg}" STREQUAL "PROFILE_HOST") + set(flag "--profile:host") + elseif("${arg}" STREQUAL "PROFILE_BUILD") + set(flag "--profile:build") + elseif("${arg}" STREQUAL "SETTINGS") + set(flag "--settings") + elseif("${arg}" STREQUAL "SETTINGS_HOST") + set(flag "--settings:host") + elseif("${arg}" STREQUAL "SETTINGS_BUILD") + set(flag "--settings:build") + endif() + list(LENGTH ARGS_${arg} numargs) + foreach(item ${ARGS_${arg}}) + if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") + set(${arg} "--build") + break() + endif() + set(${arg} ${${arg}} ${flag} ${item}) + endforeach() + endif() + endforeach() + if(DEFINED UPDATE) + set(UPDATE --update) + endif() + if(DEFINED NO_IMPORTS) + set(NO_IMPORTS --no-imports) + endif() + set(install_args install ${PATH_OR_REFERENCE} ${REFERENCE} ${UPDATE} ${NO_IMPORTS} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} ${OUTPUT_FOLDER} + ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} + ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) + + string(REPLACE ";" " " _install_args "${install_args}") + message(STATUS "Conan executing: ${CONAN_CMD} ${_install_args}") + + if(ARGS_OUTPUT_QUIET) + set(OUTPUT_OPT OUTPUT_QUIET) + endif() + if(ARGS_ERROR_QUIET) + set(ERROR_OPT ERROR_QUIET) + endif() + + execute_process(COMMAND ${CONAN_CMD} ${install_args} + RESULT_VARIABLE return_code + ${OUTPUT_OPT} + ${ERROR_OPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(NOT "${return_code}" STREQUAL "0") + if (ARGS_ERROR_QUIET) + message(WARNING "Conan install failed='${return_code}'") + else() + message(FATAL_ERROR "Conan install failed='${return_code}'") + endif() + endif() + +endfunction() + +function(conan_cmake_lock_create) + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + + set(lockCreateOptions UPDATE BASE OUTPUT_QUIET ERROR_QUIET) + set(lockCreateOneValueArgs PATH REFERENCE REMOTE LOCKFILE LOCKFILE_OUT) + set(lockCreateMultiValueArgs BUILD ENV ENV_HOST ENV_BUILD OPTIONS_HOST OPTIONS OPTIONS_BUILD PROFILE + PROFILE_HOST PROFILE_BUILD SETTINGS SETTINGS_HOST SETTINGS_BUILD) + cmake_parse_arguments(ARGS "${lockCreateOptions}" "${lockCreateOneValueArgs}" "${lockCreateMultiValueArgs}" ${ARGN}) + foreach(arg ${lockCreateOptions}) + if(ARGS_${arg}) + set(${arg} ${${arg}} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${lockCreateOneValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "REMOTE") + set(flag "--remote") + elseif("${arg}" STREQUAL "LOCKFILE") + set(flag "--lockfile") + elseif("${arg}" STREQUAL "LOCKFILE_OUT") + set(flag "--lockfile-out") + endif() + set(${arg} ${${arg}} ${flag} ${ARGS_${arg}}) + endif() + endforeach() + foreach(arg ${lockCreateMultiValueArgs}) + if(DEFINED ARGS_${arg}) + if("${arg}" STREQUAL "BUILD") + set(flag "--build") + elseif("${arg}" STREQUAL "ENV") + set(flag "--env") + elseif("${arg}" STREQUAL "ENV_HOST") + set(flag "--env:host") + elseif("${arg}" STREQUAL "ENV_BUILD") + set(flag "--env:build") + elseif("${arg}" STREQUAL "OPTIONS") + set(flag "--options") + elseif("${arg}" STREQUAL "OPTIONS_HOST") + set(flag "--options:host") + elseif("${arg}" STREQUAL "OPTIONS_BUILD") + set(flag "--options:build") + elseif("${arg}" STREQUAL "PROFILE") + set(flag "--profile") + elseif("${arg}" STREQUAL "PROFILE_HOST") + set(flag "--profile:host") + elseif("${arg}" STREQUAL "PROFILE_BUILD") + set(flag "--profile:build") + elseif("${arg}" STREQUAL "SETTINGS") + set(flag "--settings") + elseif("${arg}" STREQUAL "SETTINGS_HOST") + set(flag "--settings:host") + elseif("${arg}" STREQUAL "SETTINGS_BUILD") + set(flag "--settings:build") + endif() + list(LENGTH ARGS_${arg} numargs) + foreach(item ${ARGS_${arg}}) + if(${item} STREQUAL "all" AND ${arg} STREQUAL "BUILD") + set(${arg} "--build") + break() + endif() + set(${arg} ${${arg}} ${flag} ${item}) + endforeach() + endif() + endforeach() + if(DEFINED UPDATE) + set(UPDATE --update) + endif() + if(DEFINED BASE) + set(BASE --base) + endif() + set(lock_create_Args lock create ${PATH} ${REFERENCE} ${UPDATE} ${BASE} ${REMOTE} ${LOCKFILE} ${LOCKFILE_OUT} ${LOCKFILE_NODE_ID} ${INSTALL_FOLDER} + ${GENERATOR} ${BUILD} ${ENV} ${ENV_HOST} ${ENV_BUILD} ${OPTIONS} ${OPTIONS_HOST} ${OPTIONS_BUILD} + ${PROFILE} ${PROFILE_HOST} ${PROFILE_BUILD} ${SETTINGS} ${SETTINGS_HOST} ${SETTINGS_BUILD}) + + string(REPLACE ";" " " _lock_create_Args "${lock_create_Args}") + message(STATUS "Conan executing: ${CONAN_CMD} ${_lock_create_Args}") + + if(ARGS_OUTPUT_QUIET) + set(OUTPUT_OPT OUTPUT_QUIET) + endif() + if(ARGS_ERROR_QUIET) + set(ERROR_OPT ERROR_QUIET) + endif() + + execute_process(COMMAND ${CONAN_CMD} ${lock_create_Args} + RESULT_VARIABLE return_code + ${OUTPUT_OPT} + ${ERROR_OPT} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) + + if(NOT "${return_code}" STREQUAL "0") + if (ARGS_ERROR_QUIET) + message(WARNING "Conan lock create failed='${return_code}'") + else() + message(FATAL_ERROR "Conan lock create failed='${return_code}'") + endif() + endif() +endfunction() + +function(conan_cmake_setup_conanfile) + conan_parse_arguments(${ARGV}) + if(ARGUMENTS_CONANFILE) + get_filename_component(_CONANFILE_NAME ${ARGUMENTS_CONANFILE} NAME) + # configure_file will make sure cmake re-runs when conanfile is updated + configure_file(${ARGUMENTS_CONANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk COPYONLY) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/${_CONANFILE_NAME}.junk) + else() + conan_cmake_generate_conanfile(ON ${ARGV}) + endif() +endfunction() + +function(conan_cmake_configure) + conan_cmake_generate_conanfile(OFF ${ARGV}) +endfunction() + +# Generate, writing in disk a conanfile.txt with the requires, options, and imports +# specified as arguments +# This will be considered as temporary file, generated in CMAKE_CURRENT_BINARY_DIR) +function(conan_cmake_generate_conanfile DEFAULT_GENERATOR) + + conan_parse_arguments(${ARGV}) + + set(_FN "${CMAKE_CURRENT_BINARY_DIR}/conanfile.txt") + file(WRITE ${_FN} "") + + if(DEFINED ARGUMENTS_REQUIRES) + file(APPEND ${_FN} "[requires]\n") + foreach(REQUIRE ${ARGUMENTS_REQUIRES}) + file(APPEND ${_FN} ${REQUIRE} "\n") + endforeach() + endif() + + if (DEFAULT_GENERATOR OR DEFINED ARGUMENTS_GENERATORS) + file(APPEND ${_FN} "[generators]\n") + if (DEFAULT_GENERATOR) + file(APPEND ${_FN} "cmake\n") + endif() + if (DEFINED ARGUMENTS_GENERATORS) + foreach(GENERATOR ${ARGUMENTS_GENERATORS}) + file(APPEND ${_FN} ${GENERATOR} "\n") + endforeach() + endif() + endif() + + if(DEFINED ARGUMENTS_BUILD_REQUIRES) + file(APPEND ${_FN} "[build_requires]\n") + foreach(BUILD_REQUIRE ${ARGUMENTS_BUILD_REQUIRES}) + file(APPEND ${_FN} ${BUILD_REQUIRE} "\n") + endforeach() + endif() + + if(DEFINED ARGUMENTS_IMPORTS) + file(APPEND ${_FN} "[imports]\n") + foreach(IMPORTS ${ARGUMENTS_IMPORTS}) + file(APPEND ${_FN} ${IMPORTS} "\n") + endforeach() + endif() + + if(DEFINED ARGUMENTS_OPTIONS) + file(APPEND ${_FN} "[options]\n") + foreach(OPTION ${ARGUMENTS_OPTIONS}) + file(APPEND ${_FN} ${OPTION} "\n") + endforeach() + endif() + +endfunction() + + +macro(conan_load_buildinfo) + if(CONAN_CMAKE_MULTI) + set(_CONANBUILDINFO conanbuildinfo_multi.cmake) + else() + set(_CONANBUILDINFO conanbuildinfo.cmake) + endif() + if(ARGUMENTS_INSTALL_FOLDER) + set(_CONANBUILDINFOFOLDER ${ARGUMENTS_INSTALL_FOLDER}) + else() + set(_CONANBUILDINFOFOLDER ${CMAKE_CURRENT_BINARY_DIR}) + endif() + # Checks for the existence of conanbuildinfo.cmake, and loads it + # important that it is macro, so variables defined at parent scope + if(EXISTS "${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}") + message(STATUS "Conan: Loading ${_CONANBUILDINFO}") + include(${_CONANBUILDINFOFOLDER}/${_CONANBUILDINFO}) + else() + message(FATAL_ERROR "${_CONANBUILDINFO} doesn't exist in ${CMAKE_CURRENT_BINARY_DIR}") + endif() +endmacro() + + +macro(conan_cmake_run) + conan_parse_arguments(${ARGV}) + + if(ARGUMENTS_CONFIGURATION_TYPES AND NOT CMAKE_CONFIGURATION_TYPES) + message(WARNING "CONFIGURATION_TYPES should only be specified for multi-configuration generators") + elseif(ARGUMENTS_CONFIGURATION_TYPES AND ARGUMENTS_BUILD_TYPE) + message(WARNING "CONFIGURATION_TYPES and BUILD_TYPE arguments should not be defined at the same time.") + endif() + + if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE AND NOT CONAN_EXPORTED + AND NOT ARGUMENTS_BUILD_TYPE) + set(CONAN_CMAKE_MULTI ON) + if (NOT ARGUMENTS_CONFIGURATION_TYPES) + set(ARGUMENTS_CONFIGURATION_TYPES "Release;Debug") + endif() + message(STATUS "Conan: Using cmake-multi generator") + else() + set(CONAN_CMAKE_MULTI OFF) + endif() + + if(NOT CONAN_EXPORTED) + conan_cmake_setup_conanfile(${ARGV}) + if(CONAN_CMAKE_MULTI) + foreach(CMAKE_BUILD_TYPE ${ARGUMENTS_CONFIGURATION_TYPES}) + set(ENV{CONAN_IMPORT_PATH} ${CMAKE_BUILD_TYPE}) + conan_cmake_settings(settings ${ARGV}) + old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) + endforeach() + set(CMAKE_BUILD_TYPE) + else() + conan_cmake_settings(settings ${ARGV}) + old_conan_cmake_install(SETTINGS ${settings} ${ARGV}) + endif() + endif() + + if (NOT ARGUMENTS_NO_LOAD) + conan_load_buildinfo() + endif() + + if(ARGUMENTS_BASIC_SETUP) + foreach(_option CMAKE_TARGETS KEEP_RPATHS NO_OUTPUT_DIRS SKIP_STD) + if(ARGUMENTS_${_option}) + if(${_option} STREQUAL "CMAKE_TARGETS") + list(APPEND _setup_options "TARGETS") + else() + list(APPEND _setup_options ${_option}) + endif() + endif() + endforeach() + conan_basic_setup(${_setup_options}) + endif() +endmacro() + +macro(conan_check) + # Checks conan availability in PATH + # Arguments REQUIRED, DETECT_QUIET and VERSION are optional + # Example usage: + # conan_check(VERSION 1.0.0 REQUIRED) + set(options REQUIRED DETECT_QUIET) + set(oneValueArgs VERSION) + cmake_parse_arguments(CONAN "${options}" "${oneValueArgs}" "" ${ARGN}) + if(NOT CONAN_DETECT_QUIET) + message(STATUS "Conan: checking conan executable") + endif() + + find_program(CONAN_CMD conan) + if(NOT CONAN_CMD AND CONAN_REQUIRED) + message(FATAL_ERROR "Conan executable not found! Please install conan.") + endif() + if(NOT CONAN_DETECT_QUIET) + message(STATUS "Conan: Found program ${CONAN_CMD}") + endif() + execute_process(COMMAND ${CONAN_CMD} --version + RESULT_VARIABLE return_code + OUTPUT_VARIABLE CONAN_VERSION_OUTPUT + ERROR_VARIABLE CONAN_VERSION_OUTPUT) + + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan --version failed='${return_code}'") + endif() + + if(NOT CONAN_DETECT_QUIET) + string(STRIP "${CONAN_VERSION_OUTPUT}" _CONAN_VERSION_OUTPUT) + message(STATUS "Conan: Version found ${_CONAN_VERSION_OUTPUT}") + endif() + + if(DEFINED CONAN_VERSION) + string(REGEX MATCH ".*Conan version ([0-9]+\\.[0-9]+\\.[0-9]+)" FOO + "${CONAN_VERSION_OUTPUT}") + if(${CMAKE_MATCH_1} VERSION_LESS ${CONAN_VERSION}) + message(FATAL_ERROR "Conan outdated. Installed: ${CMAKE_MATCH_1}, \ + required: ${CONAN_VERSION}. Consider updating via 'pip \ + install conan==${CONAN_VERSION}'.") + endif() + endif() +endmacro() + +function(conan_add_remote) + # Adds a remote + # Arguments URL and NAME are required, INDEX, COMMAND and VERIFY_SSL are optional + # Example usage: + # conan_add_remote(NAME bincrafters INDEX 1 + # URL https://api.bintray.com/conan/bincrafters/public-conan + # VERIFY_SSL True) + set(oneValueArgs URL NAME INDEX COMMAND VERIFY_SSL) + cmake_parse_arguments(CONAN "" "${oneValueArgs}" "" ${ARGN}) + + if(DEFINED CONAN_INDEX) + set(CONAN_INDEX_ARG "-i ${CONAN_INDEX}") + endif() + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED DETECT_QUIET) + endif() + set(CONAN_VERIFY_SSL_ARG "True") + if(DEFINED CONAN_VERIFY_SSL) + set(CONAN_VERIFY_SSL_ARG ${CONAN_VERIFY_SSL}) + endif() + message(STATUS "Conan: Adding ${CONAN_NAME} remote repository (${CONAN_URL}) verify ssl (${CONAN_VERIFY_SSL_ARG})") + execute_process(COMMAND ${CONAN_CMD} remote add ${CONAN_NAME} ${CONAN_INDEX_ARG} -f ${CONAN_URL} ${CONAN_VERIFY_SSL_ARG} + RESULT_VARIABLE return_code) + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan remote failed='${return_code}'") + endif() +endfunction() + +macro(conan_config_install) + # install a full configuration from a local or remote zip file + # Argument ITEM is required, arguments TYPE, SOURCE, TARGET and VERIFY_SSL are optional + # Example usage: + # conan_config_install(ITEM https://github.com/conan-io/cmake-conan.git + # TYPE git SOURCE source-folder TARGET target-folder VERIFY_SSL false) + set(oneValueArgs ITEM TYPE SOURCE TARGET VERIFY_SSL) + set(multiValueArgs ARGS) + cmake_parse_arguments(CONAN "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(DEFINED CONAN_COMMAND) + set(CONAN_CMD ${CONAN_COMMAND}) + else() + conan_check(REQUIRED) + endif() + + if(DEFINED CONAN_VERIFY_SSL) + set(CONAN_VERIFY_SSL_ARG "--verify-ssl=${CONAN_VERIFY_SSL}") + endif() + + if(DEFINED CONAN_TYPE) + set(CONAN_TYPE_ARG "--type=${CONAN_TYPE}") + endif() + + if(DEFINED CONAN_ARGS) + set(CONAN_ARGS_ARGS "--args=\"${CONAN_ARGS}\"") + endif() + + if(DEFINED CONAN_SOURCE) + set(CONAN_SOURCE_ARGS "--source-folder=${CONAN_SOURCE}") + endif() + + if(DEFINED CONAN_TARGET) + set(CONAN_TARGET_ARGS "--target-folder=${CONAN_TARGET}") + endif() + + set (CONAN_CONFIG_INSTALL_ARGS ${CONAN_VERIFY_SSL_ARG} + ${CONAN_TYPE_ARG} + ${CONAN_ARGS_ARGS} + ${CONAN_SOURCE_ARGS} + ${CONAN_TARGET_ARGS}) + + message(STATUS "Conan: Installing config from ${CONAN_ITEM}") + execute_process(COMMAND ${CONAN_CMD} config install ${CONAN_ITEM} ${CONAN_CONFIG_INSTALL_ARGS} + RESULT_VARIABLE return_code) + if(NOT "${return_code}" STREQUAL "0") + message(FATAL_ERROR "Conan config failed='${return_code}'") + endif() +endmacro() diff --git a/agent/native/building/cmake/elastic_conan_export.cmake b/agent/native/building/cmake/elastic_conan_export.cmake new file mode 100644 index 000000000..6b052a3d2 --- /dev/null +++ b/agent/native/building/cmake/elastic_conan_export.cmake @@ -0,0 +1,43 @@ + +include(CMakeParseArguments) + +function(elastic_conan_export) + set(oneValueArgs PATH REFERENCE PROFILE) + cmake_parse_arguments(_elastic_conan_export "" "${oneValueArgs}" "" ${ARGN} ) + + message(STATUS "conan export path: ${_elastic_conan_export_PATH} ref: ${_elastic_conan_export_REFERENCE} profile: ${_elastic_conan_export_PROFILE}" ) + + execute_process(COMMAND ${CONAN_CMD} export ${_elastic_conan_export_PATH} ${_elastic_conan_export_REFERENCE} ) +endfunction() + +function(elastic_conan_create) + set(oneValueArgs PATH REFERENCE PROFILE) + cmake_parse_arguments(_elastic_conan_create "" "${oneValueArgs}" "" ${ARGN} ) + + execute_process(COMMAND ${CONAN_CMD} search --raw ${_elastic_conan_create_REFERENCE} + RESULT_VARIABLE return_code + OUTPUT_QUIET + ERROR_QUIET + ) + + if ("${return_code}" STREQUAL 0) + message(STATUS "Package ${_elastic_conan_create_REFERENCE} already installed") + return() + endif() + + message(STATUS "${CONAN_CMD} create --build=missing -pr ${_elastic_conan_create_PROFILE} ${_elastic_conan_create_PATH} ${_elastic_conan_create_REFERENCE}" ) + execute_process(COMMAND ${CONAN_CMD} create --build=missing -pr ${_elastic_conan_create_PROFILE} ${_elastic_conan_create_PATH} ${_elastic_conan_create_REFERENCE} + COMMAND_ERROR_IS_FATAL ANY + ) +endfunction() + + +function(elastic_conan_alias) + set(oneValueArgs PATH REFERENCE TARGET) + cmake_parse_arguments(_elastic_conan_alias "" "${oneValueArgs}" "" ${ARGN} ) + + message(STATUS "${CONAN_CMD} alias ${_elastic_conan_alias_REFERENCE} ${_elastic_conan_alias_TARGET}") + execute_process(COMMAND ${CONAN_CMD} alias ${_elastic_conan_alias_REFERENCE} ${_elastic_conan_alias_TARGET} + COMMAND_ERROR_IS_FATAL ANY + ) +endfunction() diff --git a/agent/native/building/cmake/elastic_conan_installer.cmake b/agent/native/building/cmake/elastic_conan_installer.cmake new file mode 100644 index 000000000..7bc9040bc --- /dev/null +++ b/agent/native/building/cmake/elastic_conan_installer.cmake @@ -0,0 +1,106 @@ +include(CMakeParseArguments) + + + +set(python "python3") +set(python_pip "pip3") + +# Detect Alpine/MUSLC build +if(EXISTS /etc/alpine-release) + set(MUSL_BUILD true) +endif() + +message(STATUS "Enabling python virtual environment") + +set(VENV_PATH ${CMAKE_BINARY_DIR}/python_venv) + +if(NOT EXISTS ${VENV_PATH}) + execute_process( + COMMAND ${python} -m venv ${VENV_PATH} + COMMAND_ERROR_IS_FATAL ANY + ) + file(COPY ${CMAKE_SOURCE_DIR}/building/cmake/test_venv.py DESTINATION ${CMAKE_BINARY_DIR}/) + set(_VENV_CREATED TRUE) +endif() + +set(ENV{VIRTUAL_ENV} ${VENV_PATH}) +set(ENV{PATH} $ENV{VIRTUAL_ENV}/bin:$ENV{PATH}) +set(python "${VENV_PATH}/bin/python3") +set(python_pip "${VENV_PATH}/bin/pip3") + +message(STATUS PATH="$ENV{PATH}") + + +# Testing if venv is detected propely by python +execute_process( + COMMAND ${python} ${CMAKE_BINARY_DIR}/test_venv.py + COMMAND_ERROR_IS_FATAL ANY + ) + +set(_PRV_CONAN_PROFILE_OS ${CMAKE_SYSTEM_NAME}) + +if (MUSL_BUILD) + #this is workaround to force build from souce on musl - this will prevent from installing libc binaries + set(_PRV_CONAN_PROFILE_OS_DISTRO "os.distro=Alpine") + set(_PRV_COMPILER_LIBC_IMPLEMENTATION "compiler.libc=musl") +elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(_PRV_CONAN_PROFILE_OS_DISTRO "os.distro=Centos7") + set(_PRV_COMPILER_LIBC_IMPLEMENTATION "compiler.libc=glibc") +endif() + +if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + message(STATUS "Linux ${_PRV_CONAN_PROFILE_OS_DISTRO}, ${_PRV_COMPILER_LIBC_IMPLEMENTATION}") +endif() + +# setting up paths used to configure compiler profile +set(_PRV_CONAN_PROFILE_CC ${CMAKE_C_COMPILER}) +set(_PRV_CONAN_PROFILE_CXX ${CMAKE_CXX_COMPILER}) + +# some recipes doesn't use profile compiler, it is a workaround +if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + list(APPEND CMAKE_PROGRAM_PATH "$ENV{COMPILER_HOME_PATH}/bin/") + set(ENV{PATH} $ENV{COMPILER_HOME_PATH}/bin:$ENV{PATH}) +endif() + +# Prepare conan profile +set(_PRV_COMPILER_NAME gcc) +string(REPLACE "." ";" _PRV_COMPILER_VERSION_TOKENIZED ${CMAKE_CXX_COMPILER_VERSION}) +list(GET _PRV_COMPILER_VERSION_TOKENIZED 0 _PRV_COMPILER_VERSION_MAJOR) +list(GET _PRV_COMPILER_VERSION_TOKENIZED 1 _PRV_COMPILER_VERSION_MINOR) +set(_PRV_COMPILER_VERSION_SHORT "${_PRV_COMPILER_VERSION_MAJOR}.${_PRV_COMPILER_VERSION_MINOR}") +set(_CONAN_PROFILE "${CMAKE_BINARY_DIR}/conan_compiler") + +configure_file("${CMAKE_SOURCE_DIR}/building/conan/conan_profile.in" "${_CONAN_PROFILE}" @ONLY) + + +if(_VENV_CREATED) + # Installing conan and required dependencies + execute_process( + COMMAND ${python_pip} install -U pip + COMMAND_ERROR_IS_FATAL ANY + ) + + execute_process( + COMMAND ${python_pip} install -U wheel + COMMAND_ERROR_IS_FATAL ANY + ) + + execute_process( + COMMAND ${python_pip} install -U conan<2.0 + COMMAND_ERROR_IS_FATAL ANY + ) + +endif() + +message(STATUS "Installing conan configuration from ${CMAKE_SOURCE_DIR}/building/conan/settings.yml") +execute_process( + COMMAND conan config install ${CMAKE_SOURCE_DIR}/building/conan/settings.yml + COMMAND_ERROR_IS_FATAL ANY +) + +message(STATUS "Conan installation done") + +include(conan) +conan_check() + +include(elastic_conan_export) diff --git a/agent/native/building/cmake/elastic_get_git_version.cmake b/agent/native/building/cmake/elastic_get_git_version.cmake new file mode 100644 index 000000000..241b76f1b --- /dev/null +++ b/agent/native/building/cmake/elastic_get_git_version.cmake @@ -0,0 +1,43 @@ + +find_package(Git) + +function(elastic_get_git_version PROJECT_VERSION SIMPLE_VERSION GIT_REVISION_HASH) + #PROJECT_VERSION MAJOR.MINOR.PATCH + #SIMPLE_VERSION MAJOR.MINOR.PATCH-dirty + + block(SCOPE_FOR VARIABLES) + execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --match "v*" --dirty --abbrev=0 + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_VERSION + RESULT_VARIABLE GIT_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(${GIT_RESULT}) + message(FATAL_ERROR "Could not get version from git. Git error code: ${GIT_RESULT}. Output: ${GIT_VERSION}") + endif() + + # strip leading v + string(SUBSTRING ${GIT_VERSION} 1 -1 TMP_SIMPLE_VERSION) + + # remove -dirty if exists + string(REPLACE "-dirty" "" TMP_PROJECT_VERSION ${TMP_SIMPLE_VERSION}) + + execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + OUTPUT_VARIABLE GIT_REVISION + RESULT_VARIABLE GIT_RESULT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + + if(${GIT_RESULT}) + message(FATAL_ERROR "Could not get revision from git. Git error code: ${GIT_RESULT}. Output: ${GIT_REVISION}") + endif() + set(${GIT_REVISION_HASH} ${GIT_REVISION}) + + set(${PROJECT_VERSION} ${TMP_PROJECT_VERSION}) + set(${SIMPLE_VERSION} ${TMP_SIMPLE_VERSION}) + + return(PROPAGATE ${PROJECT_VERSION} ${SIMPLE_VERSION} ${GIT_REVISION_HASH}) + endblock() +endfunction() diff --git a/agent/native/building/cmake/elastic_set_default_build_options.cmake b/agent/native/building/cmake/elastic_set_default_build_options.cmake new file mode 100644 index 000000000..54175cff8 --- /dev/null +++ b/agent/native/building/cmake/elastic_set_default_build_options.cmake @@ -0,0 +1,86 @@ + + +# Constrol switches +set(_ELASTIC_FAIL_ON_ERROR false) +set(_ELASTIC_WARN_ON_UNINITIALIZED true) + + +# determine build type and set +set(MUSL_BUILD false) + +set_property(GLOBAL PROPERTY GLOBAL_DEPENDS_NO_CYCLES ON) # https://cmake.org/cmake/help/latest/prop_gbl/GLOBAL_DEPENDS_NO_CYCLES.html + +# Set the defauts for all targets +set(CMAKE_DISABLE_IN_SOURCE_BUILD ON) # https://github.com/ComputationalRadiationPhysics/picongpu/issues/2109 +set(CMAKE_DISABLE_SOURCE_CHANGES ON) +set(CMAKE_CXX_EXTENSIONS OFF) # https://cmake.org/cmake/help/latest/prop_tgt/CXX_EXTENSIONS.html#prop_tgt:CXX_EXTENSIONS +set(CMAKE_CXX_STANDARD_REQUIRED ON) # https://cmake.org/cmake/help/latest/prop_tgt/CXX_STANDARD_REQUIRED.html#prop_tgt:CXX_STANDARD_REQUIRED +set(CMAKE_CXX_STANDARD 20) +set(CMAKE_INCLUDE_CURRENT_DIR ON) # https://cmake.org/cmake/help/latest/variable/CMAKE_INCLUDE_CURRENT_DIR.html + +set(CMAKE_BUILD_WITH_INSTALL_RPATH ON) # include runtime search path for shared libs + +# set up visibility policy for dynamic linking +set(CMAKE_C_VISIBILITY_PRESET hidden) # https://cmake.org/cmake/help/latest/policy/CMP0063.html#policy:CMP0063 +set(CMAKE_CXX_VISIBILITY_PRESET hidden) + +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # https://cmake.org/cmake/help/latest/variable/CMAKE_POSITION_INDEPENDENT_CODE.html#variable:CMAKE_POSITION_INDEPENDENT_CODE + +# Enabling pthreads - https://cmake.org/cmake/help/v3.2/module/FindThreads.html +set(CMAKE_THREAD_PREFER_PTHREAD ON) +set(THREADS_PREFER_PTHREAD_FLAG ON) +find_package(Threads REQUIRED) + + +# Keep output small as possible and manually control what we want to link with binaries +set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "") +set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "") + +# Workaround to enable globally staticaly linked libgcc and libstdc++ - don't need to be enabled foreach target +# linking with libdl and libpthreads +# Bsymbolic - use our own symbols instead of PHP one - prevent curl issues (https://www.intel.com/content/www/us/en/docs/cpp-compiler/developer-guide-reference/2021-8/bsymbolic-functions.html) +set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libgcc -static-libstdc++ -pthread -ldl -Wl,-Bsymbolic -Wl,--exclude-libs,ALL") +set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++ -pthread") + +add_compile_options("-pipe") # don't use temporary files but pipe data to linker + +# Set up optimizations +if(RELEASE_BUILD) + add_compile_options("-O2" + "-g" + ) + add_definitions("-DNDEBUG") + add_definitions("-D_FORTIFY_SOURCE=2") +elseif(DEBUG_BUILD) + add_compile_options("-O0" + "-g3") +endif() + +add_compile_options("-pthread" + "-fexceptions" # Enable exception handling in C to interoperate properly with exception handlers written in C++ (https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html) + "-fstack-protector-strong" + ) + + +# handling warnings +add_compile_options( + "-Wall" + "-Wextra" + "-Wno-unused-parameter" # annoying when using PHP delivered macros +) + +if(NOT _ELASTIC_WARN_ON_UNINITIALIZED) + add_compile_options("-Wno-maybe-uninitialized") +endif() + +if(_ELASTIC_FAIL_ON_ERROR) + add_compile_options("-Werror") +endif() + +# C++ only switches +add_compile_options("$<$:-Wno-register>") +add_compile_options("$<$:-Wnon-virtual-dtor>") +add_compile_options("$<$:-fdiagnostics-show-template-tree>") # print template mismatch as tree - much more user friendly + +# C only switches +add_compile_options("$<$:-Wstrict-prototypes>") diff --git a/agent/native/building/cmake/test_venv.py b/agent/native/building/cmake/test_venv.py new file mode 100644 index 000000000..756e92c74 --- /dev/null +++ b/agent/native/building/cmake/test_venv.py @@ -0,0 +1,14 @@ +import logging +import os +import sys + +#Detecting venv + +if sys.prefix == sys.base_prefix: + logging.error("venv not detected") + exit(1) +else: + logging.info("Virtual environment detected: " + sys.prefix) + + +exit(0) \ No newline at end of file diff --git a/agent/native/building/conan/conan_profile.in b/agent/native/building/conan/conan_profile.in new file mode 100644 index 000000000..f56637490 --- /dev/null +++ b/agent/native/building/conan/conan_profile.in @@ -0,0 +1,17 @@ + +[settings] +os=@_PRV_CONAN_PROFILE_OS@ +@_PRV_CONAN_PROFILE_OS_DISTRO@ +arch=x86_64 +arch_build=x86_64 +build_type=Release +compiler=@_PRV_COMPILER_NAME@ +compiler.version=@_PRV_COMPILER_VERSION_SHORT@ +compiler.libcxx=libstdc++11 +@_PRV_COMPILER_LIBC_IMPLEMENTATION@ + + +[env] +CC=@_PRV_CONAN_PROFILE_CC@ +CXX=@_PRV_CONAN_PROFILE_CXX@ +LDFLAGS="-static-libgcc -static-libstdc++" diff --git a/agent/native/building/conan/settings.yml b/agent/native/building/conan/settings.yml new file mode 100644 index 000000000..39ca052aa --- /dev/null +++ b/agent/native/building/conan/settings.yml @@ -0,0 +1,154 @@ + +# Only for cross building, 'os_build/arch_build' is the system that runs Conan +os_build: [Windows, WindowsStore, Linux, Macos, FreeBSD, SunOS, AIX, VxWorks] +arch_build: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7] + +# Only for building cross compilation tools, 'os_target/arch_target' is the system for +# which the tools generate code +os_target: [Windows, Linux, Macos, Android, iOS, watchOS, tvOS, FreeBSD, SunOS, AIX, Arduino, Neutrino] +arch_target: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7] + +# Rest of the settings are "host" settings: +# - For native building/cross building: Where the library/program will run. +# - For building cross compilation tools: Where the cross compiler will run. +os: + Windows: + subsystem: [None, cygwin, msys, msys2, wsl] + WindowsStore: + version: ["8.1", "10.0"] + WindowsCE: + platform: ANY + version: ["5.0", "6.0", "7.0", "8.0"] + Linux: + distro: ["Alpine", "Centos7"] + iOS: + version: &ios_version + ["7.0", "7.1", "8.0", "8.1", "8.2", "8.3", "9.0", "9.1", "9.2", "9.3", "10.0", "10.1", "10.2", "10.3", + "11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", + "13.0", "13.1", "13.2", "13.3", "13.4", "13.5", "13.6", "13.7", + "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", "14.8", + "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1"] + sdk: [None, "iphoneos", "iphonesimulator"] + sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", + "13.0", "13.1", "13.2", "13.4", "13.5", "13.6", "13.7", + "14.0", "14.1", "14.2", "14.3", "14.4", "14.5", "15.0", "15.2", "15.4", "15.5", "16.0", "16.1"] + watchOS: + version: ["4.0", "4.1", "4.2", "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2", + "7.0", "7.1", "7.2", "7.3", "7.4", "7.5", "7.6", "8.0", "8.1", "8.3", "8.4", "8.5", "8.6", "8.7", "9.0", "9.1"] + sdk: [None, "watchos", "watchsimulator"] + sdk_version: [None, "4.3", "5.0", "5.1", "5.2", "5.3", "6.0", "6.1", "6.2", + "7.0", "7.1", "7.2", "7.4", "8.0", "8.0.1", "8.3", "8.5", "9.0", "9.1"] + tvOS: + version: ["11.0", "11.1", "11.2", "11.3", "11.4", "12.0", "12.1", "12.2", "12.3", "12.4", + "13.0", "13.2", "13.3", "13.4", "14.0", "14.2", "14.3", "14.4", "14.5", "14.6", "14.7", + "15.0", "15.1", "15.2", "15.3", "15.4", "15.5", "15.6", "16.0", "16.1"] + sdk: [None, "appletvos", "appletvsimulator"] + sdk_version: [None, "11.3", "11.4", "12.0", "12.1", "12.2", "12.4", + "13.0", "13.1", "13.2", "13.4", "14.0", "14.2", "14.3", "14.5", "15.0", "15.2", "15.4", "16.0", "16.1"] + Macos: + version: [None, "10.6", "10.7", "10.8", "10.9", "10.10", "10.11", "10.12", "10.13", "10.14", "10.15", "11.0", "12.0", "13.0"] + sdk: [None, "macosx"] + sdk_version: [None, "10.13", "10.14", "10.15", "11.0", "11.1", "11.3", "12.0", "12.1", "12.3", "13.0"] + subsystem: + None: + catalyst: + ios_version: *ios_version + Android: + api_level: ANY + FreeBSD: + SunOS: + AIX: + Arduino: + board: ANY + Emscripten: + Neutrino: + version: ["6.4", "6.5", "6.6", "7.0", "7.1"] + baremetal: + VxWorks: + version: ["7"] +arch: [x86, x86_64, ppc32be, ppc32, ppc64le, ppc64, armv4, armv4i, armv5el, armv5hf, armv6, armv7, armv7hf, armv7s, armv7k, armv8, armv8_32, armv8.3, sparc, sparcv9, mips, mips64, avr, s390, s390x, asm.js, wasm, sh4le, e2k-v2, e2k-v3, e2k-v4, e2k-v5, e2k-v6, e2k-v7, xtensalx6, xtensalx106, xtensalx7] +compiler: + sun-cc: + version: ["5.10", "5.11", "5.12", "5.13", "5.14", "5.15"] + threads: [None, posix] + libcxx: [libCstd, libstdcxx, libstlport, libstdc++] + gcc: &gcc + version: ["4.1", "4.4", "4.5", "4.6", "4.7", "4.8", "4.9", + "5", "5.1", "5.2", "5.3", "5.4", "5.5", + "6", "6.1", "6.2", "6.3", "6.4", "6.5", + "7", "7.1", "7.2", "7.3", "7.4", "7.5", + "8", "8.1", "8.2", "8.3", "8.4", "8.5", + "9", "9.1", "9.2", "9.3", "9.4", "9.5", + "10", "10.1", "10.2", "10.3", "10.4", + "11", "11.1", "11.2", "11.3", + "12", "12.1", "12.2"] + libcxx: [libstdc++, libstdc++11] + threads: [None, posix, win32] # Windows MinGW + exception: [None, dwarf2, sjlj, seh] # Windows MinGW + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + libc: [glibc, musl] + Visual Studio: &visual_studio + runtime: [MD, MT, MTd, MDd] + version: ["8", "9", "10", "11", "12", "14", "15", "16", "17"] + toolset: [None, v90, v100, v110, v110_xp, v120, v120_xp, + v140, v140_xp, v140_clang_c2, LLVM-vs2012, LLVM-vs2012_xp, + LLVM-vs2013, LLVM-vs2013_xp, LLVM-vs2014, LLVM-vs2014_xp, + LLVM-vs2017, LLVM-vs2017_xp, v141, v141_xp, v141_clang_c2, v142, + llvm, ClangCL, v143] + cppstd: [None, 14, 17, 20, 23] + msvc: + version: [170, 180, 190, 191, 192, 193] + update: [None, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9] + runtime: [static, dynamic] + runtime_type: [Debug, Release] + cppstd: [98, 14, 17, 20, 23] + toolset: [None, v110_xp, v120_xp, v140_xp, v141_xp] + clang: + version: ["3.3", "3.4", "3.5", "3.6", "3.7", "3.8", "3.9", "4.0", + "5.0", "6.0", "7.0", "7.1", + "8", "9", "10", "11", "12", "13", "14", "15", "16"] + libcxx: [None, libstdc++, libstdc++11, libc++, c++_shared, c++_static] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + runtime: [None, MD, MT, MTd, MDd, static, dynamic] + runtime_type: [None, Debug, Release] + runtime_version: [None, v140, v141, v142, v143] + apple-clang: &apple_clang + version: ["5.0", "5.1", "6.0", "6.1", "7.0", "7.3", "8.0", "8.1", "9.0", "9.1", "10.0", "11.0", "12.0", "13", "13.0", "13.1", "14", "14.0"] + libcxx: [libstdc++, libc++] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + intel: + version: ["11", "12", "13", "14", "15", "16", "17", "18", "19", "19.1"] + update: [None, ANY] + base: + gcc: + <<: *gcc + threads: [None] + exception: [None] + Visual Studio: + <<: *visual_studio + apple-clang: + <<: *apple_clang + intel-cc: + version: ["2021.1", "2021.2", "2021.3"] + update: [None, ANY] + mode: ["icx", "classic", "dpcpp"] + libcxx: [None, libstdc++, libstdc++11, libc++] + cppstd: [None, 98, gnu98, 03, gnu03, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] + runtime: [None, static, dynamic] + runtime_type: [None, Debug, Release] + qcc: + version: ["4.4", "5.4", "8.3"] + libcxx: [cxx, gpp, cpp, cpp-ne, accp, acpp-ne, ecpp, ecpp-ne] + cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17] + mcst-lcc: + version: ["1.19", "1.20", "1.21", "1.22", "1.23", "1.24", "1.25"] + base: + gcc: + <<: *gcc + threads: [None] + exceptions: [None] + +build_type: [None, Debug, Release, RelWithDebInfo, MinSizeRel] + + +cppstd: [None, 98, gnu98, 11, gnu11, 14, gnu14, 17, gnu17, 20, gnu20, 23, gnu23] # Deprecated, use compiler.cppstd diff --git a/agent/native/building/dependencies/php72/conandata.yml b/agent/native/building/dependencies/php72/conandata.yml new file mode 100644 index 000000000..2491593ed --- /dev/null +++ b/agent/native/building/dependencies/php72/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-72" +version: "1.0" +php_source_version: 7.2.34 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php72/conanfile.py b/agent/native/building/dependencies/php72/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php72/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/php73/conandata.yml b/agent/native/building/dependencies/php73/conandata.yml new file mode 100644 index 000000000..29d9ff604 --- /dev/null +++ b/agent/native/building/dependencies/php73/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-73" +version: "1.0" +php_source_version: 7.3.33 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php73/conanfile.py b/agent/native/building/dependencies/php73/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php73/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/php74/conandata.yml b/agent/native/building/dependencies/php74/conandata.yml new file mode 100644 index 000000000..5f6d12cda --- /dev/null +++ b/agent/native/building/dependencies/php74/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-74" +version: "1.0" +php_source_version: 7.4.33 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php74/conanfile.py b/agent/native/building/dependencies/php74/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php74/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/php80/conandata.yml b/agent/native/building/dependencies/php80/conandata.yml new file mode 100644 index 000000000..6523273c4 --- /dev/null +++ b/agent/native/building/dependencies/php80/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-80" +version: "1.0" +php_source_version: 8.0.28 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php80/conanfile.py b/agent/native/building/dependencies/php80/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php80/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/php81/conandata.yml b/agent/native/building/dependencies/php81/conandata.yml new file mode 100644 index 000000000..5a870624a --- /dev/null +++ b/agent/native/building/dependencies/php81/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-81" +version: "1.0" +php_source_version: 8.1.18 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php81/conanfile.py b/agent/native/building/dependencies/php81/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php81/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/php82/conandata.yml b/agent/native/building/dependencies/php82/conandata.yml new file mode 100644 index 000000000..918b135dc --- /dev/null +++ b/agent/native/building/dependencies/php82/conandata.yml @@ -0,0 +1,29 @@ +name: "php-headers-82" +version: "1.0" +php_source_version: 8.2.5 + +sources: + 7.2.34: + linux: + - url: "https://www.php.net/distributions/php-7.2.34.tar.gz" + contentsRoot: "php-7.2.34" + 7.3.33: + linux: + - url: "https://www.php.net/distributions/php-7.3.33.tar.gz" + contentsRoot: "php-7.3.33" + 7.4.33: + linux: + - url: "https://www.php.net/distributions/php-7.4.33.tar.gz" + contentsRoot: "php-7.4.33" + 8.0.28: + linux: + - url: "https://www.php.net/distributions/php-8.0.28.tar.gz" + contentsRoot: "php-8.0.28" + 8.1.18: + linux: + - url: "https://www.php.net/distributions/php-8.1.18.tar.gz" + contentsRoot: "php-8.1.18" + 8.2.5: + linux: + - url: "https://www.php.net/distributions/php-8.2.5.tar.gz" + contentsRoot: "php-8.2.5" diff --git a/agent/native/building/dependencies/php82/conanfile.py b/agent/native/building/dependencies/php82/conanfile.py new file mode 100644 index 000000000..2f1ec5fcc --- /dev/null +++ b/agent/native/building/dependencies/php82/conanfile.py @@ -0,0 +1,56 @@ +import os +import shutil + +from conans import tools, ConanFile, AutoToolsBuildEnvironment + +class PhpHeadersForPHP81Conan(ConanFile): + description = "PHP headers package required to build Elastic APM agent without additional PHP dependencies" + license = "The PHP License, version 3.01" + homepage = "https://php.net/" + url = "https://php.net/" + author = "pawel.filipczak@elastic.co" + + settings = "os", "compiler", "build_type", "arch" + platform = "linux" + + def init(self): + self.name = self.conan_data["name"] + self.version = self.conan_data["version"] # version of the package + self.php_version = self.conan_data["php_source_version"] # version of the PHP to build + self.source_temp_dir = "php-src" + + def requirements(self): + self.requires("libxml2/2.9.9") + self.requires("sqlite3/3.29.0") + + def source(self): + for source in self.conan_data["sources"][self.php_version][self.platform]: + + if "contentsRoot" in source: + # small hack - it can't contain custom fields, so we're removing it from source (got an unexpected keyword argument) + contentRoot = source["contentsRoot"] + del source["contentsRoot"] + tools.get(**source) + os.rename(contentRoot, self.source_temp_dir) + else: + self.output.error("Could not find 'contentsRoot' in conandata.yml") + raise Exception("Could not find 'contentsRoot' in conandata.yml") + + def build(self): + with tools.chdir(os.path.join(self.source_folder, self.source_temp_dir)): + buildEnv = AutoToolsBuildEnvironment(self) + envVariables = buildEnv.vars + envVariables['ac_cv_php_xml2_config_path'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, "bin/xml2-config") + envVariables['LIBXML_LIBS'] = os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].libdirs[0]) + envVariables['LIBXML_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["libxml2"].rootpath, self.deps_cpp_info["libxml2"].includedirs[0])) + envVariables['SQLITE_LIBS'] = os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].libdirs[0]) + envVariables['SQLITE_CFLAGS'] = "-I{}".format(os.path.join(self.deps_cpp_info["sqlite3"].rootpath, self.deps_cpp_info["sqlite3"].includedirs[0])) + self.run("./buildconf --force") + buildEnv.configure(args=[""], vars=envVariables, build=False, host=False) + + def package(self): + source = os.path.join(self.source_folder, self.source_temp_dir) + self.copy("*.h", src=source, dst='include', keep_path=True) + + def package_id(self): + del self.info.settings.compiler.version diff --git a/agent/native/building/dependencies/pkgconf/conandata.yml b/agent/native/building/dependencies/pkgconf/conandata.yml new file mode 100644 index 000000000..5a2974ff2 --- /dev/null +++ b/agent/native/building/dependencies/pkgconf/conandata.yml @@ -0,0 +1,8 @@ +version: "1.9.3" +patches: + 1.9.3: + - patch_file: patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch +sources: + 1.9.3: + sha256: e8b637c0dd8ae1decbcc95b24b64795cba81a8e3064fddb4424cacef411e59f9 + url: https://github.com/pkgconf/pkgconf/archive/refs/tags/pkgconf-1.9.3.tar.gz diff --git a/agent/native/building/dependencies/pkgconf/conanfile.py b/agent/native/building/dependencies/pkgconf/conanfile.py new file mode 100644 index 000000000..7edfbe65c --- /dev/null +++ b/agent/native/building/dependencies/pkgconf/conanfile.py @@ -0,0 +1,152 @@ +import os + +from conan import ConanFile +from conan.tools.env import VirtualBuildEnv +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, rename, rm, rmdir, replace_in_file +from conan.tools.layout import basic_layout +from conan.tools.meson import Meson, MesonToolchain +from conan.tools.microsoft import is_msvc, unix_path_package_info_legacy +from conan.tools.scm import Version +from conan.errors import ConanInvalidConfiguration + + +required_conan_version = ">=1.57.0" + + +class PkgConfConan(ConanFile): + name = "pkgconf" + url = "https://github.com/conan-io/conan-center-index" + topics = ("build", "configuration") + homepage = "https://git.sr.ht/~kaniini/pkgconf" + license = "ISC" + description = "package compiler and linker metadata toolkit" + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_lib": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_lib": False, + } + + def init(self): + self.version = self.conan_data["version"] # version of the package + + def layout(self): + basic_layout(self, src_folder="src") + + def export_sources(self): + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if not self.options.enable_lib: + self.options.rm_safe("fPIC") + self.options.rm_safe("shared") + elif self.options.shared: + self.options.rm_safe("fPIC") + + self.settings.rm_safe("compiler.libcxx") + self.settings.rm_safe("compiler.cppstd") + + def build_requirements(self): + self.tool_requires("meson/1.0.0") + + def source(self): + get(self, **self.conan_data["sources"][self.version], destination=self.source_folder, strip_root=True) + + def _patch_sources(self): + apply_conandata_patches(self) + + if not self.options.get_safe("shared", False): + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + "'-DLIBPKGCONF_EXPORT'", + "'-DPKGCONFIG_IS_STATIC'") + replace_in_file(self, os.path.join(self.source_folder, "meson.build"), + "project('pkgconf', 'c',", + "project('pkgconf', 'c',\ndefault_options : ['c_std=gnu99'],") + + def generate(self): + env = VirtualBuildEnv(self) + env.generate() + + tc = MesonToolchain(self) + tc.project_options["tests"] = False + if not self.options.enable_lib: + tc.project_options["default_library"] = "static" + tc.generate() + + def build(self): + self._patch_sources() + meson = Meson(self) + meson.configure() + meson.build() + + def package(self): + copy(self, "COPYING", src=self.source_folder, dst=os.path.join(self.package_folder,"licenses")) + + meson = Meson(self) + meson.install() + + if is_msvc(self): + rm(self, "*.pdb", os.path.join(self.package_folder, "bin")) + if self.options.enable_lib and not self.options.shared: + rename(self, os.path.join(self.package_folder, "lib", "libpkgconf.a"), + os.path.join(self.package_folder, "lib", "pkgconf.lib"),) + + if not self.options.enable_lib: + rmdir(self, os.path.join(self.package_folder, "lib")) + rmdir(self, os.path.join(self.package_folder, "include")) + + + rmdir(self, os.path.join(self.package_folder, "share", "man")) + rename(self, os.path.join(self.package_folder, "share", "aclocal"), + os.path.join(self.package_folder, "bin", "aclocal")) + rmdir(self, os.path.join(self.package_folder, "share")) + rmdir(self, os.path.join(self.package_folder, "lib", "pkgconfig")) + + def package_id(self): + if not self.info.options.enable_lib: + del self.info.settings.compiler + + def package_info(self): + if self.options.enable_lib: + self.cpp_info.set_property("pkg_config_name", "libpkgconf") + if Version(self.version) >= "1.7.4": + self.cpp_info.includedirs.append(os.path.join("include", "pkgconf")) + self.cpp_info.libs = ["pkgconf"] + if not self.options.shared: + self.cpp_info.defines = ["PKGCONFIG_IS_STATIC"] + else: + self.cpp_info.includedirs = [] + self.cpp_info.libdirs = [] + + bindir = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var: {}".format(bindir)) + self.env_info.PATH.append(bindir) + + exesuffix = ".exe" if self.settings.os == "Windows" else "" + pkg_config = os.path.join(bindir, "pkgconf" + exesuffix).replace("\\", "/") + self.output.info("Setting PKG_CONFIG env var: {}".format(pkg_config)) + self.buildenv_info.define_path("PKG_CONFIG", pkg_config) + + pkgconf_aclocal = os.path.join(self.package_folder, "bin", "aclocal") + self.buildenv_info.prepend_path("ACLOCAL_PATH", pkgconf_aclocal) + # TODO: evaluate if `ACLOCAL_PATH` is enough and we can stop using `AUTOMAKE_CONAN_INCLUDES` + self.buildenv_info.prepend_path("AUTOMAKE_CONAN_INCLUDES", pkgconf_aclocal) + + # TODO: remove in conanv2 + automake_extra_includes = unix_path_package_info_legacy(self, pkgconf_aclocal.replace("\\", "/")) + self.output.info("Appending AUTOMAKE_CONAN_INCLUDES env var: {}".format(automake_extra_includes)) + self.env_info.PKG_CONFIG = pkg_config + self.env_info.AUTOMAKE_CONAN_INCLUDES.append(automake_extra_includes) + + # TODO: to remove in conan v2 once pkg_config generator removed + if self.options.enable_lib: + self.cpp_info.names["pkg_config"] = "libpkgconf" diff --git a/agent/native/building/dependencies/pkgconf/patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch b/agent/native/building/dependencies/pkgconf/patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch new file mode 100644 index 000000000..8c6738a23 --- /dev/null +++ b/agent/native/building/dependencies/pkgconf/patches/1.9.3-0003-PKG_CONF_PATH-allow-colon+semicolon-separator.patch @@ -0,0 +1,11 @@ +--- libpkgconf/path.c ++++ libpkgconf/path.c +@@ -138,7 +138,7 @@ + return 0; + + iter = workbuf = strdup(text); +- while ((p = strtok(iter, PKG_CONFIG_PATH_SEP_S)) != NULL) ++ while ((p = strtok(iter, ":;")) != NULL) + { + pkgconf_path_add(p, dirlist, filter); + diff --git a/agent/native/building/dockerized/docker-compose.yml b/agent/native/building/dockerized/docker-compose.yml new file mode 100644 index 000000000..a95f80687 --- /dev/null +++ b/agent/native/building/dockerized/docker-compose.yml @@ -0,0 +1,19 @@ +version: "2.1" +services: + build_apm_php: + build: + context: . + dockerfile: images/Dockerfile_glibc + image: elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linux-x86-64-0.0.2 + volumes: + - ../../../../:/source + command: sh -c "cd /source/agent/native && cmake --preset linux-x86-64-release && cmake --build --preset linux-x86-64-release" + + build_apm_php_musl: + build: + context: . + dockerfile: images/Dockerfile_musl + image: elasticobservability/apm-agent-php-dev:native-build-gcc-12.2.0-linuxmusl-x86-64-0.0.2 + volumes: + - ../../../../:/source + command: sh -c "cd /source/agent/native && cmake --preset linuxmusl-x86-64-release && cmake --build --preset linuxmusl-x86-64-release" diff --git a/agent/native/building/dockerized/images/Dockerfile_glibc b/agent/native/building/dockerized/images/Dockerfile_glibc new file mode 100644 index 000000000..b640bea0d --- /dev/null +++ b/agent/native/building/dockerized/images/Dockerfile_glibc @@ -0,0 +1,102 @@ +FROM centos:7 as devtools + +ARG GCC_VERSION=12.2.0 +ARG BINUTILS_VERSION=2.40 +ARG CMAKE_VERSION=3.26.3 +ARG PYTHON_VERSION=3.9.16 +ARG USER_NAME=build + +#binutils: bison - gprofng, texinfo - makeinfo + +RUN yum -y update && yum -y install centos-release-scl +RUN yum -y install sudo curl wget git make autoconf bzip2 \ + texinfo bison \ + python3 python3-pip python3-venv \ + devtoolset-7-binutils devtoolset-7-gcc devtoolset-7-gcc-c++ zlib-devel + +RUN adduser -p password ${USER_NAME} \ + && passwd -d ${USER_NAME} \ + && echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER ${USER_NAME} + +RUN mkdir -p /home/${USER_NAME}/prerequisities +WORKDIR /home/${USER_NAME}/prerequisities + +RUN curl -LO https://gcc.gnu.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz \ + && tar -xf gcc-${GCC_VERSION}.tar.xz \ + && rm gcc-${GCC_VERSION}.tar.xz + +RUN source scl_source enable devtoolset-7 \ + && cd gcc-${GCC_VERSION} \ + && ./contrib/download_prerequisites \ + && SHARED_CONFIGURE_OPTIONS="--enable-languages=c,c++ --enable-shared --enable-linker-build-id --with-system-zlib --without-included-gettext --enable-threads=posix --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --disable-werror --enable-checking=release --with-pic --disable-symvers --enable-obsolete" \ + && SHARED_CONFIGURE_OPTIONS="$SHARED_CONFIGURE_OPTIONS --disable-libstdcxx-visibility" \ + && CONFIGURE_OPTIONS="$SHARED_CONFIGURE_OPTIONS --with-tune=generic --enable-libstdcxx-debug-flags=-gdwarf-2" \ + && CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu --disable-multilib" \ + && echo $CONFIGURE_OPTIONS \ + && ./configure --prefix=/opt/gcc-${GCC_VERSION} $CONFIGURE_OPTIONS \ + && make -j$(nproc) \ + && sudo make install \ + && cd - \ + && rm -rf gcc-${GCC_VERSION} + +RUN curl -LO https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz \ + && tar -xf binutils-${BINUTILS_VERSION}.tar.xz \ + && rm binutils-${BINUTILS_VERSION}.tar.xz + +RUN source scl_source enable devtoolset-7 \ + && cd binutils-${BINUTILS_VERSION} \ + && ./configure --prefix=/opt/binutils-${BINUTILS_VERSION} CFLAGS=-Wno-unused-value --enable-gold \ + && make -j$(nproc) \ + && sudo make install \ + && cd - \ + && rm -rf binutils-${BINUTILS_VERSION} + +RUN curl -OL https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-linux-x86_64.sh \ + && chmod +x cmake-${CMAKE_VERSION}-linux-x86_64.sh \ + && sudo mkdir -p /opt/cmake-${CMAKE_VERSION} \ + && sudo ./cmake-${CMAKE_VERSION}-linux-x86_64.sh --skip-license --prefix=/opt/cmake-${CMAKE_VERSION} \ + && rm cmake-${CMAKE_VERSION}-linux-x86_64.sh + +RUN curl -LO https://www.python.org/ftp/python/${PYTHON_VERSION}/Python-${PYTHON_VERSION}.tgz \ + && tar -xf Python-${PYTHON_VERSION}.tgz \ + && rm Python-${PYTHON_VERSION}.tgz + +RUN sudo yum -y install libffi-devel openssl-devel sqlite-devel readline-devel xz-devel bzip2-devel + +RUN source scl_source enable devtoolset-7 \ + && cd Python-${PYTHON_VERSION} \ + && ./configure --help \ + && ./configure --enable-optimizations --prefix=/opt/python-${PYTHON_VERSION} \ + && make \ + && sudo make install + + +RUN sudo yum -y remove devtoolset-7* centos-release-scl \ + && sudo yum -y clean all + + +FROM centos:7 + +ARG GCC_VERSION=12.2.0 +ARG BINUTILS_VERSION=2.40 +ARG CMAKE_VERSION=3.26.3 +ARG PYTHON_VERSION=3.9.16 +ARG USER_NAME=build + +COPY --from=devtools /opt /opt + +RUN yum -y update && yum -y install sudo curl wget git make autoconf bzip2 \ + perl-Thread-Queue perl-IPC-Cmd perl-Digest-SHA \ + file \ + glibc-devel + +RUN adduser -p password ${USER_NAME} \ + && passwd -d ${USER_NAME} \ + && echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER ${USER_NAME} + +ENV PATH="/opt/binutils-${BINUTILS_VERSION}/bin:/opt/cmake-${CMAKE_VERSION}/bin:/opt/python-${PYTHON_VERSION}/bin:${PATH}" +ENV CMAKE_INSTALL_PREFIX=/opt/cmake-${CMAKE_VERSION} diff --git a/agent/native/building/dockerized/images/Dockerfile_musl b/agent/native/building/dockerized/images/Dockerfile_musl new file mode 100644 index 000000000..e8c132545 --- /dev/null +++ b/agent/native/building/dockerized/images/Dockerfile_musl @@ -0,0 +1,85 @@ +FROM alpine:3.10 as devtools_alpine + +ARG GCC_VERSION=12.2.0 +ARG BINUTILS_VERSION=2.40 +ARG CMAKE_VERSION=3.26.3 +ARG USER_NAME=build + +#binutils: bison - gprofng, texinfo - makeinfo + +RUN apk update \ + && apk add sudo curl wget git make autoconf bzip2 \ + texinfo bison \ + binutils gcc g++ zlib-dev gettext-dev linux-headers + +RUN adduser --disabled-password --gecos '' ${USER_NAME} \ + && echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER ${USER_NAME} + +RUN mkdir -p /home/${USER_NAME}/prerequisities +WORKDIR /home/${USER_NAME}/prerequisities + +RUN curl -LO https://gcc.gnu.org/pub/gcc/releases/gcc-${GCC_VERSION}/gcc-${GCC_VERSION}.tar.xz \ + && tar -xf gcc-${GCC_VERSION}.tar.xz \ + && rm gcc-${GCC_VERSION}.tar.xz + + +RUN cd gcc-${GCC_VERSION} \ + && ./contrib/download_prerequisites \ + && SHARED_CONFIGURE_OPTIONS="--enable-languages=c,c++ --enable-shared --enable-linker-build-id --with-system-zlib --without-included-gettext --enable-threads=posix --enable-nls --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --disable-werror --enable-checking=release --with-pic --disable-symvers --enable-obsolete" \ + && SHARED_CONFIGURE_OPTIONS="$SHARED_CONFIGURE_OPTIONS --disable-libstdcxx-visibility" \ + && CONFIGURE_OPTIONS="$SHARED_CONFIGURE_OPTIONS --with-tune=generic --enable-libstdcxx-debug-flags=-gdwarf-2" \ + && CONFIGURE_OPTIONS="$CONFIGURE_OPTIONS --build=x86_64-linux-musl --host=x86_64-linux-musl --target=x86_64-linux-musl --disable-multilib --disable-libsanitizer" \ + && echo $CONFIGURE_OPTIONS \ + && ./configure --prefix=/opt/gcc-${GCC_VERSION} $CONFIGURE_OPTIONS \ + && make -j$(nproc) \ + && sudo make install \ + && cd - \ + && rm -rf gcc-${GCC_VERSION} + +RUN curl -LO https://ftp.gnu.org/gnu/binutils/binutils-${BINUTILS_VERSION}.tar.xz \ + && tar -xf binutils-${BINUTILS_VERSION}.tar.xz \ + && rm binutils-${BINUTILS_VERSION}.tar.xz + +RUN cd binutils-${BINUTILS_VERSION} \ + && ./configure --help \ + && ./configure --prefix=/opt/binutils-${BINUTILS_VERSION} --enable-gold --build=x86_64-linux-musl --host=x86_64-linux-musl --target=x86_64-linux-musl --enable-shared --disable-multilib --with-system-zlib --enable-install-libiberty --disable-gprofng --enable-ld=default --enable-64-bit-bfd --enable-relro --enable-deterministic-archives --enable-default-execstack=no --enable-default-hash-style=gnu --with-pic --disable-werror --disable-nls --with-mmap \ + + && make -j$(nproc) \ + && sudo make install \ + && cd - \ + && rm -rf binutils-${BINUTILS_VERSION} + +RUN curl -LO https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}.tar.gz \ + && tar -xf cmake-${CMAKE_VERSION}.tar.gz \ + && rm cmake-${CMAKE_VERSION}.tar.gz + +RUN sudo apk add curl-dev + +RUN cd cmake-${CMAKE_VERSION} \ + && ./bootstrap --prefix=/opt/cmake-${CMAKE_VERSION} --parallel="${nproc:-2}"\ + && make -j$(nproc)\ + && sudo make install + +FROM alpine:3.10 + +COPY --from=devtools_alpine /opt /opt + +ARG GCC_VERSION=12.2.0 +ARG BINUTILS_VERSION=2.40 +ARG CMAKE_VERSION=3.26.3 +ARG USER_NAME=build + +RUN apk add --no-cache sudo curl wget git make autoconf bzip2 \ + libstdc++ libintl icu musl-dev curl-dev linux-headers \ + python3 py3-pip py3-virtualenv bash + +RUN adduser --disabled-password --gecos '' ${USER_NAME} \ + && echo "${USER_NAME} ALL=(ALL) NOPASSWD:ALL" >>/etc/sudoers + +USER ${USER_NAME} + +ENV PATH="/opt/binutils-${BINUTILS_VERSION}/bin:/opt/cmake-${CMAKE_VERSION}/bin:${PATH}" +ENV CMAKE_INSTALL_PREFIX=/opt/cmake-${CMAKE_VERSION} + diff --git a/src/ext/.gitignore b/agent/native/ext/.gitignore similarity index 100% rename from src/ext/.gitignore rename to agent/native/ext/.gitignore diff --git a/src/ext/AST_debug.c b/agent/native/ext/AST_debug.c similarity index 100% rename from src/ext/AST_debug.c rename to agent/native/ext/AST_debug.c diff --git a/src/ext/AST_debug.h b/agent/native/ext/AST_debug.h similarity index 100% rename from src/ext/AST_debug.h rename to agent/native/ext/AST_debug.h diff --git a/src/ext/AST_instrumentation.c b/agent/native/ext/AST_instrumentation.c similarity index 100% rename from src/ext/AST_instrumentation.c rename to agent/native/ext/AST_instrumentation.c diff --git a/src/ext/AST_instrumentation.h b/agent/native/ext/AST_instrumentation.h similarity index 100% rename from src/ext/AST_instrumentation.h rename to agent/native/ext/AST_instrumentation.h diff --git a/src/ext/AST_util.h b/agent/native/ext/AST_util.h similarity index 100% rename from src/ext/AST_util.h rename to agent/native/ext/AST_util.h diff --git a/src/ext/ArrayView.h b/agent/native/ext/ArrayView.h similarity index 100% rename from src/ext/ArrayView.h rename to agent/native/ext/ArrayView.h diff --git a/agent/native/ext/CMakeLists.txt b/agent/native/ext/CMakeLists.txt new file mode 100644 index 000000000..ad36ca225 --- /dev/null +++ b/agent/native/ext/CMakeLists.txt @@ -0,0 +1,73 @@ + +#scan for source files +AUX_SOURCE_DIRECTORY(. SrcFiles) + +function(copy_debug_symbols target) + block(SCOPE_FOR VARIABLES) + get_target_property(_TargetType ${target} TYPE) + + add_custom_command(TARGET ${target} + POST_BUILD + COMMAND + ${CMAKE_OBJCOPY} "--only-keep-debug" "$" "$/$" + + COMMAND + ${CMAKE_OBJCOPY} + "--add-gnu-debuglink=$/$" + "--strip-debug" "--strip-unneeded" + "$" + COMMENT "Striped debug symbols from ${target}" + ) + + endblock() +endfunction() + + +foreach(_php_version ${_supported_php_versions}) + set (_Target elasticapm_${_php_version}) + + add_library (${_Target} + SHARED ${SrcFiles} + ) + + target_compile_definitions(${_Target} + PRIVATE + "PHP_ATOM_INC" + "PHP_ABI=${CMAKE_C_COMPILER_ABI}") + + target_include_directories(${_Target} PUBLIC "${CONAN_INCLUDE_DIRS_PHP-HEADERS-${_php_version}}" + "${CONAN_INCLUDE_DIRS_PHP-HEADERS-${_php_version}}/ext" + "${CONAN_INCLUDE_DIRS_PHP-HEADERS-${_php_version}}/main" + "${CONAN_INCLUDE_DIRS_PHP-HEADERS-${_php_version}}/TSRM" + "${CONAN_INCLUDE_DIRS_PHP-HEADERS-${_php_version}}/Zend" + "${CONAN_INCLUDE_DIRS_LIBCURL}" + "${CONAN_INCLUDE_DIRS_LIBUNWIND}" + + ) + + target_link_libraries(${_Target} + PRIVATE CONAN_PKG::libcurl + PRIVATE CONAN_PKG::libunwind + ) + + get_php_api_from_release(${_php_version} _ZEND_API_version) + + set_target_properties(${_Target} + PROPERTIES OUTPUT_NAME elastic_apm-${_ZEND_API_version} + PREFIX "" + ) + + set_target_properties(${_Target} + PROPERTIES OUTPUT_NAME elastic_apm-${_ZEND_API_version} + PREFIX "" + DEBUG_SYMBOL_FILE "elastic_apm-${_ZEND_API_version}.debug" + ) + + if (RELEASE_BUILD) + copy_debug_symbols(${_Target}) + endif() + +endforeach() + + +add_subdirectory(unit_tests) \ No newline at end of file diff --git a/src/ext/ConfigManager.c b/agent/native/ext/ConfigManager.c similarity index 100% rename from src/ext/ConfigManager.c rename to agent/native/ext/ConfigManager.c diff --git a/src/ext/ConfigManager.h b/agent/native/ext/ConfigManager.h similarity index 100% rename from src/ext/ConfigManager.h rename to agent/native/ext/ConfigManager.h diff --git a/src/ext/ConfigSnapshot.h b/agent/native/ext/ConfigSnapshot.h similarity index 100% rename from src/ext/ConfigSnapshot.h rename to agent/native/ext/ConfigSnapshot.h diff --git a/src/ext/ConfigSnapshot_forward_decl.h b/agent/native/ext/ConfigSnapshot_forward_decl.h similarity index 100% rename from src/ext/ConfigSnapshot_forward_decl.h rename to agent/native/ext/ConfigSnapshot_forward_decl.h diff --git a/src/ext/IntrusiveDoublyLinkedList.h b/agent/native/ext/IntrusiveDoublyLinkedList.h similarity index 100% rename from src/ext/IntrusiveDoublyLinkedList.h rename to agent/native/ext/IntrusiveDoublyLinkedList.h diff --git a/src/ext/LogLevel.h b/agent/native/ext/LogLevel.h similarity index 100% rename from src/ext/LogLevel.h rename to agent/native/ext/LogLevel.h diff --git a/src/ext/MemoryTracker.c b/agent/native/ext/MemoryTracker.c similarity index 100% rename from src/ext/MemoryTracker.c rename to agent/native/ext/MemoryTracker.c diff --git a/src/ext/MemoryTracker.h b/agent/native/ext/MemoryTracker.h similarity index 100% rename from src/ext/MemoryTracker.h rename to agent/native/ext/MemoryTracker.h diff --git a/src/ext/OptionalBool.h b/agent/native/ext/OptionalBool.h similarity index 100% rename from src/ext/OptionalBool.h rename to agent/native/ext/OptionalBool.h diff --git a/src/ext/ResultCode.c b/agent/native/ext/ResultCode.c similarity index 100% rename from src/ext/ResultCode.c rename to agent/native/ext/ResultCode.c diff --git a/src/ext/ResultCode.h b/agent/native/ext/ResultCode.h similarity index 100% rename from src/ext/ResultCode.h rename to agent/native/ext/ResultCode.h diff --git a/src/ext/StringView.h b/agent/native/ext/StringView.h similarity index 100% rename from src/ext/StringView.h rename to agent/native/ext/StringView.h diff --git a/src/ext/SystemMetrics.c b/agent/native/ext/SystemMetrics.c similarity index 100% rename from src/ext/SystemMetrics.c rename to agent/native/ext/SystemMetrics.c diff --git a/src/ext/SystemMetrics.h b/agent/native/ext/SystemMetrics.h similarity index 100% rename from src/ext/SystemMetrics.h rename to agent/native/ext/SystemMetrics.h diff --git a/src/ext/TextOutputStream.c b/agent/native/ext/TextOutputStream.c similarity index 100% rename from src/ext/TextOutputStream.c rename to agent/native/ext/TextOutputStream.c diff --git a/src/ext/TextOutputStream.h b/agent/native/ext/TextOutputStream.h similarity index 100% rename from src/ext/TextOutputStream.h rename to agent/native/ext/TextOutputStream.h diff --git a/src/ext/TextOutputStream_forward_decl.h b/agent/native/ext/TextOutputStream_forward_decl.h similarity index 100% rename from src/ext/TextOutputStream_forward_decl.h rename to agent/native/ext/TextOutputStream_forward_decl.h diff --git a/src/ext/Tracer.c b/agent/native/ext/Tracer.c similarity index 100% rename from src/ext/Tracer.c rename to agent/native/ext/Tracer.c diff --git a/src/ext/Tracer.h b/agent/native/ext/Tracer.h similarity index 100% rename from src/ext/Tracer.h rename to agent/native/ext/Tracer.h diff --git a/src/ext/WordPress_instrumentation.c b/agent/native/ext/WordPress_instrumentation.c similarity index 100% rename from src/ext/WordPress_instrumentation.c rename to agent/native/ext/WordPress_instrumentation.c diff --git a/src/ext/WordPress_instrumentation.h b/agent/native/ext/WordPress_instrumentation.h similarity index 100% rename from src/ext/WordPress_instrumentation.h rename to agent/native/ext/WordPress_instrumentation.h diff --git a/src/ext/backend_comm.c b/agent/native/ext/backend_comm.c similarity index 100% rename from src/ext/backend_comm.c rename to agent/native/ext/backend_comm.c diff --git a/src/ext/backend_comm.h b/agent/native/ext/backend_comm.h similarity index 100% rename from src/ext/backend_comm.h rename to agent/native/ext/backend_comm.h diff --git a/src/ext/backend_comm_backoff.c b/agent/native/ext/backend_comm_backoff.c similarity index 100% rename from src/ext/backend_comm_backoff.c rename to agent/native/ext/backend_comm_backoff.c diff --git a/src/ext/backend_comm_backoff.h b/agent/native/ext/backend_comm_backoff.h similarity index 100% rename from src/ext/backend_comm_backoff.h rename to agent/native/ext/backend_comm_backoff.h diff --git a/src/ext/basic_macros.h b/agent/native/ext/basic_macros.h similarity index 100% rename from src/ext/basic_macros.h rename to agent/native/ext/basic_macros.h diff --git a/src/ext/basic_types.h b/agent/native/ext/basic_types.h similarity index 100% rename from src/ext/basic_types.h rename to agent/native/ext/basic_types.h diff --git a/src/ext/basic_util.h b/agent/native/ext/basic_util.h similarity index 100% rename from src/ext/basic_util.h rename to agent/native/ext/basic_util.h diff --git a/src/ext/config.m4 b/agent/native/ext/config.m4 similarity index 100% rename from src/ext/config.m4 rename to agent/native/ext/config.m4 diff --git a/src/ext/config.w32 b/agent/native/ext/config.w32 similarity index 100% rename from src/ext/config.w32 rename to agent/native/ext/config.w32 diff --git a/src/ext/constants.h b/agent/native/ext/constants.h similarity index 100% rename from src/ext/constants.h rename to agent/native/ext/constants.h diff --git a/src/ext/elastic_apm.c b/agent/native/ext/elastic_apm.c similarity index 98% rename from src/ext/elastic_apm.c rename to agent/native/ext/elastic_apm.c index 4124946da..198bac16b 100644 --- a/src/ext/elastic_apm.c +++ b/agent/native/ext/elastic_apm.c @@ -669,6 +669,16 @@ PHP_FUNCTION( elastic_apm_ast_instrumentation_direct_call ) } /* }}} */ +ZEND_BEGIN_ARG_INFO_EX( elastic_apm_get_version_arginfo, /* _unused */ 0, /* return_reference: */ 0, /* required_num_args: */ 0 ) +ZEND_END_ARG_INFO() +/* {{{ elastic_apm_get_version(): string + */ +PHP_FUNCTION( elastic_apm_get_version ) +{ + RETURN_STRING( PHP_ELASTIC_APM_VERSION ); +} +/* }}} */ + /* {{{ arginfo */ ZEND_BEGIN_ARG_INFO(elastic_apm_no_paramters_arginfo, 0) @@ -716,9 +726,14 @@ zend_module_entry elastic_apm_module_entry = { }; /* }}} */ -#ifdef COMPILE_DL_ELASTIC_APM -# ifdef ZTS -ZEND_TSRMLS_CACHE_DEFINE() -# endif -ZEND_GET_MODULE(elastic_apm) -#endif + +// #ifdef COMPILE_DL_ELASTIC_APM +// # ifdef ZTS +// ZEND_TSRMLS_CACHE_DEFINE() +// # endif +// extern "C" ZEND_GET_MODULE(elastic_apm) +// #endif + +extern __attribute__((visibility("default"))) void *get_module(void) { + return &elastic_apm_module_entry; +} diff --git a/src/ext/elastic_apm.ini b/agent/native/ext/elastic_apm.ini similarity index 100% rename from src/ext/elastic_apm.ini rename to agent/native/ext/elastic_apm.ini diff --git a/src/ext/elastic_apm_API.c b/agent/native/ext/elastic_apm_API.c similarity index 100% rename from src/ext/elastic_apm_API.c rename to agent/native/ext/elastic_apm_API.c diff --git a/src/ext/elastic_apm_API.h b/agent/native/ext/elastic_apm_API.h similarity index 100% rename from src/ext/elastic_apm_API.h rename to agent/native/ext/elastic_apm_API.h diff --git a/src/ext/elastic_apm_alloc.h b/agent/native/ext/elastic_apm_alloc.h similarity index 100% rename from src/ext/elastic_apm_alloc.h rename to agent/native/ext/elastic_apm_alloc.h diff --git a/src/ext/elastic_apm_assert.c b/agent/native/ext/elastic_apm_assert.c similarity index 100% rename from src/ext/elastic_apm_assert.c rename to agent/native/ext/elastic_apm_assert.c diff --git a/src/ext/elastic_apm_assert.h b/agent/native/ext/elastic_apm_assert.h similarity index 100% rename from src/ext/elastic_apm_assert.h rename to agent/native/ext/elastic_apm_assert.h diff --git a/src/ext/elastic_apm_assert_enabled.h b/agent/native/ext/elastic_apm_assert_enabled.h similarity index 100% rename from src/ext/elastic_apm_assert_enabled.h rename to agent/native/ext/elastic_apm_assert_enabled.h diff --git a/src/ext/elastic_apm_clock.h b/agent/native/ext/elastic_apm_clock.h similarity index 100% rename from src/ext/elastic_apm_clock.h rename to agent/native/ext/elastic_apm_clock.h diff --git a/src/ext/elastic_apm_is_debug_build.h b/agent/native/ext/elastic_apm_is_debug_build.h similarity index 100% rename from src/ext/elastic_apm_is_debug_build.h rename to agent/native/ext/elastic_apm_is_debug_build.h diff --git a/src/ext/elastic_apm_version.h b/agent/native/ext/elastic_apm_version.h similarity index 100% rename from src/ext/elastic_apm_version.h rename to agent/native/ext/elastic_apm_version.h diff --git a/src/ext/internal_checks.c b/agent/native/ext/internal_checks.c similarity index 100% rename from src/ext/internal_checks.c rename to agent/native/ext/internal_checks.c diff --git a/src/ext/internal_checks.h b/agent/native/ext/internal_checks.h similarity index 100% rename from src/ext/internal_checks.h rename to agent/native/ext/internal_checks.h diff --git a/src/ext/lifecycle.c b/agent/native/ext/lifecycle.c similarity index 100% rename from src/ext/lifecycle.c rename to agent/native/ext/lifecycle.c diff --git a/src/ext/lifecycle.h b/agent/native/ext/lifecycle.h similarity index 100% rename from src/ext/lifecycle.h rename to agent/native/ext/lifecycle.h diff --git a/src/ext/log.c b/agent/native/ext/log.c similarity index 100% rename from src/ext/log.c rename to agent/native/ext/log.c diff --git a/src/ext/log.h b/agent/native/ext/log.h similarity index 100% rename from src/ext/log.h rename to agent/native/ext/log.h diff --git a/src/ext/numbered_intercepting_callbacks.h b/agent/native/ext/numbered_intercepting_callbacks.h similarity index 99% rename from src/ext/numbered_intercepting_callbacks.h rename to agent/native/ext/numbered_intercepting_callbacks.h index 77922bac0..cef6f55cd 100644 --- a/src/ext/numbered_intercepting_callbacks.h +++ b/agent/native/ext/numbered_intercepting_callbacks.h @@ -40,7 +40,7 @@ numberedInterceptingCallback( uint32_t index, zend_execute_data* execute_data, z /**/ // Uncomment // gen_numbered_intercepting_callbacks_src( 1000 ); -// in main() in "src/ext/unit_tests/main.c" to generate the part below +// in main() in "agent/native/ext/unit_tests/main.c" to generate the part below ELASTIC_APM_DEFINE_NUMBERED_INTERCEPTING_CALLBACK( 0 ) ELASTIC_APM_DEFINE_NUMBERED_INTERCEPTING_CALLBACK( 1 ) diff --git a/src/ext/php_elastic_apm.h b/agent/native/ext/php_elastic_apm.h similarity index 100% rename from src/ext/php_elastic_apm.h rename to agent/native/ext/php_elastic_apm.h diff --git a/src/ext/php_error.c b/agent/native/ext/php_error.c similarity index 100% rename from src/ext/php_error.c rename to agent/native/ext/php_error.c diff --git a/src/ext/php_error.h b/agent/native/ext/php_error.h similarity index 100% rename from src/ext/php_error.h rename to agent/native/ext/php_error.h diff --git a/src/ext/platform.c b/agent/native/ext/platform.c similarity index 100% rename from src/ext/platform.c rename to agent/native/ext/platform.c diff --git a/src/ext/platform.h b/agent/native/ext/platform.h similarity index 100% rename from src/ext/platform.h rename to agent/native/ext/platform.h diff --git a/src/ext/platform_threads.h b/agent/native/ext/platform_threads.h similarity index 100% rename from src/ext/platform_threads.h rename to agent/native/ext/platform_threads.h diff --git a/src/ext/platform_threads_linux.c b/agent/native/ext/platform_threads_linux.c similarity index 100% rename from src/ext/platform_threads_linux.c rename to agent/native/ext/platform_threads_linux.c diff --git a/agent/native/ext/sample_prof.c b/agent/native/ext/sample_prof.c new file mode 100644 index 000000000..1e9985109 --- /dev/null +++ b/agent/native/ext/sample_prof.c @@ -0,0 +1,227 @@ +// #ifdef HAVE_CONFIG_H +// #include "config.h" +// #endif + +// #include "php.h" +// #include "php_ini.h" +// #include "ext/standard/info.h" +// #include "php_sample_prof.h" +// #include "zend_exceptions.h" +// #include "sample_prof_arginfo.h" + +// #include + +// #define SAMPLE_PROF_DEFAULT_INTERVAL 1 + +// /* On 64-bit this will give a 16 * 1MB allocation */ +// #define SAMPLE_PROF_DEFAULT_ALLOC (1 << 20) + +// ZEND_DECLARE_MODULE_GLOBALS(sample_prof) + +// static inline zend_bool sample_prof_end() { +// if (!SAMPLE_PROF_G->enabled) { +// return 0; +// } + +// pthread_cancel(SAMPLE_PROF_G->thread_id); + +// SAMPLE_PROF_G->enabled = 0; +// return 1; +// } + +// static void *sample_prof_handler(void *data) { +// zend_sample_prof_globals *g = SAMPLE_PROF_G; + +// #ifdef ZTS +// volatile zend_executor_globals *eg = TSRMG_BULK(executor_globals_id, zend_executor_globals *); +// #else +// volatile zend_executor_globals *eg = &executor_globals; +// #endif + +// retry_now: +// while (1) { +// volatile zend_execute_data *ex = eg->current_execute_data, *start_ex = ex; +// zend_function *func; +// const zend_op *opline; + +// while (1) { +// zend_execute_data *prev; + +// /* We're not executing code right now, try again later */ +// if (!ex) { +// goto retry_later; +// } + +// func = ex->func; +// opline = ex->opline; +// prev = ex->prev_execute_data; + +// /* current_execute_data changed in the meantime, reload it */ +// if (eg->current_execute_data != start_ex) { +// goto retry_now; +// } + +// if (func && ZEND_USER_CODE(func->type)) { +// break; +// } + +// ex = prev; +// } + +// if (!opline) { +// goto retry_later; +// } + +// g->entries[g->entries_num].filename = func->op_array.filename; +// g->entries[g->entries_num].lineno = opline->lineno; + +// if (++g->entries_num == g->entries_allocated) { +// /* Doing a realloc within a signal handler is unsafe, end profiling */ +// g->enabled = 0; +// break; +// } + +// retry_later: +// usleep(g->interval_usec); +// } +// pthread_exit(NULL); +// } + +// static void sample_prof_start(long interval_usec, size_t num_entries_alloc) { +// zend_sample_prof_globals *g = SAMPLE_PROF_G; + +// /* Initialize data structures for entries */ +// if (g->entries) { +// efree(g->entries); +// } + +// g->interval_usec = interval_usec; +// g->entries_allocated = num_entries_alloc; +// g->entries_num = 0; +// g->entries = safe_emalloc(g->entries_allocated, sizeof(sample_prof_entry), 0); + +// /* Register signal handler */ +// if (pthread_create(&g->thread_id, NULL, sample_prof_handler, NULL)) { +// zend_throw_exception(NULL, "Could not register signal handler", 0); +// return; +// } + +// g->enabled = 1; +// } + +// PHP_FUNCTION(sample_prof_start) { +// zend_long interval_usec = 0; +// zend_long num_entries_alloc = 0; + +// if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &interval_usec, &num_entries_alloc) == FAILURE) { +// return; +// } + +// if (interval_usec < 0) { +// zend_throw_exception(NULL, "Number of microseconds can't be negative", 0); +// return; +// } else if (interval_usec == 0) { +// interval_usec = SAMPLE_PROF_DEFAULT_INTERVAL; +// } + +// if (num_entries_alloc < 0) { +// zend_throw_exception(NULL, "Number of profiling can't be negative", 0); +// return; +// } else if (num_entries_alloc == 0) { +// num_entries_alloc = SAMPLE_PROF_DEFAULT_ALLOC; +// } + +// sample_prof_start(interval_usec, num_entries_alloc); +// } + +// PHP_FUNCTION(sample_prof_end) { +// if (zend_parse_parameters_none() == FAILURE) { +// return; +// } + +// RETURN_BOOL(sample_prof_end()); +// } + +// PHP_FUNCTION(sample_prof_get_data) { +// zend_sample_prof_globals *g = SAMPLE_PROF_G; +// size_t entry_num; + +// if (zend_parse_parameters_none() == FAILURE) { +// return; +// } + +// array_init(return_value); + +// for (entry_num = 0; entry_num < g->entries_num; ++entry_num) { +// sample_prof_entry *entry = &g->entries[entry_num]; +// zend_string *filename = entry->filename; +// uint32_t lineno = entry->lineno; +// zval *lines, *num; + +// lines = zend_hash_find(Z_ARR_P(return_value), filename); +// if (lines == NULL) { +// zval lines_zv; +// array_init(&lines_zv); +// lines = zend_hash_update(Z_ARR_P(return_value), filename, &lines_zv); +// } + +// num = zend_hash_index_find(Z_ARR_P(lines), lineno); +// if (num == NULL) { +// zval num_zv; +// ZVAL_LONG(&num_zv, 0); +// num = zend_hash_index_update(Z_ARR_P(lines), lineno, &num_zv); +// } + +// increment_function(num); +// } +// } + +// PHP_RINIT_FUNCTION(sample_prof) +// { +// SAMPLE_PROF_G->enabled = 0; +// SAMPLE_PROF_G->entries = NULL; +// SAMPLE_PROF_G->entries_num = 0; + +// return SUCCESS; +// } + +// PHP_RSHUTDOWN_FUNCTION(sample_prof) +// { +// sample_prof_end(); +// if (SAMPLE_PROF_G->entries) { +// efree(SAMPLE_PROF_G->entries); +// } + +// return SUCCESS; +// } + +// PHP_MINFO_FUNCTION(sample_prof) +// { +// php_info_print_table_start(); +// php_info_print_table_header(2, "sample_prof support", "enabled"); +// php_info_print_table_end(); +// } + +// const zend_function_entry sample_prof_functions[] = { +// PHP_FE(sample_prof_start, arginfo_sample_prof_start) +// PHP_FE(sample_prof_end, arginfo_sample_prof_end) +// PHP_FE(sample_prof_get_data, arginfo_sample_prof_get_data) +// PHP_FE_END +// }; + +// zend_module_entry sample_prof_module_entry = { +// STANDARD_MODULE_HEADER, +// "sample_prof", +// sample_prof_functions, +// NULL, +// NULL, +// PHP_RINIT(sample_prof), +// PHP_RSHUTDOWN(sample_prof), +// PHP_MINFO(sample_prof), +// PHP_SAMPLE_PROF_VERSION, +// PHP_MODULE_GLOBALS(sample_prof), +// NULL, +// NULL, +// NULL, +// STANDARD_MODULE_PROPERTIES_EX +// }; diff --git a/src/ext/supportability.c b/agent/native/ext/supportability.c similarity index 100% rename from src/ext/supportability.c rename to agent/native/ext/supportability.c diff --git a/src/ext/supportability.h b/agent/native/ext/supportability.h similarity index 100% rename from src/ext/supportability.h rename to agent/native/ext/supportability.h diff --git a/src/ext/supportability_zend.h b/agent/native/ext/supportability_zend.h similarity index 100% rename from src/ext/supportability_zend.h rename to agent/native/ext/supportability_zend.h diff --git a/src/ext/tests/config_boolean_0_using_env_var_is_false.phpt b/agent/native/ext/tests/config_boolean_0_using_env_var_is_false.phpt similarity index 73% rename from src/ext/tests/config_boolean_0_using_env_var_is_false.phpt rename to agent/native/ext/tests/config_boolean_0_using_env_var_is_false.phpt index 013674cd5..817c392d8 100644 --- a/src/ext/tests/config_boolean_0_using_env_var_is_false.phpt +++ b/agent/native/ext/tests/config_boolean_0_using_env_var_is_false.phpt @@ -4,7 +4,7 @@ Boolean configuration option value 0 (in this case using environment variable) s ELASTIC_APM_ENABLED=0 ELASTIC_APM_LOG_LEVEL_STDERR=CRITICAL --INI-- -elastic_apm.bootstrap_php_part_file=../bootstrap_php_part.php +elastic_apm.bootstrap_php_part_file=../../php/bootstrap_php_part.php --FILE-- --EXPECT-- diff --git a/src/ext/tests/config_boolean_0_using_ini_is_false.phpt b/agent/native/ext/tests/config_boolean_0_using_ini_is_false.phpt similarity index 87% rename from src/ext/tests/config_boolean_0_using_ini_is_false.phpt rename to agent/native/ext/tests/config_boolean_0_using_ini_is_false.phpt index b788295a5..8c988bc4f 100644 --- a/src/ext/tests/config_boolean_0_using_ini_is_false.phpt +++ b/agent/native/ext/tests/config_boolean_0_using_ini_is_false.phpt @@ -4,7 +4,7 @@ Boolean configuration option value 0 (in this case using ini file) should be int ELASTIC_APM_LOG_LEVEL_STDERR=CRITICAL --INI-- elastic_apm.enabled=0 -elastic_apm.bootstrap_php_part_file=../bootstrap_php_part.php +elastic_apm.bootstrap_php_part_file=../../php/bootstrap_php_part.php --FILE-- |/ ELASTIC_APM_SERVER_URL=<\/\/> ELASTIC_APM_SERVICE_NAME=/\><\/ --INI-- -elastic_apm.bootstrap_php_part_file=../bootstrap_php_part.php +elastic_apm.bootstrap_php_part_file=../../php/bootstrap_php_part.php --FILE-- |/ elastic_apm.server_url=<\/\/> elastic_apm.service_name=/\><\/ -elastic_apm.bootstrap_php_part_file=../bootstrap_php_part.php +elastic_apm.bootstrap_php_part_file=../../php/bootstrap_php_part.php --FILE-- /src/ext/ConfigManager.h to add the new option for C part of the agent. + // 1) Follow the steps in /agent/native/ext/ConfigManager.h to add the new option for C part of the agent. // NOTE: Build C part of the agent after making the changes above and before proceeding to the steps below. // // diff --git a/src/ElasticApm/Impl/Config/SnapshotDevInternal.php b/agent/php/ElasticApm/Impl/Config/SnapshotDevInternal.php similarity index 100% rename from src/ElasticApm/Impl/Config/SnapshotDevInternal.php rename to agent/php/ElasticApm/Impl/Config/SnapshotDevInternal.php diff --git a/src/ElasticApm/Impl/Config/SnapshotTrait.php b/agent/php/ElasticApm/Impl/Config/SnapshotTrait.php similarity index 100% rename from src/ElasticApm/Impl/Config/SnapshotTrait.php rename to agent/php/ElasticApm/Impl/Config/SnapshotTrait.php diff --git a/src/ElasticApm/Impl/Config/StringOptionMetadata.php b/agent/php/ElasticApm/Impl/Config/StringOptionMetadata.php similarity index 100% rename from src/ElasticApm/Impl/Config/StringOptionMetadata.php rename to agent/php/ElasticApm/Impl/Config/StringOptionMetadata.php diff --git a/src/ElasticApm/Impl/Config/StringOptionParser.php b/agent/php/ElasticApm/Impl/Config/StringOptionParser.php similarity index 100% rename from src/ElasticApm/Impl/Config/StringOptionParser.php rename to agent/php/ElasticApm/Impl/Config/StringOptionParser.php diff --git a/src/ElasticApm/Impl/Config/WildcardListOptionMetadata.php b/agent/php/ElasticApm/Impl/Config/WildcardListOptionMetadata.php similarity index 100% rename from src/ElasticApm/Impl/Config/WildcardListOptionMetadata.php rename to agent/php/ElasticApm/Impl/Config/WildcardListOptionMetadata.php diff --git a/src/ElasticApm/Impl/Config/WildcardListOptionParser.php b/agent/php/ElasticApm/Impl/Config/WildcardListOptionParser.php similarity index 100% rename from src/ElasticApm/Impl/Config/WildcardListOptionParser.php rename to agent/php/ElasticApm/Impl/Config/WildcardListOptionParser.php diff --git a/src/ElasticApm/Impl/Constants.php b/agent/php/ElasticApm/Impl/Constants.php similarity index 100% rename from src/ElasticApm/Impl/Constants.php rename to agent/php/ElasticApm/Impl/Constants.php diff --git a/src/ElasticApm/Impl/ContextPartWrapper.php b/agent/php/ElasticApm/Impl/ContextPartWrapper.php similarity index 100% rename from src/ElasticApm/Impl/ContextPartWrapper.php rename to agent/php/ElasticApm/Impl/ContextPartWrapper.php diff --git a/src/ElasticApm/Impl/DistributedTracingDataInternal.php b/agent/php/ElasticApm/Impl/DistributedTracingDataInternal.php similarity index 100% rename from src/ElasticApm/Impl/DistributedTracingDataInternal.php rename to agent/php/ElasticApm/Impl/DistributedTracingDataInternal.php diff --git a/src/ElasticApm/Impl/Error.php b/agent/php/ElasticApm/Impl/Error.php similarity index 100% rename from src/ElasticApm/Impl/Error.php rename to agent/php/ElasticApm/Impl/Error.php diff --git a/src/ElasticApm/Impl/ErrorExceptionData.php b/agent/php/ElasticApm/Impl/ErrorExceptionData.php similarity index 100% rename from src/ElasticApm/Impl/ErrorExceptionData.php rename to agent/php/ElasticApm/Impl/ErrorExceptionData.php diff --git a/src/ElasticApm/Impl/ErrorTransactionData.php b/agent/php/ElasticApm/Impl/ErrorTransactionData.php similarity index 100% rename from src/ElasticApm/Impl/ErrorTransactionData.php rename to agent/php/ElasticApm/Impl/ErrorTransactionData.php diff --git a/src/ElasticApm/Impl/EventSinkInterface.php b/agent/php/ElasticApm/Impl/EventSinkInterface.php similarity index 100% rename from src/ElasticApm/Impl/EventSinkInterface.php rename to agent/php/ElasticApm/Impl/EventSinkInterface.php diff --git a/src/ElasticApm/Impl/ExecutionSegment.php b/agent/php/ElasticApm/Impl/ExecutionSegment.php similarity index 100% rename from src/ElasticApm/Impl/ExecutionSegment.php rename to agent/php/ElasticApm/Impl/ExecutionSegment.php diff --git a/src/ElasticApm/Impl/ExecutionSegmentContext.php b/agent/php/ElasticApm/Impl/ExecutionSegmentContext.php similarity index 100% rename from src/ElasticApm/Impl/ExecutionSegmentContext.php rename to agent/php/ElasticApm/Impl/ExecutionSegmentContext.php diff --git a/src/ElasticApm/Impl/GlobalTracerHolder.php b/agent/php/ElasticApm/Impl/GlobalTracerHolder.php similarity index 100% rename from src/ElasticApm/Impl/GlobalTracerHolder.php rename to agent/php/ElasticApm/Impl/GlobalTracerHolder.php diff --git a/src/ElasticApm/Impl/HttpDistributedTracing.php b/agent/php/ElasticApm/Impl/HttpDistributedTracing.php similarity index 100% rename from src/ElasticApm/Impl/HttpDistributedTracing.php rename to agent/php/ElasticApm/Impl/HttpDistributedTracing.php diff --git a/src/ElasticApm/Impl/InferredSpanFrame.php b/agent/php/ElasticApm/Impl/InferredSpanFrame.php similarity index 100% rename from src/ElasticApm/Impl/InferredSpanFrame.php rename to agent/php/ElasticApm/Impl/InferredSpanFrame.php diff --git a/src/ElasticApm/Impl/InferredSpansBuilder.php b/agent/php/ElasticApm/Impl/InferredSpansBuilder.php similarity index 100% rename from src/ElasticApm/Impl/InferredSpansBuilder.php rename to agent/php/ElasticApm/Impl/InferredSpansBuilder.php diff --git a/src/ElasticApm/Impl/InferredSpansManager.php b/agent/php/ElasticApm/Impl/InferredSpansManager.php similarity index 100% rename from src/ElasticApm/Impl/InferredSpansManager.php rename to agent/php/ElasticApm/Impl/InferredSpansManager.php diff --git a/src/ElasticApm/Impl/Log/AdhocLoggableObject.php b/agent/php/ElasticApm/Impl/Log/AdhocLoggableObject.php similarity index 100% rename from src/ElasticApm/Impl/Log/AdhocLoggableObject.php rename to agent/php/ElasticApm/Impl/Log/AdhocLoggableObject.php diff --git a/src/ElasticApm/Impl/Log/Backend.php b/agent/php/ElasticApm/Impl/Log/Backend.php similarity index 100% rename from src/ElasticApm/Impl/Log/Backend.php rename to agent/php/ElasticApm/Impl/Log/Backend.php diff --git a/src/ElasticApm/Impl/Log/EnabledLoggerProxy.php b/agent/php/ElasticApm/Impl/Log/EnabledLoggerProxy.php similarity index 100% rename from src/ElasticApm/Impl/Log/EnabledLoggerProxy.php rename to agent/php/ElasticApm/Impl/Log/EnabledLoggerProxy.php diff --git a/src/ElasticApm/Impl/Log/EnabledLoggerProxyNoLine.php b/agent/php/ElasticApm/Impl/Log/EnabledLoggerProxyNoLine.php similarity index 100% rename from src/ElasticApm/Impl/Log/EnabledLoggerProxyNoLine.php rename to agent/php/ElasticApm/Impl/Log/EnabledLoggerProxyNoLine.php diff --git a/src/ElasticApm/Impl/Log/Level.php b/agent/php/ElasticApm/Impl/Log/Level.php similarity index 100% rename from src/ElasticApm/Impl/Log/Level.php rename to agent/php/ElasticApm/Impl/Log/Level.php diff --git a/src/ElasticApm/Impl/Log/LogCategory.php b/agent/php/ElasticApm/Impl/Log/LogCategory.php similarity index 100% rename from src/ElasticApm/Impl/Log/LogCategory.php rename to agent/php/ElasticApm/Impl/Log/LogCategory.php diff --git a/src/ElasticApm/Impl/Log/LogConsts.php b/agent/php/ElasticApm/Impl/Log/LogConsts.php similarity index 100% rename from src/ElasticApm/Impl/Log/LogConsts.php rename to agent/php/ElasticApm/Impl/Log/LogConsts.php diff --git a/src/ElasticApm/Impl/Log/LogStream.php b/agent/php/ElasticApm/Impl/Log/LogStream.php similarity index 100% rename from src/ElasticApm/Impl/Log/LogStream.php rename to agent/php/ElasticApm/Impl/Log/LogStream.php diff --git a/src/ElasticApm/Impl/Log/LogStreamInterface.php b/agent/php/ElasticApm/Impl/Log/LogStreamInterface.php similarity index 100% rename from src/ElasticApm/Impl/Log/LogStreamInterface.php rename to agent/php/ElasticApm/Impl/Log/LogStreamInterface.php diff --git a/src/ElasticApm/Impl/Log/LoggableArray.php b/agent/php/ElasticApm/Impl/Log/LoggableArray.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableArray.php rename to agent/php/ElasticApm/Impl/Log/LoggableArray.php diff --git a/src/ElasticApm/Impl/Log/LoggableInterface.php b/agent/php/ElasticApm/Impl/Log/LoggableInterface.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableInterface.php rename to agent/php/ElasticApm/Impl/Log/LoggableInterface.php diff --git a/src/ElasticApm/Impl/Log/LoggableStackTrace.php b/agent/php/ElasticApm/Impl/Log/LoggableStackTrace.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableStackTrace.php rename to agent/php/ElasticApm/Impl/Log/LoggableStackTrace.php diff --git a/src/ElasticApm/Impl/Log/LoggableToEncodedJson.php b/agent/php/ElasticApm/Impl/Log/LoggableToEncodedJson.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableToEncodedJson.php rename to agent/php/ElasticApm/Impl/Log/LoggableToEncodedJson.php diff --git a/src/ElasticApm/Impl/Log/LoggableToJsonEncodable.php b/agent/php/ElasticApm/Impl/Log/LoggableToJsonEncodable.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableToJsonEncodable.php rename to agent/php/ElasticApm/Impl/Log/LoggableToJsonEncodable.php diff --git a/src/ElasticApm/Impl/Log/LoggableToString.php b/agent/php/ElasticApm/Impl/Log/LoggableToString.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableToString.php rename to agent/php/ElasticApm/Impl/Log/LoggableToString.php diff --git a/src/ElasticApm/Impl/Log/LoggableTrait.php b/agent/php/ElasticApm/Impl/Log/LoggableTrait.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggableTrait.php rename to agent/php/ElasticApm/Impl/Log/LoggableTrait.php diff --git a/src/ElasticApm/Impl/Log/Logger.php b/agent/php/ElasticApm/Impl/Log/Logger.php similarity index 100% rename from src/ElasticApm/Impl/Log/Logger.php rename to agent/php/ElasticApm/Impl/Log/Logger.php diff --git a/src/ElasticApm/Impl/Log/LoggerData.php b/agent/php/ElasticApm/Impl/Log/LoggerData.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggerData.php rename to agent/php/ElasticApm/Impl/Log/LoggerData.php diff --git a/src/ElasticApm/Impl/Log/LoggerFactory.php b/agent/php/ElasticApm/Impl/Log/LoggerFactory.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggerFactory.php rename to agent/php/ElasticApm/Impl/Log/LoggerFactory.php diff --git a/src/ElasticApm/Impl/Log/LoggingSubsystem.php b/agent/php/ElasticApm/Impl/Log/LoggingSubsystem.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggingSubsystem.php rename to agent/php/ElasticApm/Impl/Log/LoggingSubsystem.php diff --git a/src/ElasticApm/Impl/Log/LoggingSubsystemException.php b/agent/php/ElasticApm/Impl/Log/LoggingSubsystemException.php similarity index 100% rename from src/ElasticApm/Impl/Log/LoggingSubsystemException.php rename to agent/php/ElasticApm/Impl/Log/LoggingSubsystemException.php diff --git a/src/ElasticApm/Impl/Log/NoopLogSink.php b/agent/php/ElasticApm/Impl/Log/NoopLogSink.php similarity index 100% rename from src/ElasticApm/Impl/Log/NoopLogSink.php rename to agent/php/ElasticApm/Impl/Log/NoopLogSink.php diff --git a/src/ElasticApm/Impl/Log/NoopLoggerFactory.php b/agent/php/ElasticApm/Impl/Log/NoopLoggerFactory.php similarity index 100% rename from src/ElasticApm/Impl/Log/NoopLoggerFactory.php rename to agent/php/ElasticApm/Impl/Log/NoopLoggerFactory.php diff --git a/src/ElasticApm/Impl/Log/PropertyLogPriority.php b/agent/php/ElasticApm/Impl/Log/PropertyLogPriority.php similarity index 100% rename from src/ElasticApm/Impl/Log/PropertyLogPriority.php rename to agent/php/ElasticApm/Impl/Log/PropertyLogPriority.php diff --git a/src/ElasticApm/Impl/Log/SinkBase.php b/agent/php/ElasticApm/Impl/Log/SinkBase.php similarity index 100% rename from src/ElasticApm/Impl/Log/SinkBase.php rename to agent/php/ElasticApm/Impl/Log/SinkBase.php diff --git a/src/ElasticApm/Impl/Log/SinkInterface.php b/agent/php/ElasticApm/Impl/Log/SinkInterface.php similarity index 100% rename from src/ElasticApm/Impl/Log/SinkInterface.php rename to agent/php/ElasticApm/Impl/Log/SinkInterface.php diff --git a/src/ElasticApm/Impl/Log/SinkToCExt.php b/agent/php/ElasticApm/Impl/Log/SinkToCExt.php similarity index 100% rename from src/ElasticApm/Impl/Log/SinkToCExt.php rename to agent/php/ElasticApm/Impl/Log/SinkToCExt.php diff --git a/src/ElasticApm/Impl/Metadata.php b/agent/php/ElasticApm/Impl/Metadata.php similarity index 100% rename from src/ElasticApm/Impl/Metadata.php rename to agent/php/ElasticApm/Impl/Metadata.php diff --git a/src/ElasticApm/Impl/MetadataDiscoverer.php b/agent/php/ElasticApm/Impl/MetadataDiscoverer.php similarity index 100% rename from src/ElasticApm/Impl/MetadataDiscoverer.php rename to agent/php/ElasticApm/Impl/MetadataDiscoverer.php diff --git a/src/ElasticApm/Impl/MetricSet.php b/agent/php/ElasticApm/Impl/MetricSet.php similarity index 100% rename from src/ElasticApm/Impl/MetricSet.php rename to agent/php/ElasticApm/Impl/MetricSet.php diff --git a/src/ElasticApm/Impl/NameVersionData.php b/agent/php/ElasticApm/Impl/NameVersionData.php similarity index 100% rename from src/ElasticApm/Impl/NameVersionData.php rename to agent/php/ElasticApm/Impl/NameVersionData.php diff --git a/src/ElasticApm/Impl/NoopDistributedTracingData.php b/agent/php/ElasticApm/Impl/NoopDistributedTracingData.php similarity index 100% rename from src/ElasticApm/Impl/NoopDistributedTracingData.php rename to agent/php/ElasticApm/Impl/NoopDistributedTracingData.php diff --git a/src/ElasticApm/Impl/NoopEventSink.php b/agent/php/ElasticApm/Impl/NoopEventSink.php similarity index 100% rename from src/ElasticApm/Impl/NoopEventSink.php rename to agent/php/ElasticApm/Impl/NoopEventSink.php diff --git a/src/ElasticApm/Impl/NoopExecutionSegment.php b/agent/php/ElasticApm/Impl/NoopExecutionSegment.php similarity index 100% rename from src/ElasticApm/Impl/NoopExecutionSegment.php rename to agent/php/ElasticApm/Impl/NoopExecutionSegment.php diff --git a/src/ElasticApm/Impl/NoopExecutionSegmentContext.php b/agent/php/ElasticApm/Impl/NoopExecutionSegmentContext.php similarity index 100% rename from src/ElasticApm/Impl/NoopExecutionSegmentContext.php rename to agent/php/ElasticApm/Impl/NoopExecutionSegmentContext.php diff --git a/src/ElasticApm/Impl/NoopSpan.php b/agent/php/ElasticApm/Impl/NoopSpan.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpan.php rename to agent/php/ElasticApm/Impl/NoopSpan.php diff --git a/src/ElasticApm/Impl/NoopSpanContext.php b/agent/php/ElasticApm/Impl/NoopSpanContext.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContext.php rename to agent/php/ElasticApm/Impl/NoopSpanContext.php diff --git a/src/ElasticApm/Impl/NoopSpanContextDb.php b/agent/php/ElasticApm/Impl/NoopSpanContextDb.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContextDb.php rename to agent/php/ElasticApm/Impl/NoopSpanContextDb.php diff --git a/src/ElasticApm/Impl/NoopSpanContextDestination.php b/agent/php/ElasticApm/Impl/NoopSpanContextDestination.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContextDestination.php rename to agent/php/ElasticApm/Impl/NoopSpanContextDestination.php diff --git a/src/ElasticApm/Impl/NoopSpanContextHttp.php b/agent/php/ElasticApm/Impl/NoopSpanContextHttp.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContextHttp.php rename to agent/php/ElasticApm/Impl/NoopSpanContextHttp.php diff --git a/src/ElasticApm/Impl/NoopSpanContextService.php b/agent/php/ElasticApm/Impl/NoopSpanContextService.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContextService.php rename to agent/php/ElasticApm/Impl/NoopSpanContextService.php diff --git a/src/ElasticApm/Impl/NoopSpanContextServiceTarget.php b/agent/php/ElasticApm/Impl/NoopSpanContextServiceTarget.php similarity index 100% rename from src/ElasticApm/Impl/NoopSpanContextServiceTarget.php rename to agent/php/ElasticApm/Impl/NoopSpanContextServiceTarget.php diff --git a/src/ElasticApm/Impl/NoopTracer.php b/agent/php/ElasticApm/Impl/NoopTracer.php similarity index 100% rename from src/ElasticApm/Impl/NoopTracer.php rename to agent/php/ElasticApm/Impl/NoopTracer.php diff --git a/src/ElasticApm/Impl/NoopTransaction.php b/agent/php/ElasticApm/Impl/NoopTransaction.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransaction.php rename to agent/php/ElasticApm/Impl/NoopTransaction.php diff --git a/src/ElasticApm/Impl/NoopTransactionBuilder.php b/agent/php/ElasticApm/Impl/NoopTransactionBuilder.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransactionBuilder.php rename to agent/php/ElasticApm/Impl/NoopTransactionBuilder.php diff --git a/src/ElasticApm/Impl/NoopTransactionContext.php b/agent/php/ElasticApm/Impl/NoopTransactionContext.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransactionContext.php rename to agent/php/ElasticApm/Impl/NoopTransactionContext.php diff --git a/src/ElasticApm/Impl/NoopTransactionContextRequest.php b/agent/php/ElasticApm/Impl/NoopTransactionContextRequest.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransactionContextRequest.php rename to agent/php/ElasticApm/Impl/NoopTransactionContextRequest.php diff --git a/src/ElasticApm/Impl/NoopTransactionContextRequestUrl.php b/agent/php/ElasticApm/Impl/NoopTransactionContextRequestUrl.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransactionContextRequestUrl.php rename to agent/php/ElasticApm/Impl/NoopTransactionContextRequestUrl.php diff --git a/src/ElasticApm/Impl/NoopTransactionContextUser.php b/agent/php/ElasticApm/Impl/NoopTransactionContextUser.php similarity index 100% rename from src/ElasticApm/Impl/NoopTransactionContextUser.php rename to agent/php/ElasticApm/Impl/NoopTransactionContextUser.php diff --git a/src/ElasticApm/Impl/OptionalSerializableDataInterface.php b/agent/php/ElasticApm/Impl/OptionalSerializableDataInterface.php similarity index 100% rename from src/ElasticApm/Impl/OptionalSerializableDataInterface.php rename to agent/php/ElasticApm/Impl/OptionalSerializableDataInterface.php diff --git a/src/ElasticApm/Impl/ProcessData.php b/agent/php/ElasticApm/Impl/ProcessData.php similarity index 100% rename from src/ElasticApm/Impl/ProcessData.php rename to agent/php/ElasticApm/Impl/ProcessData.php diff --git a/src/ElasticApm/Impl/SerializableDataInterface.php b/agent/php/ElasticApm/Impl/SerializableDataInterface.php similarity index 100% rename from src/ElasticApm/Impl/SerializableDataInterface.php rename to agent/php/ElasticApm/Impl/SerializableDataInterface.php diff --git a/src/ElasticApm/Impl/ServiceAgentData.php b/agent/php/ElasticApm/Impl/ServiceAgentData.php similarity index 100% rename from src/ElasticApm/Impl/ServiceAgentData.php rename to agent/php/ElasticApm/Impl/ServiceAgentData.php diff --git a/src/ElasticApm/Impl/ServiceData.php b/agent/php/ElasticApm/Impl/ServiceData.php similarity index 100% rename from src/ElasticApm/Impl/ServiceData.php rename to agent/php/ElasticApm/Impl/ServiceData.php diff --git a/src/ElasticApm/Impl/Span.php b/agent/php/ElasticApm/Impl/Span.php similarity index 100% rename from src/ElasticApm/Impl/Span.php rename to agent/php/ElasticApm/Impl/Span.php diff --git a/src/ElasticApm/Impl/SpanComposite.php b/agent/php/ElasticApm/Impl/SpanComposite.php similarity index 100% rename from src/ElasticApm/Impl/SpanComposite.php rename to agent/php/ElasticApm/Impl/SpanComposite.php diff --git a/src/ElasticApm/Impl/SpanCompositeData.php b/agent/php/ElasticApm/Impl/SpanCompositeData.php similarity index 100% rename from src/ElasticApm/Impl/SpanCompositeData.php rename to agent/php/ElasticApm/Impl/SpanCompositeData.php diff --git a/src/ElasticApm/Impl/SpanContext.php b/agent/php/ElasticApm/Impl/SpanContext.php similarity index 100% rename from src/ElasticApm/Impl/SpanContext.php rename to agent/php/ElasticApm/Impl/SpanContext.php diff --git a/src/ElasticApm/Impl/SpanContextDb.php b/agent/php/ElasticApm/Impl/SpanContextDb.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextDb.php rename to agent/php/ElasticApm/Impl/SpanContextDb.php diff --git a/src/ElasticApm/Impl/SpanContextDestination.php b/agent/php/ElasticApm/Impl/SpanContextDestination.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextDestination.php rename to agent/php/ElasticApm/Impl/SpanContextDestination.php diff --git a/src/ElasticApm/Impl/SpanContextDestinationServiceData.php b/agent/php/ElasticApm/Impl/SpanContextDestinationServiceData.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextDestinationServiceData.php rename to agent/php/ElasticApm/Impl/SpanContextDestinationServiceData.php diff --git a/src/ElasticApm/Impl/SpanContextHttp.php b/agent/php/ElasticApm/Impl/SpanContextHttp.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextHttp.php rename to agent/php/ElasticApm/Impl/SpanContextHttp.php diff --git a/src/ElasticApm/Impl/SpanContextService.php b/agent/php/ElasticApm/Impl/SpanContextService.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextService.php rename to agent/php/ElasticApm/Impl/SpanContextService.php diff --git a/src/ElasticApm/Impl/SpanContextServiceTarget.php b/agent/php/ElasticApm/Impl/SpanContextServiceTarget.php similarity index 100% rename from src/ElasticApm/Impl/SpanContextServiceTarget.php rename to agent/php/ElasticApm/Impl/SpanContextServiceTarget.php diff --git a/src/ElasticApm/Impl/SpanToSendInterface.php b/agent/php/ElasticApm/Impl/SpanToSendInterface.php similarity index 100% rename from src/ElasticApm/Impl/SpanToSendInterface.php rename to agent/php/ElasticApm/Impl/SpanToSendInterface.php diff --git a/src/ElasticApm/Impl/SrcRootDir.php b/agent/php/ElasticApm/Impl/SrcRootDir.php similarity index 100% rename from src/ElasticApm/Impl/SrcRootDir.php rename to agent/php/ElasticApm/Impl/SrcRootDir.php diff --git a/src/ElasticApm/Impl/StackTraceFrame.php b/agent/php/ElasticApm/Impl/StackTraceFrame.php similarity index 100% rename from src/ElasticApm/Impl/StackTraceFrame.php rename to agent/php/ElasticApm/Impl/StackTraceFrame.php diff --git a/src/ElasticApm/Impl/SystemData.php b/agent/php/ElasticApm/Impl/SystemData.php similarity index 100% rename from src/ElasticApm/Impl/SystemData.php rename to agent/php/ElasticApm/Impl/SystemData.php diff --git a/src/ElasticApm/Impl/Tracer.php b/agent/php/ElasticApm/Impl/Tracer.php similarity index 100% rename from src/ElasticApm/Impl/Tracer.php rename to agent/php/ElasticApm/Impl/Tracer.php diff --git a/src/ElasticApm/Impl/TracerBuilder.php b/agent/php/ElasticApm/Impl/TracerBuilder.php similarity index 100% rename from src/ElasticApm/Impl/TracerBuilder.php rename to agent/php/ElasticApm/Impl/TracerBuilder.php diff --git a/src/ElasticApm/Impl/TracerDependencies.php b/agent/php/ElasticApm/Impl/TracerDependencies.php similarity index 100% rename from src/ElasticApm/Impl/TracerDependencies.php rename to agent/php/ElasticApm/Impl/TracerDependencies.php diff --git a/src/ElasticApm/Impl/TracerInterface.php b/agent/php/ElasticApm/Impl/TracerInterface.php similarity index 100% rename from src/ElasticApm/Impl/TracerInterface.php rename to agent/php/ElasticApm/Impl/TracerInterface.php diff --git a/src/ElasticApm/Impl/Transaction.php b/agent/php/ElasticApm/Impl/Transaction.php similarity index 100% rename from src/ElasticApm/Impl/Transaction.php rename to agent/php/ElasticApm/Impl/Transaction.php diff --git a/src/ElasticApm/Impl/TransactionBuilder.php b/agent/php/ElasticApm/Impl/TransactionBuilder.php similarity index 100% rename from src/ElasticApm/Impl/TransactionBuilder.php rename to agent/php/ElasticApm/Impl/TransactionBuilder.php diff --git a/src/ElasticApm/Impl/TransactionContext.php b/agent/php/ElasticApm/Impl/TransactionContext.php similarity index 100% rename from src/ElasticApm/Impl/TransactionContext.php rename to agent/php/ElasticApm/Impl/TransactionContext.php diff --git a/src/ElasticApm/Impl/TransactionContextRequest.php b/agent/php/ElasticApm/Impl/TransactionContextRequest.php similarity index 100% rename from src/ElasticApm/Impl/TransactionContextRequest.php rename to agent/php/ElasticApm/Impl/TransactionContextRequest.php diff --git a/src/ElasticApm/Impl/TransactionContextRequestUrl.php b/agent/php/ElasticApm/Impl/TransactionContextRequestUrl.php similarity index 100% rename from src/ElasticApm/Impl/TransactionContextRequestUrl.php rename to agent/php/ElasticApm/Impl/TransactionContextRequestUrl.php diff --git a/src/ElasticApm/Impl/TransactionContextUser.php b/agent/php/ElasticApm/Impl/TransactionContextUser.php similarity index 100% rename from src/ElasticApm/Impl/TransactionContextUser.php rename to agent/php/ElasticApm/Impl/TransactionContextUser.php diff --git a/src/ElasticApm/Impl/Util/ArrayUtil.php b/agent/php/ElasticApm/Impl/Util/ArrayUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/ArrayUtil.php rename to agent/php/ElasticApm/Impl/Util/ArrayUtil.php diff --git a/src/ElasticApm/Impl/Util/Assert.php b/agent/php/ElasticApm/Impl/Util/Assert.php similarity index 100% rename from src/ElasticApm/Impl/Util/Assert.php rename to agent/php/ElasticApm/Impl/Util/Assert.php diff --git a/src/ElasticApm/Impl/Util/AssertException.php b/agent/php/ElasticApm/Impl/Util/AssertException.php similarity index 100% rename from src/ElasticApm/Impl/Util/AssertException.php rename to agent/php/ElasticApm/Impl/Util/AssertException.php diff --git a/src/ElasticApm/Impl/Util/AssertLevel.php b/agent/php/ElasticApm/Impl/Util/AssertLevel.php similarity index 100% rename from src/ElasticApm/Impl/Util/AssertLevel.php rename to agent/php/ElasticApm/Impl/Util/AssertLevel.php diff --git a/src/ElasticApm/Impl/Util/BoolUtil.php b/agent/php/ElasticApm/Impl/Util/BoolUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/BoolUtil.php rename to agent/php/ElasticApm/Impl/Util/BoolUtil.php diff --git a/src/ElasticApm/Impl/Util/CallerInfo.php b/agent/php/ElasticApm/Impl/Util/CallerInfo.php similarity index 100% rename from src/ElasticApm/Impl/Util/CallerInfo.php rename to agent/php/ElasticApm/Impl/Util/CallerInfo.php diff --git a/src/ElasticApm/Impl/Util/ClassNameUtil.php b/agent/php/ElasticApm/Impl/Util/ClassNameUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/ClassNameUtil.php rename to agent/php/ElasticApm/Impl/Util/ClassNameUtil.php diff --git a/src/ElasticApm/Impl/Util/ClassicFormatStackTraceFrame.php b/agent/php/ElasticApm/Impl/Util/ClassicFormatStackTraceFrame.php similarity index 100% rename from src/ElasticApm/Impl/Util/ClassicFormatStackTraceFrame.php rename to agent/php/ElasticApm/Impl/Util/ClassicFormatStackTraceFrame.php diff --git a/src/ElasticApm/Impl/Util/DbgUtil.php b/agent/php/ElasticApm/Impl/Util/DbgUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/DbgUtil.php rename to agent/php/ElasticApm/Impl/Util/DbgUtil.php diff --git a/src/ElasticApm/Impl/Util/ElasticApmExtensionUtil.php b/agent/php/ElasticApm/Impl/Util/ElasticApmExtensionUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/ElasticApmExtensionUtil.php rename to agent/php/ElasticApm/Impl/Util/ElasticApmExtensionUtil.php diff --git a/src/ElasticApm/Impl/Util/EnabledAssertProxy.php b/agent/php/ElasticApm/Impl/Util/EnabledAssertProxy.php similarity index 100% rename from src/ElasticApm/Impl/Util/EnabledAssertProxy.php rename to agent/php/ElasticApm/Impl/Util/EnabledAssertProxy.php diff --git a/src/ElasticApm/Impl/Util/ExceptionUtil.php b/agent/php/ElasticApm/Impl/Util/ExceptionUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/ExceptionUtil.php rename to agent/php/ElasticApm/Impl/Util/ExceptionUtil.php diff --git a/src/ElasticApm/Impl/Util/HiddenConstructorTrait.php b/agent/php/ElasticApm/Impl/Util/HiddenConstructorTrait.php similarity index 100% rename from src/ElasticApm/Impl/Util/HiddenConstructorTrait.php rename to agent/php/ElasticApm/Impl/Util/HiddenConstructorTrait.php diff --git a/src/ElasticApm/Impl/Util/IdGenerator.php b/agent/php/ElasticApm/Impl/Util/IdGenerator.php similarity index 100% rename from src/ElasticApm/Impl/Util/IdGenerator.php rename to agent/php/ElasticApm/Impl/Util/IdGenerator.php diff --git a/src/ElasticApm/Impl/Util/IdValidationUtil.php b/agent/php/ElasticApm/Impl/Util/IdValidationUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/IdValidationUtil.php rename to agent/php/ElasticApm/Impl/Util/IdValidationUtil.php diff --git a/src/ElasticApm/Impl/Util/InternalFailureException.php b/agent/php/ElasticApm/Impl/Util/InternalFailureException.php similarity index 100% rename from src/ElasticApm/Impl/Util/InternalFailureException.php rename to agent/php/ElasticApm/Impl/Util/InternalFailureException.php diff --git a/src/ElasticApm/Impl/Util/IterableUtil.php b/agent/php/ElasticApm/Impl/Util/IterableUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/IterableUtil.php rename to agent/php/ElasticApm/Impl/Util/IterableUtil.php diff --git a/src/ElasticApm/Impl/Util/JsonException.php b/agent/php/ElasticApm/Impl/Util/JsonException.php similarity index 100% rename from src/ElasticApm/Impl/Util/JsonException.php rename to agent/php/ElasticApm/Impl/Util/JsonException.php diff --git a/src/ElasticApm/Impl/Util/JsonUtil.php b/agent/php/ElasticApm/Impl/Util/JsonUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/JsonUtil.php rename to agent/php/ElasticApm/Impl/Util/JsonUtil.php diff --git a/src/ElasticApm/Impl/Util/NoopObjectTrait.php b/agent/php/ElasticApm/Impl/Util/NoopObjectTrait.php similarity index 100% rename from src/ElasticApm/Impl/Util/NoopObjectTrait.php rename to agent/php/ElasticApm/Impl/Util/NoopObjectTrait.php diff --git a/src/ElasticApm/Impl/Util/NumericUtil.php b/agent/php/ElasticApm/Impl/Util/NumericUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/NumericUtil.php rename to agent/php/ElasticApm/Impl/Util/NumericUtil.php diff --git a/src/ElasticApm/Impl/Util/ObserverSet.php b/agent/php/ElasticApm/Impl/Util/ObserverSet.php similarity index 100% rename from src/ElasticApm/Impl/Util/ObserverSet.php rename to agent/php/ElasticApm/Impl/Util/ObserverSet.php diff --git a/src/ElasticApm/Impl/Util/PhpErrorUtil.php b/agent/php/ElasticApm/Impl/Util/PhpErrorUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/PhpErrorUtil.php rename to agent/php/ElasticApm/Impl/Util/PhpErrorUtil.php diff --git a/src/ElasticApm/Impl/Util/RandomUtil.php b/agent/php/ElasticApm/Impl/Util/RandomUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/RandomUtil.php rename to agent/php/ElasticApm/Impl/Util/RandomUtil.php diff --git a/src/ElasticApm/Impl/Util/RangeUtil.php b/agent/php/ElasticApm/Impl/Util/RangeUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/RangeUtil.php rename to agent/php/ElasticApm/Impl/Util/RangeUtil.php diff --git a/src/ElasticApm/Impl/Util/SingletonInstanceTrait.php b/agent/php/ElasticApm/Impl/Util/SingletonInstanceTrait.php similarity index 100% rename from src/ElasticApm/Impl/Util/SingletonInstanceTrait.php rename to agent/php/ElasticApm/Impl/Util/SingletonInstanceTrait.php diff --git a/src/ElasticApm/Impl/Util/StackTraceUtil.php b/agent/php/ElasticApm/Impl/Util/StackTraceUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/StackTraceUtil.php rename to agent/php/ElasticApm/Impl/Util/StackTraceUtil.php diff --git a/src/ElasticApm/Impl/Util/StaticClassTrait.php b/agent/php/ElasticApm/Impl/Util/StaticClassTrait.php similarity index 100% rename from src/ElasticApm/Impl/Util/StaticClassTrait.php rename to agent/php/ElasticApm/Impl/Util/StaticClassTrait.php diff --git a/src/ElasticApm/Impl/Util/TextUtil.php b/agent/php/ElasticApm/Impl/Util/TextUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/TextUtil.php rename to agent/php/ElasticApm/Impl/Util/TextUtil.php diff --git a/src/ElasticApm/Impl/Util/TimeUtil.php b/agent/php/ElasticApm/Impl/Util/TimeUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/TimeUtil.php rename to agent/php/ElasticApm/Impl/Util/TimeUtil.php diff --git a/src/ElasticApm/Impl/Util/UrlParts.php b/agent/php/ElasticApm/Impl/Util/UrlParts.php similarity index 100% rename from src/ElasticApm/Impl/Util/UrlParts.php rename to agent/php/ElasticApm/Impl/Util/UrlParts.php diff --git a/src/ElasticApm/Impl/Util/UrlUtil.php b/agent/php/ElasticApm/Impl/Util/UrlUtil.php similarity index 100% rename from src/ElasticApm/Impl/Util/UrlUtil.php rename to agent/php/ElasticApm/Impl/Util/UrlUtil.php diff --git a/src/ElasticApm/Impl/Util/WildcardListMatcher.php b/agent/php/ElasticApm/Impl/Util/WildcardListMatcher.php similarity index 100% rename from src/ElasticApm/Impl/Util/WildcardListMatcher.php rename to agent/php/ElasticApm/Impl/Util/WildcardListMatcher.php diff --git a/src/ElasticApm/Impl/Util/WildcardMatcher.php b/agent/php/ElasticApm/Impl/Util/WildcardMatcher.php similarity index 100% rename from src/ElasticApm/Impl/Util/WildcardMatcher.php rename to agent/php/ElasticApm/Impl/Util/WildcardMatcher.php diff --git a/src/ElasticApm/SpanContextDbInterface.php b/agent/php/ElasticApm/SpanContextDbInterface.php similarity index 100% rename from src/ElasticApm/SpanContextDbInterface.php rename to agent/php/ElasticApm/SpanContextDbInterface.php diff --git a/src/ElasticApm/SpanContextDestinationInterface.php b/agent/php/ElasticApm/SpanContextDestinationInterface.php similarity index 100% rename from src/ElasticApm/SpanContextDestinationInterface.php rename to agent/php/ElasticApm/SpanContextDestinationInterface.php diff --git a/src/ElasticApm/SpanContextHttpInterface.php b/agent/php/ElasticApm/SpanContextHttpInterface.php similarity index 100% rename from src/ElasticApm/SpanContextHttpInterface.php rename to agent/php/ElasticApm/SpanContextHttpInterface.php diff --git a/src/ElasticApm/SpanContextInterface.php b/agent/php/ElasticApm/SpanContextInterface.php similarity index 100% rename from src/ElasticApm/SpanContextInterface.php rename to agent/php/ElasticApm/SpanContextInterface.php diff --git a/src/ElasticApm/SpanContextServiceInterface.php b/agent/php/ElasticApm/SpanContextServiceInterface.php similarity index 100% rename from src/ElasticApm/SpanContextServiceInterface.php rename to agent/php/ElasticApm/SpanContextServiceInterface.php diff --git a/src/ElasticApm/SpanContextServiceTargetInterface.php b/agent/php/ElasticApm/SpanContextServiceTargetInterface.php similarity index 100% rename from src/ElasticApm/SpanContextServiceTargetInterface.php rename to agent/php/ElasticApm/SpanContextServiceTargetInterface.php diff --git a/src/ElasticApm/SpanInterface.php b/agent/php/ElasticApm/SpanInterface.php similarity index 100% rename from src/ElasticApm/SpanInterface.php rename to agent/php/ElasticApm/SpanInterface.php diff --git a/src/ElasticApm/TransactionBuilderInterface.php b/agent/php/ElasticApm/TransactionBuilderInterface.php similarity index 100% rename from src/ElasticApm/TransactionBuilderInterface.php rename to agent/php/ElasticApm/TransactionBuilderInterface.php diff --git a/src/ElasticApm/TransactionContextInterface.php b/agent/php/ElasticApm/TransactionContextInterface.php similarity index 100% rename from src/ElasticApm/TransactionContextInterface.php rename to agent/php/ElasticApm/TransactionContextInterface.php diff --git a/src/ElasticApm/TransactionContextRequestInterface.php b/agent/php/ElasticApm/TransactionContextRequestInterface.php similarity index 100% rename from src/ElasticApm/TransactionContextRequestInterface.php rename to agent/php/ElasticApm/TransactionContextRequestInterface.php diff --git a/src/ElasticApm/TransactionContextRequestUrlInterface.php b/agent/php/ElasticApm/TransactionContextRequestUrlInterface.php similarity index 100% rename from src/ElasticApm/TransactionContextRequestUrlInterface.php rename to agent/php/ElasticApm/TransactionContextRequestUrlInterface.php diff --git a/src/ElasticApm/TransactionContextUserInterface.php b/agent/php/ElasticApm/TransactionContextUserInterface.php similarity index 100% rename from src/ElasticApm/TransactionContextUserInterface.php rename to agent/php/ElasticApm/TransactionContextUserInterface.php diff --git a/src/ElasticApm/TransactionInterface.php b/agent/php/ElasticApm/TransactionInterface.php similarity index 100% rename from src/ElasticApm/TransactionInterface.php rename to agent/php/ElasticApm/TransactionInterface.php diff --git a/src/bootstrap_php_part.php b/agent/php/bootstrap_php_part.php similarity index 100% rename from src/bootstrap_php_part.php rename to agent/php/bootstrap_php_part.php diff --git a/composer.json b/composer.json index e0b0d1be6..c42409c1c 100644 --- a/composer.json +++ b/composer.json @@ -41,7 +41,7 @@ }, "autoload": { "psr-4": { - "Elastic\\Apm\\": "./src/ElasticApm/" + "Elastic\\Apm\\": "./agent/php/ElasticApm/" } }, "autoload-dev": { @@ -59,25 +59,25 @@ }, "scripts": { "parallel-lint": [ - "parallel-lint ./src/ElasticApm/ ./tests/ --exclude ./tests/polyfills/" + "parallel-lint ./agent/php/ElasticApm/ ./tests/ --exclude ./tests/polyfills/" ], "php_codesniffer_check": [ - "phpcs -s ./src/ElasticApm/", + "phpcs -s ./agent/php/ElasticApm/", "phpcs -s ./tests/", "phpcs -s ./examples/" ], "php_codesniffer_fix": [ - "phpcbf ./src/ElasticApm", + "phpcbf ./agent/php/ElasticApm", "phpcbf ./tests", "phpcbf ./examples/" ], "phpstan-junit-report-for-ci": [ - "phpstan analyse --error-format=junit -c ./phpstan.neon ./src/ElasticApm/ --level max --memory-limit=1G | tee build/elasticapm-phpstan-junit.xml", + "phpstan analyse --error-format=junit -c ./phpstan.neon ./agent/php/ElasticApm/ --level max --memory-limit=1G | tee build/elasticapm-phpstan-junit.xml", "phpstan analyse --error-format=junit -c ./phpstan.neon ./tests/ --level max --memory-limit=1G --error-format=junit | tee build/tests-phpstan-junit.xml", "phpstan analyse --error-format=junit -c ./phpstan.neon ./examples/ --level max --memory-limit=1G --error-format=junit | tee build/examples-phpstan-junit.xml" ], "phpstan": [ - "phpstan analyse -c ./phpstan.neon ./src/ElasticApm/ --level max --memory-limit=1G", + "phpstan analyse -c ./phpstan.neon ./agent/php/ElasticApm/ --level max --memory-limit=1G", "phpstan analyse -c ./phpstan.neon ./tests/ --level max --memory-limit=1G", "phpstan analyse -c ./phpstan.neon ./examples/ --level max --memory-limit=1G" ], diff --git a/demos/shared/install_agent.sh b/demos/shared/install_agent.sh index 2f9b04e10..9957daf08 100644 --- a/demos/shared/install_agent.sh +++ b/demos/shared/install_agent.sh @@ -42,8 +42,8 @@ install_local_package_from_url () { ;; esac - grep PHP_ELASTIC_APM_VERSION "/opt/elastic/apm-agent-php/src/ext/elastic_apm_version.h" - grep VERSION "/opt/elastic/apm-agent-php/src/ElasticApm/ElasticApm.php" + grep PHP_ELASTIC_APM_VERSION "/opt/elastic/apm-agent-php/agent/native/ext/elastic_apm_version.h" + grep VERSION "/opt/elastic/apm-agent-php/agent/php/ElasticApm/ElasticApm.php" } detect_and_install () { diff --git a/packaging/Makefile b/packaging/Makefile index 19e8d157e..481a9c47a 100644 --- a/packaging/Makefile +++ b/packaging/Makefile @@ -2,7 +2,7 @@ SHELL = /bin/bash MAKEFLAGS += --no-print-directory IMAGE:=php-packaging NAME:=apm-agent-php -VERSION?=$(shell grep 'VERSION' ../src/ElasticApm/ElasticApm.php | cut -d= -f2 | tr -d " " | sed "s/'\(.*\)'.*/\1/g") +VERSION?=$(shell grep 'VERSION' ../agent/php/ElasticApm/ElasticApm.php | cut -d= -f2 | tr -d " " | sed "s/'\(.*\)'.*/\1/g") OUTPUT:=build/packages PHP_AGENT_DIR:=/opt/elastic/apm-agent-php PHP_VERSION?=7.2 @@ -89,14 +89,20 @@ rpm-info: ## Show the rpm package metadata .PHONY: tar-info tar-info: ## Show the tar package metadata cd $(PWD) ;\ - BINARY=$$(ls -1 $(OUTPUT)/*.tar) ;\ + BINARY=$$(ls -1 $(OUTPUT)/$(NAME)-linux-x86-64*.tar) ;\ + docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/tar $(IMAGE) -tvf $$BINARY ;\ + BINARY=$$(ls -1 $(OUTPUT)/$(NAME)-debugsymbols-linux-x86-64.tar) ;\ + docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/tar $(IMAGE) -tvf $$BINARY ;\ + BINARY=$$(ls -1 $(OUTPUT)/$(NAME)-linuxmusl-x86-64*.tar) ;\ + docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/tar $(IMAGE) -tvf $$BINARY ;\ + BINARY=$$(ls -1 $(OUTPUT)/$(NAME)-debugsymbols-linuxmusl-x86-64.tar) ;\ docker run --rm -v $(PWD):/app -w /app --entrypoint /usr/bin/tar $(IMAGE) -tvf $$BINARY .PHONY: prepare-apk prepare-apk: ## Build the docker image for the apk smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions cd $(PWD)/packaging/test/alpine ;\ - docker build --build-arg PHP_VERSION=$(PHP_VERSION) --build-arg ADD_LIBUNWIND_DEPENDENCY=${ADD_LIBUNWIND_DEPENDENCY} -t $@ . || exit 1 ;\ + docker build --build-arg PHP_VERSION=$(PHP_VERSION) -t $@ . || exit 1 ;\ cd - @echo "::endgroup::" @@ -141,65 +147,65 @@ prepare-rpm: ## Build the docker image for the rpm smoke tests @echo "::endgroup::" .PHONY: apk-install -apk-install: prepare-apk ## Install the apk installer to run some smoke tests +apk-install: ## Install the apk installer to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - $(PWD)/.ci/run_docker_with_component_tests.sh prepare-apk + $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-apk-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-install -deb-install: prepare-deb ## Install the deb installer to run some smoke tests +deb-install: ## Install the deb installer to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb + TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 .PHONY: tar-install -tar-install: prepare-tar ## Install the tar installer to run some smoke tests +tar-install: ## Install the tar installer to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=tar $(PWD)/.ci/run_docker_with_component_tests.sh prepare-tar + TYPE=tar $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-install -rpm-install: prepare-rpm ## Install the rpm installer to run some smoke tests +rpm-install: ## Install the rpm installer to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + TYPE=rpm $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-install-in-apache -deb-install-in-apache: prepare-deb-apache ## Install the deb installer to run some smoke tests in apache +deb-install-in-apache: ## Install the deb installer to run some smoke tests in apache @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb-apache + TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-install-in-fpm -deb-install-in-fpm: prepare-deb-fpm ## Install the deb installer to run some smoke tests in fpm +deb-install-in-fpm: ## Install the deb installer to run some smoke tests in fpm @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb-fpm + TYPE=deb $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: install install: apk-install deb-install rpm-install tar-install ## Install all the distributions .PHONY: apk-install-release-github -apk-install-release-github: prepare-apk ## Install the apk installer from a given release to run some smoke tests +apk-install-release-github: ## Install the apk installer from a given release to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh prepare-apk + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-apk-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-install-release-github -deb-install-release-github: prepare-deb ## Install the deb installer from a given release to run some smoke tests +deb-install-release-github: ## Install the deb installer from a given release to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-install-release-github -rpm-install-release-github: prepare-rpm ## Install the rpm installer from a given release to run some smoke tests +rpm-install-release-github: ## Install the rpm installer from a given release to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=release-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: tar-install-release-github -tar-install-release-github: prepare-tar ## Install the tar installer from a given release to run some smoke tests +tar-install-release-github: ## Install the tar installer from a given release to run some smoke tests @echo "::group::$@" # Helping to group logs in GitHub actions - GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) VERSION=$(RELEASE_VERSION) TYPE=release-tar-github $(PWD)/.ci/run_docker_with_component_tests.sh prepare-tar + GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) VERSION=$(RELEASE_VERSION) TYPE=release-tar-github $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: install-release-github @@ -209,68 +215,70 @@ install-release-github: apk-install-release-github deb-install-release-github rp lifecycle-testing: apk-lifecycle-testing deb-lifecycle-testing rpm-lifecycle-testing tar-lifecycle-testing ## Lifecycle testing all the distributions .PHONY: apk-lifecycle-testing -apk-lifecycle-testing: prepare-apk ## Lifecycle testing for the apk installer +apk-lifecycle-testing: ## Lifecycle testing for the apk installer @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=apk-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-apk + TYPE=apk-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-apk-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-lifecycle-testing -deb-lifecycle-testing: prepare-deb ## Lifecycle testing for the deb installer +deb-lifecycle-testing: ## Lifecycle testing for the deb installer @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb + TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-lifecycle-testing-in-apache -deb-lifecycle-testing-in-apache: prepare-deb-apache ## Lifecycle testing for the deb installer with apache +deb-lifecycle-testing-in-apache: ## Lifecycle testing for the deb installer with apache @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb-apache + TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-lifecycle-testing-in-fpm -deb-lifecycle-testing-in-fpm: prepare-deb-fpm ## Lifecycle testing for the deb installer with fpm +deb-lifecycle-testing-in-fpm: ## Lifecycle testing for the deb installer with fpm @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb-fpm + TYPE=deb-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-lifecycle-testing -rpm-lifecycle-testing: prepare-rpm ## Lifecycle testing for the rpm installer +rpm-lifecycle-testing: ## Lifecycle testing for the rpm installer @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=rpm-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + TYPE=rpm-uninstall PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: tar-lifecycle-testing -tar-lifecycle-testing: prepare-tar ## Lifecycle testing for the tar installer +tar-lifecycle-testing: ## Lifecycle testing for the tar installer @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=tar-uninstall $(PWD)/.ci/run_docker_with_component_tests.sh prepare-tar + TYPE=tar-uninstall $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-php-upgrade-testing -rpm-php-upgrade-testing: PHP_VERSION="7.2" ### Force the PHP version to start with. -rpm-php-upgrade-testing: prepare-rpm ## PHP upgrade, from 7.2 to 7.4, testing for the rpm installer +### Force the PHP version to start with. +rpm-php-upgrade-testing: PHP_VERSION=7.2 +rpm-php-upgrade-testing: ## PHP upgrade, from 7.2 to 7.4, testing for the rpm installer @echo "::group::$@" # Helping to group logs in GitHub actions - TYPE=php-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + echo "'$(PHP_VERSION)'" + TYPE=php-upgrade PHP_VERSION=$(PHP_VERSION) PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-agent-upgrade-testing -rpm-agent-upgrade-testing: prepare-rpm ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer +rpm-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-agent-upgrade-testing -deb-agent-upgrade-testing: prepare-deb ## Agent upgrade, from 1.0.0 to the current generated one, testing for the deb installer +deb-agent-upgrade-testing: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the deb installer @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: rpm-agent-upgrade-testing-local -rpm-agent-upgrade-testing-local: prepare-rpm ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer +rpm-agent-upgrade-testing-local: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the rpm installer @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-rpm + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-rpm-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" .PHONY: deb-agent-upgrade-testing-local -deb-agent-upgrade-testing-local: prepare-deb ## Agent upgrade, from 1.0.0 to the current generated one, testing for the deb installer +deb-agent-upgrade-testing-local: ## Agent upgrade, from 1.0.0 to the current generated one, testing for the deb installer @echo "::group::$@" # Helping to group logs in GitHub actions - VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh prepare-deb + VERSION=$(RELEASE_VERSION) GITHUB_RELEASES_URL=$(GITHUB_RELEASES_URL) TYPE=agent-upgrade-local PACKAGE=$(NAME) $(PWD)/.ci/run_docker_with_component_tests.sh elasticobservability/apm-agent-php-dev:packages-test-deb-php-$(PHP_VERSION)-0.0.1 @echo "::endgroup::" diff --git a/packaging/before-uninstall.sh b/packaging/before-uninstall.sh index 621b6c333..21f365a6f 100755 --- a/packaging/before-uninstall.sh +++ b/packaging/before-uninstall.sh @@ -103,9 +103,9 @@ function remove_extension_configuration_to_file() { function get_extension_filename() { PHP_API=$(php_api) ## If alpine then add another suffix - if grep -q -i alpine /etc/os-release; then - SUFFIX=-alpine - fi +# if grep -q -i alpine /etc/os-release; then +# SUFFIX=-alpine +# fi echo "elastic_apm-${PHP_API}${SUFFIX}.so" } diff --git a/packaging/create-package.sh b/packaging/create-package.sh index 3aca60a7b..cc40af01d 100755 --- a/packaging/create-package.sh +++ b/packaging/create-package.sh @@ -5,36 +5,22 @@ set -x ## - If alpine then use only alpine so files ## - If deb/rpm then skip alpine so files ## - If tar then use all the so files -BUILD_EXT_DIR=build/ext/modules/ -mkdir -p ${BUILD_EXT_DIR} -cp -rf src/ext/modules/*.so ${BUILD_EXT_DIR} -if [ "${TYPE}" = 'apk' ] ; then - find ${BUILD_EXT_DIR} -type f -name '*.so' ! -name '*-alpine.so' -delete -elif [ "${TYPE}" = 'deb' ] || [ "${TYPE}" = 'rpm' ] ; then - find ${BUILD_EXT_DIR} -type f -name '*-alpine.so' -delete -fi -## src/ext files to be archived in the package -BUILD_SRC_EXT_DIR=build/src -IGNORE_FILE=${BUILD_SRC_EXT_DIR}/ext/.gitignore -mkdir -p ${BUILD_SRC_EXT_DIR} -cp -rf src/ext ${BUILD_SRC_EXT_DIR} -if [ -e ${IGNORE_FILE} ] ; then - while IFS= read -r line - do - if [ -n "$line" ]; then - if case $line in "#"*) false;; *) true;; esac; then - # shellcheck disable=SC2086 - rm -rf ${BUILD_SRC_EXT_DIR}/ext/${line} || true - fi - fi - done < "${IGNORE_FILE}" - rm ${IGNORE_FILE} || true +BUILD_EXT_DIR="" + +if [ "${TYPE}" = 'apk' ] ; then + BUILD_EXT_DIR=agent/native/_build/linuxmusl-x86-64-release/ext/ +else + BUILD_EXT_DIR=agent/native/_build/linux-x86-64-release/ext/ fi touch build/elastic-apm.ini -## Create package +function createPackage () { + +mkdir -p /tmp/extensions +cp ${BUILD_EXT_DIR}/*.so /tmp/extensions/ + fpm --input-type dir \ --output-type "${TYPE}" \ --name "${NAME}" \ @@ -46,24 +32,80 @@ fpm --input-type dir \ --vendor 'Elasticsearch, Inc.' \ --description "PHP agent for Elastic APM\nGit Commit: ${GIT_SHA}" \ --package "${OUTPUT}" \ - --chdir /app ${FPM_FLAGS} \ + ${FPM_FLAGS} \ --after-install=packaging/post-install.sh \ --before-remove=packaging/before-uninstall.sh \ --directories ${PHP_AGENT_DIR}/etc \ --config-files ${PHP_AGENT_DIR}/etc \ - packaging/post-install.sh=${PHP_AGENT_DIR}/bin/post-install.sh \ - build/elastic-apm.ini=${PHP_AGENT_DIR}/etc/ \ - packaging/elastic-apm-custom-template.ini=${PHP_AGENT_DIR}/etc/elastic-apm-custom.ini \ - packaging/before-uninstall.sh=${PHP_AGENT_DIR}/bin/before-uninstall.sh \ - ${BUILD_SRC_EXT_DIR}=${PHP_AGENT_DIR} \ - ${BUILD_EXT_DIR}=${PHP_AGENT_DIR}/extensions \ - README.md=${PHP_AGENT_DIR}/docs/README.md \ - src/ElasticApm=${PHP_AGENT_DIR}/src \ - src/bootstrap_php_part.php=${PHP_AGENT_DIR}/src/bootstrap_php_part.php + /app/packaging/post-install.sh=${PHP_AGENT_DIR}/bin/post-install.sh \ + /app/build/elastic-apm.ini=${PHP_AGENT_DIR}/etc/ \ + /app/packaging/elastic-apm-custom-template.ini=${PHP_AGENT_DIR}/etc/elastic-apm-custom.ini \ + /app/packaging/before-uninstall.sh=${PHP_AGENT_DIR}/bin/before-uninstall.sh \ + /app/agent/php/=${PHP_AGENT_DIR}/src \ + /tmp/extensions/=${PHP_AGENT_DIR}/extensions \ + /app/README.md=${PHP_AGENT_DIR}/docs/README.md + +rm -rf /tmp/extensions ## Create sha512 -BINARY=$(ls -1 "${OUTPUT}"/*."${TYPE}") +BINARY=$(ls -1 "${OUTPUT}"/${NAME}*."${TYPE}") SHA=${BINARY}.sha512 sha512sum "${BINARY}" > "${SHA}" sed -i.bck "s#${OUTPUT}/##g" "${SHA}" rm "${OUTPUT}"/*.bck + +} + + +function createDebugPackage () { + +mkdir -p /tmp/extensions +cp ${BUILD_EXT_DIR}/*.debug /tmp/extensions/ + +fpm --input-type dir \ + --output-type "${TYPE}" \ + --name "${NAME}" \ + --version "${VERSION}" \ + --architecture all \ + --url 'https://github.com/elastic/apm-agent-php' \ + --maintainer 'APM Team ' \ + --license 'ASL 2.0' \ + --vendor 'Elasticsearch, Inc.' \ + --description "PHP debug symbols agent for Elastic APM\nGit Commit: ${GIT_SHA}" \ + --package "${OUTPUT}" \ + ${FPM_FLAGS} \ + /tmp/extensions/=${PHP_AGENT_DIR}/extensions + +rm -rf /tmp/extensions + +## Create sha512 +BINARY=$(ls -1 "${OUTPUT}"/${NAME}*."${TYPE}") +SHA=${BINARY}.sha512 +sha512sum "${BINARY}" > "${SHA}" +sed -i.bck "s#${OUTPUT}/##g" "${SHA}" +rm "${OUTPUT}"/*.bck + +} + + + + +# create second tar for musl +if [ "${TYPE}" = 'tar' ] ; then + NAME_BACKUP=${NAME} + NAME="${NAME_BACKUP}-linux-x86-64" + BUILD_EXT_DIR=agent/native/_build/linux-x86-64-release/ext/ + createPackage + + NAME="${NAME_BACKUP}-debugsymbols-linux-x86-64" + createDebugPackage + + NAME="${NAME_BACKUP}-linuxmusl-x86-64" + BUILD_EXT_DIR=agent/native/_build/linuxmusl-x86-64-release/ext/ + createPackage + + NAME="${NAME_BACKUP}-debugsymbols-linuxmusl-x86-64" + createDebugPackage +else + createPackage +fi \ No newline at end of file diff --git a/packaging/post-install.sh b/packaging/post-install.sh index 2b96f9b8c..460475570 100755 --- a/packaging/post-install.sh +++ b/packaging/post-install.sh @@ -186,9 +186,9 @@ function agent_extension_not_supported() { function get_extension_file() { PHP_API=$(php_api) ## If alpine then add another suffix - if grep -q -i alpine /etc/os-release; then - SUFFIX=-alpine - fi +# if grep -q -i alpine /etc/os-release; then +# SUFFIX=-alpine +# fi echo "${EXTENSION_DIR}/elastic_apm-${PHP_API}${SUFFIX}.so" } diff --git a/packaging/test/alpine/Dockerfile b/packaging/test/alpine/Dockerfile index 071b2497d..c7163048c 100644 --- a/packaging/test/alpine/Dockerfile +++ b/packaging/test/alpine/Dockerfile @@ -14,9 +14,6 @@ RUN apk update \ unzip \ wget -ARG ADD_LIBUNWIND_DEPENDENCY=false -RUN if [[ "${ADD_LIBUNWIND_DEPENDENCY}" = "true" ]] ; then apk add libunwind; fi - RUN docker-php-ext-install \ mysqli \ pcntl \ diff --git a/packaging/test/centos/entrypoint.sh b/packaging/test/centos/entrypoint.sh index dbb4684d0..ff6d96c70 100755 --- a/packaging/test/centos/entrypoint.sh +++ b/packaging/test/centos/entrypoint.sh @@ -64,7 +64,7 @@ elif [ "${TYPE}" == "release-github" ] ; then download "${PACKAGE}" "${BUILD_RELEASES_FOLDER}" "${GITHUB_RELEASES_URL}/v${VERSION}" rpm -ivh "${BUILD_RELEASES_FOLDER}/${PACKAGE}" elif [ "${TYPE}" == "release-tar-github" ] ; then - PACKAGE=apm-agent-php.tar + PACKAGE=apm-agent-php-linux-x86-64.tar download "${PACKAGE}" "${BUILD_RELEASES_FOLDER}" "${GITHUB_RELEASES_URL}/v${VERSION}" ## Install tar package and configure the agent accordingly tar -xf ${BUILD_RELEASES_FOLDER}/${PACKAGE} -C / @@ -79,7 +79,7 @@ elif [ "${TYPE}" == "agent-upgrade-local" ] ; then rpm -ivh build/local/*.rpm else ## Install tar package and configure the agent accordingly - tar -xf $BUILD_PACKAGES/*.tar -C / + tar -xf $BUILD_PACKAGES/apm-agent-php-linux-x86-64.tar -C / # shellcheck disable=SC1091 source /opt/elastic/apm-agent-php/bin/post-install.sh fi diff --git a/packaging/test/docker-compose.yml b/packaging/test/docker-compose.yml new file mode 100644 index 000000000..4af448e02 --- /dev/null +++ b/packaging/test/docker-compose.yml @@ -0,0 +1,220 @@ +version: "3" +services: + deb-fpm-php82: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-8.2-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=8.2 + deb-fpm-php81: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-8.1-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=8.1 + deb-fpm-php80: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-8.0-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=8.0 + deb-fpm-php74: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-7.4-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=7.4 + deb-fpm-php73: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-7.3-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=7.3 + deb-fpm-php72: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-fpm-php-7.2-0.0.1 + build: + context: ubuntu + dockerfile: fpm/Dockerfile + args: + - PHP_VERSION=7.2 + + + + + deb-apache-php82: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-8.2-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=8.2 + deb-apache-php81: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-8.1-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=8.1 + deb-apache-php80: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-8.0-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=8.0 + deb-apache-php74: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-7.4-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=7.4 + deb-apache-php73: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-7.3-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=7.3 + deb-apache-php72: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-apache-php-7.2-0.0.1 + build: + context: ubuntu + dockerfile: apache/Dockerfile + args: + - PHP_VERSION=7.2 + + + deb-php82: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-8.2-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=8.2 + deb-php81: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-8.1-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=8.1 + deb-php80: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-8.0-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=8.0 + deb-php74: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-7.4-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=7.4 + deb-php73: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-7.3-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=7.3 + deb-php72: + image: elasticobservability/apm-agent-php-dev:packages-test-deb-php-7.2-0.0.1 + build: + context: ubuntu + dockerfile: Dockerfile + args: + - PHP_VERSION=7.2 + + rpm-php82: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.2-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=8.2 + rpm-php81: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.1-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=8.1 + rpm-php80: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-8.0-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=8.0 + rpm-php74: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.4-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=7.4 + rpm-php73: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.3-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=7.3 + rpm-php72: + image: elasticobservability/apm-agent-php-dev:packages-test-rpm-php-7.2-0.0.1 + build: + context: centos + dockerfile: Dockerfile + args: + - PHP_VERSION=7.2 + + apk-php82: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-8.2-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=8.2 + apk-php81: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-8.1-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=8.1 + apk-php80: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-8.0-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=8.0 + apk-php74: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-7.4-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=7.4 + apk-php73: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-7.3-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=7.3 + apk-php72: + image: elasticobservability/apm-agent-php-dev:packages-test-apk-php-7.2-0.0.1 + build: + context: alpine + dockerfile: Dockerfile + args: + - PHP_VERSION=7.2 diff --git a/packaging/test/ubuntu/entrypoint.sh b/packaging/test/ubuntu/entrypoint.sh index 699a1becd..7809ae404 100755 --- a/packaging/test/ubuntu/entrypoint.sh +++ b/packaging/test/ubuntu/entrypoint.sh @@ -64,7 +64,7 @@ elif [ "${TYPE}" == "release-github" ] ; then dpkg-sig --verify "${BUILD_RELEASES_FOLDER}/${PACKAGE}" dpkg -i "${BUILD_RELEASES_FOLDER}/${PACKAGE}" elif [ "${TYPE}" == "release-tar-github" ] ; then - PACKAGE=apm-agent-php.tar + PACKAGE=apm-agent-php-linux-x86-64.tar download "${PACKAGE}" "${BUILD_RELEASES_FOLDER}" "${GITHUB_RELEASES_URL}/v${VERSION}" ## Install tar package and configure the agent accordingly tar -xf ${BUILD_RELEASES_FOLDER}/${PACKAGE} -C / @@ -78,7 +78,7 @@ elif [ "${TYPE}" == "agent-upgrade-local" ] ; then dpkg -i build/local/*.deb else ## Install tar package and configure the agent accordingly - tar -xf $BUILD_PACKAGES/*.tar -C / + tar -xf $BUILD_PACKAGES/apm-agent-php-linux-x86-64.tar -C / ls -ltrah /opt/elastic/apm-agent-php/bin # shellcheck disable=SC1091 source /opt/elastic/apm-agent-php/bin/post-install.sh diff --git a/src/ext/sample_prof.c b/src/ext/sample_prof.c deleted file mode 100644 index 20ea2c3ca..000000000 --- a/src/ext/sample_prof.c +++ /dev/null @@ -1,227 +0,0 @@ -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#include "php.h" -#include "php_ini.h" -#include "ext/standard/info.h" -#include "php_sample_prof.h" -#include "zend_exceptions.h" -#include "sample_prof_arginfo.h" - -#include - -#define SAMPLE_PROF_DEFAULT_INTERVAL 1 - -/* On 64-bit this will give a 16 * 1MB allocation */ -#define SAMPLE_PROF_DEFAULT_ALLOC (1 << 20) - -ZEND_DECLARE_MODULE_GLOBALS(sample_prof) - -static inline zend_bool sample_prof_end() { - if (!SAMPLE_PROF_G->enabled) { - return 0; - } - - pthread_cancel(SAMPLE_PROF_G->thread_id); - - SAMPLE_PROF_G->enabled = 0; - return 1; -} - -static void *sample_prof_handler(void *data) { - zend_sample_prof_globals *g = SAMPLE_PROF_G; - -#ifdef ZTS - volatile zend_executor_globals *eg = TSRMG_BULK(executor_globals_id, zend_executor_globals *); -#else - volatile zend_executor_globals *eg = &executor_globals; -#endif - - retry_now: - while (1) { - volatile zend_execute_data *ex = eg->current_execute_data, *start_ex = ex; - zend_function *func; - const zend_op *opline; - - while (1) { - zend_execute_data *prev; - - /* We're not executing code right now, try again later */ - if (!ex) { - goto retry_later; - } - - func = ex->func; - opline = ex->opline; - prev = ex->prev_execute_data; - - /* current_execute_data changed in the meantime, reload it */ - if (eg->current_execute_data != start_ex) { - goto retry_now; - } - - if (func && ZEND_USER_CODE(func->type)) { - break; - } - - ex = prev; - } - - if (!opline) { - goto retry_later; - } - - g->entries[g->entries_num].filename = func->op_array.filename; - g->entries[g->entries_num].lineno = opline->lineno; - - if (++g->entries_num == g->entries_allocated) { - /* Doing a realloc within a signal handler is unsafe, end profiling */ - g->enabled = 0; - break; - } - - retry_later: - usleep(g->interval_usec); - } - pthread_exit(NULL); -} - -static void sample_prof_start(long interval_usec, size_t num_entries_alloc) { - zend_sample_prof_globals *g = SAMPLE_PROF_G; - - /* Initialize data structures for entries */ - if (g->entries) { - efree(g->entries); - } - - g->interval_usec = interval_usec; - g->entries_allocated = num_entries_alloc; - g->entries_num = 0; - g->entries = safe_emalloc(g->entries_allocated, sizeof(sample_prof_entry), 0); - - /* Register signal handler */ - if (pthread_create(&g->thread_id, NULL, sample_prof_handler, NULL)) { - zend_throw_exception(NULL, "Could not register signal handler", 0); - return; - } - - g->enabled = 1; -} - -PHP_FUNCTION(sample_prof_start) { - zend_long interval_usec = 0; - zend_long num_entries_alloc = 0; - - if (zend_parse_parameters(ZEND_NUM_ARGS(), "|ll", &interval_usec, &num_entries_alloc) == FAILURE) { - return; - } - - if (interval_usec < 0) { - zend_throw_exception(NULL, "Number of microseconds can't be negative", 0); - return; - } else if (interval_usec == 0) { - interval_usec = SAMPLE_PROF_DEFAULT_INTERVAL; - } - - if (num_entries_alloc < 0) { - zend_throw_exception(NULL, "Number of profiling can't be negative", 0); - return; - } else if (num_entries_alloc == 0) { - num_entries_alloc = SAMPLE_PROF_DEFAULT_ALLOC; - } - - sample_prof_start(interval_usec, num_entries_alloc); -} - -PHP_FUNCTION(sample_prof_end) { - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - RETURN_BOOL(sample_prof_end()); -} - -PHP_FUNCTION(sample_prof_get_data) { - zend_sample_prof_globals *g = SAMPLE_PROF_G; - size_t entry_num; - - if (zend_parse_parameters_none() == FAILURE) { - return; - } - - array_init(return_value); - - for (entry_num = 0; entry_num < g->entries_num; ++entry_num) { - sample_prof_entry *entry = &g->entries[entry_num]; - zend_string *filename = entry->filename; - uint32_t lineno = entry->lineno; - zval *lines, *num; - - lines = zend_hash_find(Z_ARR_P(return_value), filename); - if (lines == NULL) { - zval lines_zv; - array_init(&lines_zv); - lines = zend_hash_update(Z_ARR_P(return_value), filename, &lines_zv); - } - - num = zend_hash_index_find(Z_ARR_P(lines), lineno); - if (num == NULL) { - zval num_zv; - ZVAL_LONG(&num_zv, 0); - num = zend_hash_index_update(Z_ARR_P(lines), lineno, &num_zv); - } - - increment_function(num); - } -} - -PHP_RINIT_FUNCTION(sample_prof) - { - SAMPLE_PROF_G->enabled = 0; - SAMPLE_PROF_G->entries = NULL; - SAMPLE_PROF_G->entries_num = 0; - - return SUCCESS; - } - -PHP_RSHUTDOWN_FUNCTION(sample_prof) - { - sample_prof_end(); - if (SAMPLE_PROF_G->entries) { - efree(SAMPLE_PROF_G->entries); - } - - return SUCCESS; - } - -PHP_MINFO_FUNCTION(sample_prof) - { - php_info_print_table_start(); - php_info_print_table_header(2, "sample_prof support", "enabled"); - php_info_print_table_end(); - } - -const zend_function_entry sample_prof_functions[] = { - PHP_FE(sample_prof_start, arginfo_sample_prof_start) - PHP_FE(sample_prof_end, arginfo_sample_prof_end) - PHP_FE(sample_prof_get_data, arginfo_sample_prof_get_data) - PHP_FE_END -}; - -zend_module_entry sample_prof_module_entry = { - STANDARD_MODULE_HEADER, - "sample_prof", - sample_prof_functions, - NULL, - NULL, - PHP_RINIT(sample_prof), - PHP_RSHUTDOWN(sample_prof), - PHP_MINFO(sample_prof), - PHP_SAMPLE_PROF_VERSION, - PHP_MODULE_GLOBALS(sample_prof), - NULL, - NULL, - NULL, - STANDARD_MODULE_PROPERTIES_EX -};