Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the root Makefile macOS compatible #2614

Merged
merged 2 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 11 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ INIT_HOOK_TEST_FILES = $(shell find tests/C2PHP -name '*.phpt' -o -name '*.inc'
M4_FILES = $(shell find m4 -name '*.m4*' | awk '{ printf "$(BUILD_DIR)/%s\n", $$1 }' ) $(BUILD_DIR)/config.m4
XDEBUG_SO_FILE = $(shell find $(shell php-config --extension-dir) -type f -name "xdebug*.so" -exec basename {} \; | tail -n 1)

# Make 'sed -i' portable
ifeq ($(shell uname),Darwin)
SED_I = sed -i ''
else
SED_I = sed -i
endif

all: $(BUILD_DIR)/configure $(SO_FILE)

# The following differentiation exists so we can build only (but always) the relevant files while executing tests
Expand All @@ -67,13 +74,13 @@ $(BUILD_DIR)/%Cargo.toml: %Cargo.toml
$(Q) echo Copying $*Cargo.toml to $@
$(Q) mkdir -p $(dir $@)
$(Q) cp -a $*Cargo.toml $@
sed -i -E 's/"\.\.\/([^"]*)"/"..\/..\/..\/\1"/' $@
$(SED_I) -E 's/"\.\.\/([^"]*)"/"..\/..\/..\/\1"/' $@

$(BUILD_DIR)/Cargo.toml: Cargo.toml
$(Q) echo Copying Cargo.toml to $@
$(Q) mkdir -p $(dir $@)
$(Q) cp -a Cargo.toml $@
sed -i -E 's/, "profiling",?//' $@
$(SED_I) -E 's/, "profiling",?//' $@

$(BUILD_DIR)/%: %
$(Q) echo Copying $* to $@
Expand All @@ -86,7 +93,7 @@ JUNIT_RESULTS_DIR := $(shell pwd)
all: $(BUILD_DIR)/configure $(SO_FILE)

$(BUILD_DIR)/configure: $(M4_FILES) $(BUILD_DIR)/ddtrace.sym $(BUILD_DIR)/VERSION
$(Q) (cd $(BUILD_DIR); phpize && sed -i 's/\/FAILED/\/\\bFAILED/' $(BUILD_DIR)/run-tests.php) # Fix PHP 5.4 exit code bug when running selected tests (FAILED vs XFAILED)
$(Q) (cd $(BUILD_DIR); phpize && $(SED_I) 's/\/FAILED/\/\\bFAILED/' $(BUILD_DIR)/run-tests.php) # Fix PHP 5.4 exit code bug when running selected tests (FAILED vs XFAILED)

$(BUILD_DIR)/Makefile: $(BUILD_DIR)/configure
$(Q) (cd $(BUILD_DIR); ./configure --$(if $(RUST_DEBUG_BUILD),enable,disable)-ddtrace-rust-debug)
Expand Down Expand Up @@ -289,7 +296,7 @@ test_coverage_collect:
--exclude "$(BUILD_DIR)/src/dogstatsd/*" \
--exclude "$(BUILD_DIR)/src/dogstatsd/dogstatsd_client/*" \
--output-file $(PROJECT_ROOT)/tmp/coverage.info
$(Q) sed -i 's+tmp/build_extension/ext+ext+g' $(PROJECT_ROOT)/tmp/coverage.info
$(Q) $(SED_I) 's+tmp/build_extension/ext+ext+g' $(PROJECT_ROOT)/tmp/coverage.info

test_coverage_output:
$(Q) genhtml \
Expand Down
1 change: 1 addition & 0 deletions components-rs/php_sidecar_mockgen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ version = "0.1.0"

[dependencies]
cc_utils = { path = "../../libdatadog/tools/cc_utils" }
current_platform = "0.2.0"
sidecar_mockgen = { path = "../../libdatadog/tools/sidecar_mockgen" }

[[bin]]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,22 @@ fn main() {
if fs::metadata("mock_php.shared_lib").map_or(true, |m| m.modified().unwrap() < source_modified) {
env::set_var("OPT_LEVEL", "2");

let mut cc_build = cc::Build::new();

// The 'host' and 'target' options are required to compile.
// They can be provided using the HOST and TARGET environment variables.
// On Linux, these environment variables can be empty strings, but it's not the case on macOS.
let host = std::env::var("HOST").unwrap_or("".to_string());
if host == "" {
cc_build.host(current_platform::CURRENT_PLATFORM);
}
let target = std::env::var("TARGET").unwrap_or("".to_string());
if target == "" {
cc_build.target(current_platform::CURRENT_PLATFORM);
}

cc_utils::ImprovedBuild::new()
.set_cc_builder(cc_build)
.file("mock_php_syms.c")
.link_dynamically("dl")
.warnings(true)
Expand Down
Loading