|
1 | 1 | #powershell -ExecutionPolicy ByPass -File build.ps1 |
2 | 2 | param( |
3 | 3 | [string]$libcdoc = $PSScriptRoot, |
4 | | - [string]$platform = $env:PLATFORM, |
| 4 | + [string]$platform = "x64", |
5 | 5 | [string]$build_number = $(if ($null -eq $env:BUILD_NUMBER) {"0"} else {$env:BUILD_NUMBER}), |
6 | | - [string]$msiversion = "1.0.0.$build_number", |
7 | | - [string]$msi_name = "libcdoc-$msiversion$env:VER_SUFFIX.$platform.msi", |
8 | 6 | [string]$git = "git.exe", |
9 | 7 | [string]$vcpkg = "vcpkg\vcpkg.exe", |
10 | 8 | [string]$vcpkg_dir = (split-path -parent $vcpkg), |
11 | 9 | [string]$vcpkg_installed = $libcdoc, |
12 | | - [string]$vcpkg_installed_platform = "$vcpkg_installed\vcpkg_installed_$platform", |
13 | | - [string]$vcpkg_triplet = "$platform-windows", |
| 10 | + [string]$vcpkg_triplet = "x64-windows", |
| 11 | + [string]$vcpkg_installed_platform = "$vcpkg_installed\vcpkg_installed", |
14 | 12 | [string]$cmake = "cmake.exe", |
15 | | - [string]$generator = "NMake Makefiles", |
16 | | - [switch]$run_tests = $false, |
17 | | - [string]$swig = $null, |
18 | | - [string]$doxygen = $null, |
19 | | - [string]$python = $null |
| 13 | + [string]$generator = "Visual Studio 17 2022", |
| 14 | + [switch]$RunTests = $false, |
20 | 15 | ) |
21 | 16 |
|
22 | | -Try { |
23 | | - & wix > $null |
24 | | -} |
25 | | -Catch { |
26 | | - & dotnet tool install -g --version 6.0.2 wix |
27 | | - & wix extension add -g WixToolset.UI.wixext/6.0.2 |
28 | | -} |
29 | | - |
30 | 17 | if(!(Test-Path -Path $vcpkg)) { |
31 | 18 | & $git clone https://github.com/microsoft/vcpkg.git $vcpkg_dir |
32 | 19 | & $vcpkg_dir\bootstrap-vcpkg.bat |
33 | 20 | } |
34 | 21 |
|
35 | 22 | $cmakeext = @() |
36 | | -$wixext = @() |
37 | | -$target = @("all") |
38 | | -if($swig) { |
39 | | - $cmakeext += "-DSWIG_EXECUTABLE=$swig" |
40 | | - $wixext += "-d", "swig=$swig" |
41 | | -} |
42 | | -if($doxygen) { |
43 | | - $cmakeext += "-DDOXYGEN_EXECUTABLE=$doxygen" |
44 | | -} |
45 | 23 | if($platform -eq "arm64" -and $env:VSCMD_ARG_HOST_ARCH -ne "arm64") { |
46 | | - $run_tests = $false |
| 24 | + $cmakeext += "-DCMAKE_DISABLE_FIND_PACKAGE_Python3=yes" |
| 25 | + $RunTests = $false |
47 | 26 | } |
48 | | -if($run_tests) { |
| 27 | +if($RunTests) { |
49 | 28 | $cmakeext += "-DVCPKG_MANIFEST_FEATURES=tests" |
50 | | - $target += "check" |
51 | | -} |
52 | | -if($python) { |
53 | | - $cmakeext += "-DPython3_ROOT_DIR=$python/$platform" |
54 | | - $wixext += "-d", "python=1" |
55 | 29 | } |
56 | 30 |
|
57 | | -foreach($type in @("Debug", "RelWithDebInfo")) { |
58 | | - "===================" |
59 | | - "Build Configuration: " + $type |
60 | | - "===================" |
61 | | - $buildpath = $platform+$type |
62 | | - & $cmake --fresh -B $buildpath -S . "-G$generator" $cmakeext ` |
63 | | - "-DCMAKE_BUILD_TYPE=$type" ` |
64 | | - "-DCMAKE_INSTALL_PREFIX=$platform" ` |
65 | | - "-DCMAKE_INSTALL_BINDIR=." ` |
66 | | - "-DCMAKE_INSTALL_LIBDIR=." ` |
67 | | - "-DCMAKE_TOOLCHAIN_FILE=$vcpkg_dir/scripts/buildsystems/vcpkg.cmake" ` |
| 31 | +$buildpath = "build" |
| 32 | + |
| 33 | +& $cmake --fresh -B $buildpath -S . "-G$generator" $cmakeext ` |
| 34 | + "--toolchain $vcpkg_dir/scripts/buildsystems/vcpkg.cmake" ` |
68 | 35 | "-DVCPKG_INSTALLED_DIR=$vcpkg_installed_platform" ` |
69 | 36 | "-DVCPKG_TARGET_TRIPLET=$vcpkg_triplet" |
70 | | - & $cmake --build $buildpath --target $target |
71 | | - & $cmake --install $buildpath |
72 | | -} |
73 | 37 |
|
74 | | -$docLocation = "$(Get-Location)/$platform/share/doc/libcdoc" |
75 | | -if (Test-Path -Path $docLocation -PathType Container) { |
76 | | - $wixext += "-d", "docLocation=$docLocation" |
| 38 | +foreach($type in @("Debug", "RelWithDebInfo")) { |
| 39 | + "===================" |
| 40 | + "Build Configuration: " + $type |
| 41 | + "===================" |
| 42 | + & $cmake --build $buildpath --config $type |
| 43 | +# & $cmake --install $buildpath |
77 | 44 | } |
78 | 45 |
|
79 | | -& wix build -nologo -arch $platform -out $msi_name $wixext ` |
80 | | - -ext WixToolset.UI.wixext ` |
81 | | - -bv "WixUIBannerBmp=$libcdoc/banner.bmp" ` |
82 | | - -bv "WixUIDialogBmp=$libcdoc/dlgbmp.bmp" ` |
83 | | - -d "ICON=$libcdoc/ID.ico" ` |
84 | | - -d "vcpkg=$vcpkg_installed_platform/$vcpkg_triplet" ` |
85 | | - -d "libcdoc=$(Get-Location)/$platform" ` |
86 | | - $libcdoc\libcdoc.wxs |
87 | | - |
| 46 | +if($RunTests) { |
| 47 | + Push-Location "$libcdoc\$buildpath" |
| 48 | + ctest -V -C Debug |
| 49 | + Pop-Location |
| 50 | +} |
0 commit comments