Skip to content
Open
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
38 changes: 30 additions & 8 deletions build-all.bat
Original file line number Diff line number Diff line change
@@ -1,9 +1,38 @@
@echo off

cd %~dp0
call tools\gen-version.cmd
@setlocal ENABLEEXTENSIONS

set CUSTOM_PROPS=
if not "%~1"=="" (
if not exist "%~f1" (
goto custom_props_missing
)
if /I not "%~x1"==".props" (
if /I not "%~x1"==".targets" (
goto custom_props_invalid_type
)
)
set CUSTOM_PROPS="/p:ForceImportBeforeCppTargets=%~f1"
echo Using custom properties file for the build:
echo %CUSTOM_PROPS%
)

goto after_custom_props_validation

:custom_props_missing
echo ERROR: Custom build input not found: %~1
echo Pass an existing MSBuild .props or .targets file to ForceImportBeforeCppTargets.
exit /b 1

:custom_props_invalid_type
echo ERROR: Custom build input must be an MSBuild .props or .targets file: %~1
echo Pass the MSBuild import file, not the CONFIG_CUSTOM_H header.
exit /b 1

:after_custom_props_validation
call tools\gen-version.cmd

echo Update all public submodules...
git -c submodule."lib/modules".update=none submodule update --init --recursive

Expand All @@ -17,13 +46,6 @@ if NOT EXIST %GTEST_PATH%\CMakeLists.txt (
git clone --depth 1 --branch release-1.12.1 https://github.com/google/googletest %GTEST_PATH%
)

set CUSTOM_PROPS=
if ("%~1"=="") goto skip
set CUSTOM_PROPS="/p:ForceImportBeforeCppTargets=%1"
echo Using custom properties file for the build:
echo %CUSTOM_PROPS%
:skip

if NOT DEFINED SKIP_MD_BUILD (
REM DLL and static /MD build
REM Release
Expand Down
38 changes: 30 additions & 8 deletions build-tests.cmd
Original file line number Diff line number Diff line change
@@ -1,8 +1,37 @@
@echo off
cd %~dp0
call tools\gen-version.cmd
@setlocal ENABLEEXTENSIONS

set CUSTOM_PROPS=
if not "%~3"=="" (
if not exist "%~f3" (
goto custom_props_missing
)
if /I not "%~x3"==".props" (
if /I not "%~x3"==".targets" (
goto custom_props_invalid_type
)
)
set CUSTOM_PROPS="/p:ForceImportBeforeCppTargets=%~f3"
echo Using custom properties file for the build:
echo %CUSTOM_PROPS%
)

goto after_custom_props_validation

:custom_props_missing
echo ERROR: Custom build input not found: %~3
echo Pass an existing MSBuild .props or .targets file to ForceImportBeforeCppTargets.
exit /b 1

:custom_props_invalid_type
echo ERROR: Custom build input must be an MSBuild .props or .targets file: %~3
echo Pass the MSBuild import file, not the CONFIG_CUSTOM_H header.
exit /b 1

:after_custom_props_validation
call tools\gen-version.cmd

if DEFINED GIT_PULL_TOKEN (
rd /s /q lib\modules
git clone https://%GIT_PULL_TOKEN%:x-oauth-basic@github.com/microsoft/cpp_client_telemetry_modules.git lib\modules
Expand All @@ -20,13 +49,6 @@ set PLAT=%1
REM Possible configurations: Release|Debug
set CONFIGURATION=%2

set CUSTOM_PROPS=
if ("%3"=="") goto skip
set CUSTOM_PROPS="/p:ForceImportBeforeCppTargets=%3"
echo Using custom properties file for the build:
echo %CUSTOM_PROPS%
:skip

set MAXCPUCOUNT=%NUMBER_OF_PROCESSORS%
set SOLUTION=Solutions\MSTelemetrySDK.sln

Expand Down
25 changes: 23 additions & 2 deletions build-win.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,17 @@ $cpuCount = $env:NUMBER_OF_PROCESSORS

$actualCustomProps = ""
if ($customProps -ne "") {
$actualCustomProps = "/p:ForceImportBeforeCppTargets=$customProps"
if (-not (Test-Path -LiteralPath $customProps -PathType Leaf)) {
throw "Custom build input not found: $customProps`nPass an existing MSBuild .props or .targets file to ForceImportBeforeCppTargets."
}

$customPropsExtension = [System.IO.Path]::GetExtension($customProps)
if ($customPropsExtension -ine ".props" -and $customPropsExtension -ine ".targets") {
throw "Custom build input must be an MSBuild .props or .targets file: $customProps`nPass the MSBuild import file, not the CONFIG_CUSTOM_H header."
}

$resolvedCustomProps = (Resolve-Path -LiteralPath $customProps).Path
$actualCustomProps = "/p:ForceImportBeforeCppTargets=$resolvedCustomProps"
Comment thread
bmehta001 marked this conversation as resolved.
}

$coreTargets = @("zlib")
Expand Down Expand Up @@ -133,7 +143,18 @@ foreach ($arch in $archs) {
}

# Build!
& cmd /c "msbuild $solution /target:$targetStr /p:BuildProjectReferences=true /maxcpucount:$cpuCount /p:Configuration=$actualConfig /p:Platform=$actualArch $actualCustomProps"
$msbuildArgs = @(
$solution
"/target:$targetStr"
"/p:BuildProjectReferences=true"
"/maxcpucount:$cpuCount"
"/p:Configuration=$actualConfig"
"/p:Platform=$actualArch"
)
if ($actualCustomProps -ne "") {
$msbuildArgs += $actualCustomProps
}
& msbuild @msbuildArgs

echo "...Done!"
echo ""
Expand Down
2 changes: 2 additions & 0 deletions docs/building-custom-SKU.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ build-all.bat %CD%\Solutions\build.compact.props

produces a custom compact SDK build.

The argument passed to `build-all.bat` must be an MSBuild `.props` or `.targets` file that sets the required preprocessor definitions. Do not pass the `config-*.h` header directly to `ForceImportBeforeCppTargets`.

How it works:

**build.compact.props** - contains the preprocessor definition that is functionally equivalent to
Expand Down
Loading