diff options
Diffstat (limited to 'scripts/build-windows.ps1')
-rw-r--r-- | scripts/build-windows.ps1 | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/scripts/build-windows.ps1 b/scripts/build-windows.ps1 new file mode 100644 index 000000000..9d4219ffb --- /dev/null +++ b/scripts/build-windows.ps1 | |||
@@ -0,0 +1,100 @@ | |||
1 | # INTRO: | ||
2 | # This file is used to build ferdium on windows. | ||
3 | # It also handles any corrupted node modules with the 'CLEAN' env var (set it to 'true' for cleaning) | ||
4 | # It will install the system dependencies except for node (which is still verified) | ||
5 | # I sometimes symlink my 'recipes' folder so that any changes that I need to do in it can also be committed and pushed | ||
6 | # This file can live anywhere in your PATH | ||
7 | |||
8 | #CHECK PYTHON | ||
9 | #CHECK NODE.JS | ||
10 | #CHECK NPM | ||
11 | #CHECK MSVS_VERSION and MSVS Tools | ||
12 | |||
13 | $USERHOME = "${env:HOMEDRIVE}${env:HOMEPATH}" | ||
14 | |||
15 | $env:ELECTRON_CACHE = $USERHOME + '/.cache/electron' | ||
16 | $env:ELECTRON_BUILDER_CACHE = $USERHOME + '/.cache/electron-builder' | ||
17 | $env:CSC_IDENTITY_AUTO_DISCOVERY = $false | ||
18 | |||
19 | $env:CI = $true | ||
20 | |||
21 | $EXPECTED_NODE_VERSION = (Get-Content .\.nvmrc) | ||
22 | $ACTUAL_NODE_VERSION = (node -v) | ||
23 | |||
24 | if ( "v$EXPECTED_NODE_VERSION" -ne $ACTUAL_NODE_VERSION) | ||
25 | { | ||
26 | Write-Host "You are not running the expected version of node!" | ||
27 | Write-Host " expected: [v$EXPECTED_NODE_VERSION]" | ||
28 | Write-Host " actual : [$ACTUAL_NODE_VERSION]" | ||
29 | exit 1 | ||
30 | } | ||
31 | |||
32 | if ( $env:CLEAN -eq "true" ) | ||
33 | { | ||
34 | $NPM_PATH = "$USERHOME\.npm" | ||
35 | $NODE_GYP = "$USERHOME\.node-gyp" | ||
36 | |||
37 | Write-Host "Cleaning!" | ||
38 | npm cache clean --force | ||
39 | Remove-Item -Path $NPM_PATH -Recurse | ||
40 | Remove-Item -Path $NODE_GYP -Recurse | ||
41 | |||
42 | if ( Test-Path -Path ".\pnpm-lock.yaml" -and (Get-Command -ErrorAction Ignore -Type Application pnpm) ) | ||
43 | { | ||
44 | $PNPM_STORE = "$USERHOME\.pnpm-store" | ||
45 | $PNPM_STATE = "$USERHOME\.pnpm-state" | ||
46 | |||
47 | pnpm store prune | ||
48 | |||
49 | Remove-Item -Path $PNPM_STORE -Recurse | ||
50 | Remove-Item -Path $PNPM_STATE -Recurse | ||
51 | } | ||
52 | |||
53 | git -C recipes clean -fxd | ||
54 | git clean -fxd # Note: This will blast away the 'recipes' folder if you have symlinked it | ||
55 | } | ||
56 | |||
57 | # Ensure that the system dependencies are at the correct version | ||
58 | npm i -gf npm@8.7.0 | ||
59 | npm i -gf pnpm@6.32.8 | ||
60 | |||
61 | # This is useful if we move from 'npm' to 'pnpm' for the main repo as well | ||
62 | if ( (Test-Path -Path ".\pnpm-lock.yaml") -and (Get-Command -ErrorAction Ignore -Type Application pnpm) ) | ||
63 | { | ||
64 | $BASE_CMD="pnpm" | ||
65 | $env:EXEC_CMD="pnpm dlx" | ||
66 | } | ||
67 | else | ||
68 | { | ||
69 | $BASE_CMD="npm" | ||
70 | $env:EXEC_CMD="npx" | ||
71 | } | ||
72 | |||
73 | # Now the meat..... | ||
74 | & $BASE_CMD i | ||
75 | & $BASE_CMD run prepare-code | ||
76 | |||
77 | # Check if the 'recipes' folder is present either as a git submodule or a symbolic link | ||
78 | if (-not (Test-Path -Path ".\recipes\package.json")) | ||
79 | { | ||
80 | try { | ||
81 | git submodule update --init --recursive --remote --rebase --force | ||
82 | } catch { | ||
83 | Write-Host "FAILING since 'recipes' folder/submodule has not been checked out" | ||
84 | exit 1 | ||
85 | } | ||
86 | } | ||
87 | |||
88 | # Note: 'recipes' is already using only pnpm - can switch to $BASE_CMD AFTER both repos are using pnpm | ||
89 | Set-Location recipes | ||
90 | pnpm i | ||
91 | pnpm run package | ||
92 | Set-Location .. | ||
93 | |||
94 | $TARGET_ARCH="x64" | ||
95 | & $BASE_CMD run build -- --$TARGET_ARCH --dir | ||
96 | |||
97 | # Final check to ensure that the version built is the same as the latest commit | ||
98 | # TODO: Need to make this an assertion similar to tthe unix-equivalent | ||
99 | Get-Content "build/buildInfo.json" | ConvertFrom-Json | ||
100 | git log -1 | ||