Skip to content

Commit 3f1a650

Browse files
committed
Allow setting the VS Code build target
For the NPM package (and tests, at least for now), we will still use linux-x64, but this is going to allow using the platform build targets for our standalone releases so we can avoid having to copy all the packaging steps (like cleaning up modules). This does mean that the NPM package when installed will be missing those cleanup steps. Possibly we can try to break out the packaging step into a something that can be ran standalone (which will also require installing dev dependencies like gulp) but not sure how much work this would be.
1 parent a5c1b6a commit 3f1a650

File tree

5 files changed

+58
-31
lines changed

5 files changed

+58
-31
lines changed

.github/workflows/build.yaml

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,14 @@ jobs:
157157
token: ${{ secrets.CODECOV_TOKEN }}
158158

159159
build:
160-
name: Build code-server
160+
name: Build code-server npm package
161161
runs-on: ubuntu-22.04
162162
env:
163163
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
164164
DISABLE_V8_COMPILE_CACHE: 1
165+
VERSION: 0.0.0
166+
VSCODE_TARGET: linux-x64
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
165168
steps:
166169
- uses: actions/checkout@v6
167170
with:
@@ -181,34 +184,29 @@ jobs:
181184
test/package-lock.json
182185
- run: SKIP_SUBMODULE_DEPS=1 npm ci
183186
- run: npm run build
184-
env:
185-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
186187
# Get Code's git hash. When this changes it means the content is
187188
# different and we need to rebuild.
188189
- name: Get latest lib/vscode rev
189190
id: vscode-rev
190191
run: echo "rev=$(git rev-parse HEAD:./lib/vscode)" >> $GITHUB_OUTPUT
191-
# We need to rebuild when we have a new version of Code, when any of
192-
# the patches changed, or when the code-server version changes (since
193-
# it gets embedded into the code). Use VSCODE_CACHE_VERSION to
194-
# force a rebuild.
195-
- name: Fetch prebuilt Code package from cache
192+
# We need to rebuild when we have a new version of Code, when any of the
193+
# patches changed, or when the code-server version changes (since it gets
194+
# embedded into the code). Use VSCODE_CACHE_VERSION to force a rebuild.
195+
- name: Fetch prebuilt linux-x64 Code package from cache
196196
id: cache-vscode
197197
uses: actions/cache@v4
198198
with:
199-
path: lib/vscode-reh-web-*
200-
key: vscode-reh-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
199+
path: lib/vscode-reh-web-linux-x64-min-ci
200+
key: vscode-reh-linux-x64-package-${{ secrets.VSCODE_CACHE_VERSION }}-${{ steps.vscode-rev.outputs.rev }}-${{ hashFiles('patches/*.diff', 'ci/build/build-vscode.sh') }}
201201
- name: Build vscode
202-
env:
203-
VERSION: "0.0.0"
204202
if: steps.cache-vscode.outputs.cache-hit != 'true'
205203
run: |
206204
pushd lib/vscode
207205
npm ci
208206
popd
209207
npm run build:vscode
210-
# The release package does not contain any native modules
211-
# and is neutral to architecture/os/libc version.
208+
# The release package is just the compiled code, does not contain any
209+
# native modules, and is thus neutral to architecture/os/libc version.
212210
- run: npm run release
213211
if: success()
214212
# https://github.com/actions/upload-artifact/issues/38

.prettierignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
lib/vscode
2-
lib/vscode-reh-web-linux-x64
1+
lib
32
release-standalone
43
release-packages
54
release

ci/build/build-release.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ set -euo pipefail
44
# Once both code-server and VS Code have been built, use this script to copy
55
# them into a single directory (./release), prepare the package.json and
66
# product.json, and add shrinkwraps. This results in a generic NPM package that
7-
# we published to NPM and also use to compile platform-specific packages.
7+
# we can publish to NPM.
88

99
# MINIFY controls whether minified VS Code is bundled. It must match the value
1010
# used when VS Code was built.
1111
MINIFY="${MINIFY-true}"
1212

1313
# node_modules are not copied by default. Set KEEP_MODULES=1 to copy them.
14+
# Note these modules will be for the platform that built them, making the result
15+
# no longer generic (it can still be published though as the modules will be
16+
# ignored when pushing).
1417
KEEP_MODULES="${KEEP_MODULES-0}"
1518

1619
main() {
@@ -85,7 +88,7 @@ bundle_vscode() {
8588
rsync_opts+=(--exclude node_modules)
8689
fi
8790

88-
rsync "${rsync_opts[@]}" ./lib/vscode-reh-web-*/ "$VSCODE_OUT_PATH"
91+
rsync "${rsync_opts[@]}" "./lib/vscode-reh-web-$VSCODE_TARGET/" "$VSCODE_OUT_PATH"
8992

9093
# Merge the package.json for the web/remote server so we can include
9194
# dependencies, since we want to ship this via NPM.

ci/build/build-vscode.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ set -euo pipefail
77
MINIFY=${MINIFY-true}
88

99
delete-bin-script() {
10-
rm -f "lib/vscode-reh-web-linux-x64/bin/$1"
10+
rm -f "lib/vscode-reh-web-$VSCODE_TARGET/bin/$1"
1111
}
1212

1313
copy-bin-script() {
1414
local script="$1"
15-
local dest="lib/vscode-reh-web-linux-x64/bin/$script"
15+
local dest="lib/vscode-reh-web-$VSCODE_TARGET/bin/$script"
1616
cp "lib/vscode/resources/server/bin/$script" "$dest"
1717
sed -i.bak "s/@@VERSION@@/$(vscode_version)/g" "$dest"
1818
sed -i.bak "s/@@COMMIT@@/$BUILD_SOURCEVERSION/g" "$dest"
@@ -108,12 +108,8 @@ main() {
108108
EOF
109109
) > product.json
110110

111-
# Any platform here works since we will do our own packaging. We have to do
112-
# this because we have an NPM package that could be installed on any platform.
113-
# The correct platform dependencies and scripts will be installed as part of
114-
# the post-install during `npm install` or when building a standalone release.
115111
npm run gulp core-ci
116-
npm run gulp "vscode-reh-web-linux-x64${MINIFY:+-min}-ci"
112+
npm run gulp "vscode-reh-web-$VSCODE_TARGET${MINIFY:+-min}-ci"
117113

118114
# Reset so if you develop after building you will not be stuck with the wrong
119115
# commit (the dev client will use `oss-dev` but the dev server will still use
@@ -122,7 +118,7 @@ EOF
122118

123119
popd
124120

125-
pushd lib/vscode-reh-web-linux-x64
121+
pushd "lib/vscode-reh-web-$VSCODE_TARGET"
126122
# Make sure Code took the version we set in the environment variable. Not
127123
# having a version will break display languages.
128124
if ! jq -e .commit product.json; then

ci/lib.sh

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,42 @@ rsync() {
4444
command rsync -a --del "$@"
4545
}
4646

47-
ARCH="$(arch)"
48-
export ARCH
49-
OS=$(os)
50-
export OS
47+
if [[ ! ${ARCH-} ]]; then
48+
ARCH=$(arch)
49+
export ARCH
50+
fi
51+
52+
if [[ ! ${OS-} ]]; then
53+
OS=$(os)
54+
export OS
55+
fi
5156

5257
# RELEASE_PATH is the destination directory for the release from the root.
5358
# Defaults to release
54-
RELEASE_PATH="${RELEASE_PATH-release}"
59+
if [[ ! ${RELEASE_PATH-} ]]; then
60+
RELEASE_PATH="release"
61+
export RELEASE_PATH
62+
fi
63+
64+
nodeOS() {
65+
osname=$OS
66+
case $osname in
67+
macos) osname=darwin ;;
68+
windows) osname=win32 ;;
69+
esac
70+
echo "$osname"
71+
}
72+
73+
nodeArch() {
74+
cpu=$ARCH
75+
case $cpu in
76+
amd64) cpu=x64 ;;
77+
esac
78+
echo "$cpu"
79+
}
80+
81+
# See gulpfile.reh.ts for available targets.
82+
if [[ ! ${VSCODE_TARGET-} ]]; then
83+
VSCODE_TARGET="$(nodeOS)-$(nodeArch)"
84+
export VSCODE_TARGET
85+
fi

0 commit comments

Comments
 (0)