Skip to content
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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -198,3 +198,6 @@ tests/appsec/iast/fixtures/taint_sinks/not_exists.txt

*.debug
*.dSYM/

# Rust build artifacts
src/native/target*
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ message(WARNING "LIBRARY_NAME: ${LIBRARY_NAME}")

# We expect the native extension to be built and installed the headers in the following directory. It is configured in
# setup.py by setting CARGO_TARGET_DIR environment variable.
set(SOURCE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/../../../../../src/native/target/include)
set(SOURCE_INCLUDE_DIR
${CMAKE_SOURCE_DIR}/../../../../../src/native/target${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/include)

set(DEST_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR})
set(DEST_INCLUDE_DIR ${DEST_LIB_DIR}/include)
Expand Down
7 changes: 5 additions & 2 deletions ddtrace/internal/datadog/profiling/ddup/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,11 @@ if(APPLE)
elseif(UNIX)
set_target_properties(${EXTENSION_NAME} PROPERTIES INSTALL_RPATH "$ORIGIN/..")
endif()
target_include_directories(${EXTENSION_NAME} PRIVATE ../dd_wrapper/include ../../../../../src/native/target/include/
${Datadog_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS})
target_include_directories(
${EXTENSION_NAME}
PRIVATE ../dd_wrapper/include
../../../../../src/native/target${Python3_VERSION_MAJOR}.${Python3_VERSION_MINOR}/include/
${Datadog_INCLUDE_DIRS} ${Python3_INCLUDE_DIRS})

target_link_libraries(${EXTENSION_NAME} PRIVATE dd_wrapper)

Expand Down
12 changes: 7 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@
DDUP_DIR = HERE / "ddtrace" / "internal" / "datadog" / "profiling" / "ddup"
STACK_V2_DIR = HERE / "ddtrace" / "internal" / "datadog" / "profiling" / "stack_v2"
NATIVE_CRATE = HERE / "src" / "native"
CARGO_TARGET_DIR = NATIVE_CRATE.absolute() / f"target{sys.version_info.major}.{sys.version_info.minor}"

BUILD_PROFILING_NATIVE_TESTS = os.getenv("DD_PROFILING_NATIVE_TESTS", "0").lower() in ("1", "yes", "on", "true")

Expand Down Expand Up @@ -208,7 +209,7 @@ def __init__(self, attrs=None):
# but at the same time dropped support for Python 3.8. So we'd need to
# make sure that this env var is set to install the ffi headers in the
# right place.
os.environ["CARGO_TARGET_DIR"] = str(NATIVE_CRATE.absolute() / "target")
os.environ["CARGO_TARGET_DIR"] = str(CARGO_TARGET_DIR)
self.rust_extensions = [
RustExtension(
# The Python import path of your extension:
Expand All @@ -235,7 +236,9 @@ def run(self):
sources = [
_
for _ in source_path.glob("**/*")
if _.is_file() and _.relative_to(source_path).parts[0] != "target"
if _.is_file()
and _.relative_to(source_path).parts[0]
!= f"target{sys.version_info.major}.{sys.version_info.minor}"
]
else:
sources = [Path(_) for _ in ext.sources]
Expand Down Expand Up @@ -318,7 +321,7 @@ def run(self):
dedup_env["PATH"] = cargo_bin + os.pathsep + os.environ["PATH"]

# Run dedup_headers on the generated headers
include_dir = NATIVE_CRATE.absolute() / "target" / "include" / "datadog"
include_dir = CARGO_TARGET_DIR / "include" / "datadog"
if include_dir.exists():
subprocess.run(
["dedup_headers", "common.h", "profiling.h"],
Expand Down Expand Up @@ -499,8 +502,7 @@ def remove_artifacts():
@staticmethod
def remove_rust():
"""Clean the Rust crate using cargo clean."""
target_dir = NATIVE_CRATE / "target"
if target_dir.exists():
if CARGO_TARGET_DIR.exists():
subprocess.run(
["cargo", "clean"],
cwd=str(NATIVE_CRATE),
Expand Down
Loading