From 8dadc21abe993d3a68b658e1583b512388ff783d Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 12 Aug 2020 11:09:06 -0400 Subject: [PATCH 1/5] Initial win32 build --- repos/win_scripts/{args.gn => args_x64.gn} | 2 ++ repos/win_scripts/args_x86.gn | 18 ++++++++++++++ repos/win_scripts/build_kaleido.ps1 | 29 +++++++++++++--------- 3 files changed, 37 insertions(+), 12 deletions(-) rename repos/win_scripts/{args.gn => args_x64.gn} (92%) create mode 100644 repos/win_scripts/args_x86.gn diff --git a/repos/win_scripts/args.gn b/repos/win_scripts/args_x64.gn similarity index 92% rename from repos/win_scripts/args.gn rename to repos/win_scripts/args_x64.gn index fbd6d732..efcbc374 100644 --- a/repos/win_scripts/args.gn +++ b/repos/win_scripts/args_x64.gn @@ -14,3 +14,5 @@ symbol_level=0 blink_symbol_level=0 is_debug=false is_component_build=false + +target_cpu = "x64" \ No newline at end of file diff --git a/repos/win_scripts/args_x86.gn b/repos/win_scripts/args_x86.gn new file mode 100644 index 00000000..19aad93d --- /dev/null +++ b/repos/win_scripts/args_x86.gn @@ -0,0 +1,18 @@ +# Copied windows compatible options from //build/args/headless.gn +# Embed resource.pak into binary to simplify deployment. +headless_use_embedded_resources = true + +# Use embedded data instead external files for headless in order +# to simplify deployment. +v8_use_external_startup_data = false + +enable_nacl = false +enable_remoting = false + +# Debug / symbols +symbol_level=0 +blink_symbol_level=0 +is_debug=false +is_component_build=false + +target_cpu = "x86" \ No newline at end of file diff --git a/repos/win_scripts/build_kaleido.ps1 b/repos/win_scripts/build_kaleido.ps1 index 92c20a02..31b2a34c 100644 --- a/repos/win_scripts/build_kaleido.ps1 +++ b/repos/win_scripts/build_kaleido.ps1 @@ -1,4 +1,10 @@ -& { +echo $args[0] +if (-not ($args[0] -eq "x86" -or $args[1] -eq "x64")) { + throw "Invalid architecture: must be one of x86 or x64" +} + + +$arch = $args[0] # cd to repos directory cd $PSScriptRoot\.. @@ -29,12 +35,12 @@ $env:DEPOT_TOOLS_WIN_TOOLCHAIN=0 cd src # Make output directory -if (-Not (Test-Path out\Kaleido_win)) { - New-Item -Path out\Kaleido_win -ItemType "directory" -ErrorAction Ignore +if (-Not (Test-Path out\Kaleido_win_$arch)) { + New-Item -Path out\Kaleido_win_$arch -ItemType "directory" -ErrorAction Ignore } # Write out/Kaleido_win/args.gn -Copy-Item ..\win_scripts\args.gn -Destination out\Kaleido_win +Copy-Item ..\win_scripts\args_$arch.gn -Destination out\Kaleido_win # Copy kaleido/kaleido.cc to src/headless/app/kaleido.cc if (Test-Path headless\app\scopes) { @@ -43,8 +49,8 @@ if (Test-Path headless\app\scopes) { Copy-Item ..\kaleido\cc\* -Destination headless\app\ -Recurse # Perform build, result will be out/Kaleido_win/kaleido -gn gen out\Kaleido_win -ninja -C out\Kaleido_win -j 16 kaleido +gn gen out\Kaleido_win_$arch +ninja -C out\Kaleido_win_$arch -j 16 kaleido # Copy build files if (-Not (Test-Path ..\build\kaleido)) { @@ -53,8 +59,8 @@ if (-Not (Test-Path ..\build\kaleido)) { Remove-Item -Recurse -Force ..\build\kaleido\* -ErrorAction Ignore New-Item -Path ..\build\kaleido\bin -ItemType "directory" -Copy-Item out\Kaleido_win\kaleido.exe -Destination ..\build\kaleido\bin -Recurse -Copy-Item out\Kaleido_win\swiftshader -Destination ..\build\kaleido\bin -Recurse +Copy-Item out\Kaleido_win_$arch\kaleido.exe -Destination ..\build\kaleido\bin -Recurse +Copy-Item out\Kaleido_win_$arch\swiftshader -Destination ..\build\kaleido\bin -Recurse # version cp ..\kaleido\version ..\build\kaleido\ @@ -63,7 +69,7 @@ cp ..\kaleido\version ..\build\kaleido\ cp ..\kaleido\LICENSE.txt ..\build\kaleido\ # Copy icudtl.dat -Copy-Item .\out\Kaleido_win\icudtl.dat -Destination ..\build\kaleido\bin +Copy-Item .\out\Kaleido_win_$arch\icudtl.dat -Destination ..\build\kaleido\bin # Copy javascript cd ..\kaleido\js\ @@ -86,6 +92,7 @@ Copy-Item ..\win_scripts\kaleido.cmd -Destination ..\build\kaleido\ # Build python wheel cd ../kaleido/py +$env:KALEIDO_ARCH=$arch python setup.py package # Change up to kaleido/ directory @@ -101,6 +108,4 @@ Compress-Archive -Path ..\build\kaleido -DestinationPath ..\build\kaleido_win.zi if (Test-Path ..\kaleido\py\kaleido_wheel.zip) { Remove-Item -Recurse -Force ..\kaleido\py\kaleido_wheel.zip } -Compress-Archive -Path ..\kaleido\py\dist -DestinationPath ..\kaleido\py\kaleido_wheel.zip - -} \ No newline at end of file +Compress-Archive -Path ..\kaleido\py\dist -DestinationPath ..\kaleido\py\kaleido_wheel.zip \ No newline at end of file From ab89151ae9334b30cef64c367e698980390e1793 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 12 Aug 2020 11:15:49 -0400 Subject: [PATCH 2/5] build win32 package --- repos/kaleido/py/setup.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/repos/kaleido/py/setup.py b/repos/kaleido/py/setup.py index 897f63be..95eced3b 100644 --- a/repos/kaleido/py/setup.py +++ b/repos/kaleido/py/setup.py @@ -129,6 +129,13 @@ def run(self): # Use current platform as plat_name, but replace linux with manylinux2014 cmd_obj.plat_name = distutils.util.get_platform().replace("linux-", "manylinux1-") + # Handle windows 32-bit cross compilation + print(os.environ.get("KALEIDO_ARCH", "x64")) + if cmd_obj.plat_name.startswith("win-"): + arch = os.environ.get("KALEIDO_ARCH", "x64") + if arch == "x86": + cmd_obj.plat_name = "win32" + print(cmd_obj.plat_name) # Set macos platform to 10.10 to match chromium build target (See build/config/mac/mac_sdk.gni) # rather than Python environment if cmd_obj.plat_name.startswith("macosx"): From aef6a8730d004e95e5c49f5281bfa3e1f49b83c1 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 12 Aug 2020 11:39:03 -0400 Subject: [PATCH 3/5] Add WIP win32 job to circleci --- .circleci/config.yml | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5718e58c..ebd40317 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -169,14 +169,34 @@ jobs: command: Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force - attach_workspace: at: .\repos - - run: .\repos\win_scripts\build_kaleido.ps1 + - run: .\repos\win_scripts\build_kaleido.ps1 x64 - run: dir .\repos\build\kaleido - run: dir .\repos\kaleido\py\dist - store_artifacts: path: ./repos/build/kaleido_win.zip - store_artifacts: path: ./repos/kaleido/py/kaleido_wheel.zip - + + windows_build-32: + executor: + name: win/default + size: "xlarge" + shell: powershell.exe + steps: + - checkout + - run: + name: Update PowerShell.Archive to fix slash direction + command: Install-Module Microsoft.PowerShell.Archive -MinimumVersion 1.2.3.0 -Repository PSGallery -Force + - attach_workspace: + at: .\repos + - run: .\repos\win_scripts\build_kaleido.ps1 x86 + - run: dir .\repos\build\kaleido + - run: dir .\repos\kaleido\py\dist + - store_artifacts: + path: ./repos/build/kaleido_win.zip + - store_artifacts: + path: ./repos/kaleido/py/kaleido_wheel.zip + workflows: build-windows: jobs: @@ -184,7 +204,12 @@ workflows: - windows_build: requires: - windows_fetch - + build-windows-32: + jobs: + - windows_fetch + - windows_build-32: + requires: + - windows_fetch build-mac: jobs: - mac_fetch From 9083f151509801e4a7c2bc32198437e6bcaac11a Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Wed, 12 Aug 2020 15:29:33 -0400 Subject: [PATCH 4/5] Update win build script --- repos/win_scripts/build_kaleido.ps1 | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/repos/win_scripts/build_kaleido.ps1 b/repos/win_scripts/build_kaleido.ps1 index 31b2a34c..32449498 100644 --- a/repos/win_scripts/build_kaleido.ps1 +++ b/repos/win_scripts/build_kaleido.ps1 @@ -1,10 +1,8 @@ -echo $args[0] -if (-not ($args[0] -eq "x86" -or $args[1] -eq "x64")) { - throw "Invalid architecture: must be one of x86 or x64" -} - - $arch = $args[0] +echo $arch +if (-not ($arch -eq "x86" -or $arch -eq "x64")) { + throw "Invalid architecture,: must be one of x86 or x64: received $arch" +} # cd to repos directory cd $PSScriptRoot\.. From 20c01af06708269fc3efb84f3c03fd86fcb83778 Mon Sep 17 00:00:00 2001 From: Jon Mease Date: Fri, 14 Aug 2020 15:18:00 -0400 Subject: [PATCH 5/5] Fix copy args.gn command --- repos/win_scripts/build_kaleido.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/repos/win_scripts/build_kaleido.ps1 b/repos/win_scripts/build_kaleido.ps1 index 32449498..e5613211 100644 --- a/repos/win_scripts/build_kaleido.ps1 +++ b/repos/win_scripts/build_kaleido.ps1 @@ -38,7 +38,7 @@ if (-Not (Test-Path out\Kaleido_win_$arch)) { } # Write out/Kaleido_win/args.gn -Copy-Item ..\win_scripts\args_$arch.gn -Destination out\Kaleido_win +Copy-Item ..\win_scripts\args_$arch.gn -Destination out\Kaleido_win_$arch\args.gn # Copy kaleido/kaleido.cc to src/headless/app/kaleido.cc if (Test-Path headless\app\scopes) {