Skip to content

Commit

Permalink
Make the pwsh script work
Browse files Browse the repository at this point in the history
  • Loading branch information
gleocadie committed Oct 28, 2024
1 parent c27aad9 commit c2e963d
Show file tree
Hide file tree
Showing 7 changed files with 86 additions and 46 deletions.
4 changes: 4 additions & 0 deletions builder/build/arch/apple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use std::process::Command;

use std::ffi::OsStr;

pub const NATIVE_LIBS: &str =
" -framework Security -framework CoreFoundation -liconv -lSystem -lresolv -lc -lm -liconv";
pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.dylib";
Expand Down Expand Up @@ -38,3 +40,5 @@ pub fn strip_libraries(lib_path: &str) {
}

pub fn fix_soname(_lib_path: &str) {}

pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}
4 changes: 4 additions & 0 deletions builder/build/arch/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use std::process::Command;

use std::ffi::OsStr;

pub const NATIVE_LIBS: &str = " -ldl -lrt -lpthread -lc -lm -lrt -lpthread -lutil -ldl -lutil";
pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.so";
pub const PROF_STATIC_LIB: &str = "libdatadog_profiling.a";
Expand Down Expand Up @@ -68,3 +70,5 @@ pub fn fix_soname(lib_path: &str) {

patch_soname.wait().expect("failed to change the soname");
}

pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}
4 changes: 4 additions & 0 deletions builder/build/arch/musl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@

use std::process::Command;

use std::ffi::OsStr;

pub const NATIVE_LIBS: &str = " -lssp_nonshared -lc";
pub const PROF_DYNAMIC_LIB: &str = "libdatadog_profiling.so";
pub const PROF_STATIC_LIB: &str = "libdatadog_profiling.a";
Expand Down Expand Up @@ -67,3 +69,5 @@ pub fn fix_soname(lib_path: &str) {

patch_soname.wait().expect("failed to change the soname");
}

pub fn add_additional_files(_lib_path: &str, _target_path: &OsStr) {}
13 changes: 13 additions & 0 deletions builder/build/arch/windows.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
// Copyright 2024-Present Datadog, Inc. https://www.datadoghq.com/
// SPDX-License-Identifier: Apache-2.0

use std::ffi::OsStr;
use std::fs;
use std::path::PathBuf;

pub const NATIVE_LIBS: &str = "";
pub const PROF_DYNAMIC_LIB: &str = "datadog_profiling.dll";
pub const PROF_STATIC_LIB: &str = "datadog_profiling.lib";
pub const PROF_PDB: &str = "datadog_profiling.pdb";
pub const PROF_DYNAMIC_LIB_FFI: &str = "datadog_profiling_ffi.dll";
pub const PROF_STATIC_LIB_FFI: &str = "datadog_profiling_ffi.lib";
pub const PROF_PDB_FFI: &str = "datadog_profiling_ffi.pdb";
pub const REMOVE_RPATH: bool = false;
pub const BUILD_CRASHTRACKER: bool = false;

pub fn fix_rpath(_lib_path: &str) {}
pub fn strip_libraries(_lib_path: &str) {}
pub fn fix_soname(_lib_path: &str) {}

pub fn add_additional_files(lib_path: &str, target_path: &OsStr) {
let from_pdb: PathBuf = [lib_path, PROF_PDB_FFI].iter().collect();
let to_pdb: PathBuf = [target_path, OsStr::new(PROF_PDB)].iter().collect();

fs::copy(from_pdb, to_pdb).expect("unable to copy pdb file");
}
3 changes: 2 additions & 1 deletion builder/build/profiling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ impl Profiling {
let to_dyn: PathBuf = [lib_dir.as_os_str(), OsStr::new(arch::PROF_DYNAMIC_LIB)]
.iter()
.collect();

fs::copy(from_dyn, to_dyn).expect("unable to copy dynamic lib");

let from_static: PathBuf = [&self.source_lib, arch::PROF_STATIC_LIB_FFI]
Expand All @@ -61,6 +60,8 @@ impl Profiling {
.collect();
fs::copy(from_static, to_static).expect("unable to copy static lib");

arch::add_additional_files(&self.source_lib, lib_dir.as_os_str());

arch::fix_soname(&self.target_lib);

// Generate debug information
Expand Down
43 changes: 26 additions & 17 deletions windows/build-artifacts.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ function Invoke-Call {
)
$env:LIBDD_OUTPUT_FOLDER=$LddOutputFolder
& @ScriptBlock
gci env:*
Remove-Item env:LIBDD_OUTPUT_FOLDER
if ($lastexitcode -ne 0) {
exit $lastexitcode
}
}

$output_dir = $args[0]
$x86_release_dir = "$($output_dir)-x86-release"
$x86_debug_dir = "$($output_dir)-x86-debug"
$x86_64_release_dir = "$($output_dir)-x86_64-release"
$x86_64_debug_dir = "$($output_dir)-x86_64-debug"

if ([string]::IsNullOrEmpty($output_dir)) {
throw "You must specify an output directory. Ex: $($myInvocation.InvocationName) my_rust_project/ bin"
Expand All @@ -25,31 +22,43 @@ if (![System.IO.Path]::IsPathRooted($output_dir)) {
$output_dir = [System.IO.Path]::Combine($(Get-Location), $output_dir)
}

Write-Host "Building project into $($output_dir)" -ForegroundColor Magenta
$x86_release_dir = "$($output_dir)-x86-release"
$x86_debug_dir = "$($output_dir)-x86-debug"
$x86_64_release_dir = "$($output_dir)-x86_64-release"
$x86_64_debug_dir = "$($output_dir)-x86_64-debug"

# build inside the crate to use the config.toml file
pushd profiling-ffi
Invoke-Call -LddOutputFolder $x86_release_dir -ScriptBlock { gci env:* | sort-object name; cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target i686-pc-windows-msvc --release}
#pushd profiling-ffi

Write-Host "Building project into $($x86_release_dir)" -ForegroundColor Magenta
Invoke-Call -LddOutputFolder $x86_release_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target i686-pc-windows-msvc --release}

Write-Host "Building project into $($x86_debug_dir)" -ForegroundColor Magenta
Invoke-Call -LddOutputFolder $x86_debug_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target i686-pc-windows-msvc }
Invoke-Call -LddOutputFolder $x86_64_release_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target i686-pc-windows-msvc --release}
Invoke-Call -LddOutputFolder $x86_64_debug_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target i686-pc-windows-msvc }
#Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --release --target-dir $output_dir }

Write-Host "Building project into $($x86_64_release_dir)" -ForegroundColor Magenta
Invoke-Call -LddOutputFolder $x86_64_release_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target x86_64-pc-windows-msvc --release}

Write-Host "Building project into $($x86_64_debug_dir)" -ForegroundColor Magenta
Invoke-Call -LddOutputFolder $x86_64_debug_dir -ScriptBlock { cargo build -p builder --features profiling,telemetry,data-pipeline,symbolizer,crashtracker --target x86_64-pc-windows-msvc }

#Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --release --target-dir $output_dir }
#Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target i686-pc-windows-msvc --target-dir $output_dir }
#Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --release --target-dir $output_dir }
#Invoke-Call -ScriptBlock { cargo build --features datadog-profiling-ffi/ddtelemetry-ffi,datadog-profiling-ffi/crashtracker-receiver,datadog-profiling-ffi/crashtracker-collector,datadog-profiling-ffi/demangler --target x86_64-pc-windows-msvc --target-dir $output_dir }
popd
#popd

# Write-Host "Building tools" -ForegroundColor Magenta
# Set-Location tools
# Invoke-Call -ScriptBlock { cargo build --release }
# Set-Location ..

Write-Host "Copying artifacts" -ForegroundColor Magenta
New-Item -Path "c:\" -Name "logfiles" -ItemType "directory"
Copy-Item -Path $x86_release_dir\* $output_dir\ -Recurse
Copy-Item -Path $x86_debug_dir\* $output_dir\ -Recurse
Copy-Item -Path $x86_64_release_dir\* $output_dir\ -Recurse
Copy-Item -Path $x86_64_debug_dir\* $output_dir\ -Recurse
Copy-Item -Path $x86_64_release_dir $output_dir\x64\release\ -Recurse
Copy-Item -Path $x86_64_debug_dir $output_dir\x64\debug\ -Recurse
Copy-Item -Path $x86_release_dir $output_dir\x86\release -Recurse
Copy-Item -Path $x86_debug_dir $output_dir\x86\debug\ -Recurse

# Write-Host "Generating headers" -ForegroundColor Magenta
# Invoke-Call -ScriptBlock { cbindgen --crate ddcommon-ffi --config ddcommon-ffi/cbindgen.toml --output $output_dir\common.h }
# Invoke-Call -ScriptBlock { cbindgen --crate datadog-profiling-ffi --config profiling-ffi/cbindgen.toml --output $output_dir\profiling.h }
Expand All @@ -58,4 +67,4 @@ Copy-Item -Path $x86_64_debug_dir\* $output_dir\ -Recurse
# Invoke-Call -ScriptBlock { cbindgen --crate datadog-crashtracker-ffi --config crashtracker-ffi/cbindgen.toml --output $output_dir"\crashtracker.h" }
# Invoke-Call -ScriptBlock { .\target\release\dedup_headers $output_dir"\common.h" $output_dir"\profiling.h" $output_dir"\telemetry.h" $output_dir"\data-pipeline.h" $output_dir"\crashtracker.h"}

Write-Host "Build finished" -ForegroundColor Magenta
Write-Host "Build finished" -ForegroundColor Magenta
61 changes: 33 additions & 28 deletions windows/libdatadog.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -27,41 +27,46 @@
<None Include="..\LICENSE" Pack="true" PackagePath="\" />
<None Include="libdatadog.props" Pack="true" PackagePath="build\native\libdatadog.props" />

<None Include="$(LibDatadogBinariesOutputDir)\common.h" Pack="true"
<!-- header files are the same between x64/x86/debug/release, so taking it from x64/release it's enough -->
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\common.h" Pack="true"
PackagePath="include\native\datadog\common.h" />
<None Include="$(LibDatadogBinariesOutputDir)\profiling.h" Pack="true"
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\profiling.h" Pack="true"
PackagePath="include\native\datadog\profiling.h" />
<None Include="$(LibDatadogBinariesOutputDir)\telemetry.h" Pack="true"
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\telemetry.h" Pack="true"
PackagePath="include\native\datadog\telemetry.h" />
<None Include="$(LibDatadogBinariesOutputDir)\crashtracker.h" Pack="true"
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\blazesym.h" Pack="true"
PackagePath="include\native\datadog\blazesym.h" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\crashtracker.h" Pack="true"
PackagePath="include\native\datadog\crashtracker.h" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\include\datadog\data-pipeline.h" Pack="true"
PackagePath="include\native\datadog\data-pipeline.h" />

<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\debug\datadog_profiling_ffi.lib"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling_ffi.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\debug\datadog_profiling_ffi.dll"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling_ffi.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\debug\datadog_profiling_ffi.pdb"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling_ffi.pdb" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\debug\lib\datadog_profiling.lib"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\debug\lib\datadog_profiling.dll"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\debug\lib\datadog_profiling.pdb"
Pack="true" PackagePath="build\native\lib\x64\debug\datadog_profiling.pdb" />

<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\release\datadog_profiling_ffi.lib"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling_ffi.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\release\datadog_profiling_ffi.dll"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling_ffi.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x86_64-pc-windows-msvc\release\datadog_profiling_ffi.pdb"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling_ffi.pdb" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\lib\datadog_profiling.lib"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\lib\datadog_profiling.dll"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x64\release\lib\datadog_profiling.pdb"
Pack="true" PackagePath="build\native\lib\x64\release\datadog_profiling.pdb" />

<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\debug\datadog_profiling_ffi.lib"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling_ffi.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\debug\datadog_profiling_ffi.dll"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling_ffi.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\debug\datadog_profiling_ffi.pdb"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling_ffi.pdb" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\debug\lib\datadog_profiling.lib"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\debug\lib\datadog_profiling.dll"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\debug\lib\datadog_profiling.pdb"
Pack="true" PackagePath="build\native\lib\x86\debug\datadog_profiling.pdb" />

<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\release\datadog_profiling_ffi.lib"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling_ffi.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\release\datadog_profiling_ffi.dll"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling_ffi.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\i686-pc-windows-msvc\release\datadog_profiling_ffi.pdb"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling_ffi.pdb" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\release\lib\datadog_profiling.lib"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling.lib" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\release\lib\datadog_profiling.dll"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling.dll" />
<None Include="$(LibDatadogBinariesOutputDir)\x86\release\lib\datadog_profiling.pdb"
Pack="true" PackagePath="build\native\lib\x86\release\datadog_profiling.pdb" />
</ItemGroup>
</Project>

0 comments on commit c2e963d

Please sign in to comment.