Skip to content

Commit

Permalink
ci: use sysroots for stripping binaries in rpmbuild (microsoft#227397)
Browse files Browse the repository at this point in the history
  • Loading branch information
deepak1556 authored Sep 3, 2024
1 parent 07a1a14 commit adac839
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 2 deletions.
32 changes: 32 additions & 0 deletions build/azure-pipelines/linux/product-build-linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,26 @@ steps:
fi
echo "Yarn failed $i, trying again..."
done
displayName: Install build dependencies
condition: and(succeeded(), ne(variables.NODE_MODULES_RESTORED, 'true'))
# Step will be used by both Install dependencies and building rpm package,
# hence avoid adding it behind NODE_MODULES_RESTORED condition.
- script: |
set -e
SYSROOT_ARCH=$VSCODE_ARCH
if [ "$SYSROOT_ARCH" == "x64" ]; then
SYSROOT_ARCH="amd64"
fi
export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots
SYSROOT_ARCH="$SYSROOT_ARCH" node -e '(async () => { const { getVSCodeSysroot } = require("./build/linux/debian/install-sysroot.js"); await getVSCodeSysroot(process.env["SYSROOT_ARCH"]); })()'
env:
VSCODE_ARCH: $(VSCODE_ARCH)
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Download vscode sysroots
- script: |
set -e
source ./build/azure-pipelines/linux/setup-env.sh
Expand Down Expand Up @@ -290,7 +310,19 @@ steps:
- script: |
set -e
TRIPLE=""
if [ "$VSCODE_ARCH" == "x64" ]; then
TRIPLE="x86_64-linux-gnu"
elif [ "$VSCODE_ARCH" == "arm64" ]; then
TRIPLE="aarch64-linux-gnu"
elif [ "$VSCODE_ARCH" == "armhf" ]; then
TRIPLE="arm-rpi-linux-gnueabihf"
fi
export VSCODE_SYSROOT_DIR=$(Build.SourcesDirectory)/.build/sysroots
export STRIP="$VSCODE_SYSROOT_DIR/$TRIPLE/$TRIPLE/bin/strip"
yarn gulp "vscode-linux-$(VSCODE_ARCH)-prepare-rpm"
env:
VSCODE_ARCH: $(VSCODE_ARCH)
displayName: Prepare rpm package
- script: |
Expand Down
7 changes: 6 additions & 1 deletion build/azure-pipelines/linux/setup-env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ if [ "$SYSROOT_ARCH" == "x64" ]; then
fi

export VSCODE_SYSROOT_DIR=$PWD/.build/sysroots
SYSROOT_ARCH="$SYSROOT_ARCH" node -e '(async () => { const { getVSCodeSysroot } = require("./build/linux/debian/install-sysroot.js"); await getVSCodeSysroot(process.env["SYSROOT_ARCH"]); })()'
if [ -d "$VSCODE_SYSROOT_DIR" ]; then
echo "Using cached sysroot"
else
echo "Downloading sysroot"
SYSROOT_ARCH="$SYSROOT_ARCH" node -e '(async () => { const { getVSCodeSysroot } = require("./build/linux/debian/install-sysroot.js"); await getVSCodeSysroot(process.env["SYSROOT_ARCH"]); })()'
fi

if [ "$npm_config_arch" == "x64" ]; then
if [ "$(echo "$@" | grep -c -- "--only-remote")" -eq 0 ]; then
Expand Down
2 changes: 1 addition & 1 deletion build/azure-pipelines/product-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ extends:
- ${{ if or(eq(parameters.VSCODE_BUILD_LINUX, true),eq(parameters.VSCODE_BUILD_LINUX_ARMHF, true),eq(parameters.VSCODE_BUILD_LINUX_ARM64, true),eq(parameters.VSCODE_BUILD_ALPINE, true),eq(parameters.VSCODE_BUILD_ALPINE_ARM64, true),eq(parameters.VSCODE_BUILD_MACOS, true),eq(parameters.VSCODE_BUILD_MACOS_ARM64, true),eq(parameters.VSCODE_BUILD_WIN32, true),eq(parameters.VSCODE_BUILD_WIN32_ARM64, true)) }}:
- CompileCLI
pool:
name: 1es-ubuntu-20.04-x64
name: 1es-ubuntu-22.04-x64
os: linux
jobs:
- ${{ if eq(variables['VSCODE_CIBUILD'], true) }}:
Expand Down
2 changes: 2 additions & 0 deletions build/gulpfile.vscode.linux.js
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ function getRpmPackageArch(arch) {
function prepareRpmPackage(arch) {
const binaryDir = '../VSCode-linux-' + arch;
const rpmArch = getRpmPackageArch(arch);
const stripBinary = process.env['STRIP'] ?? '/usr/bin/strip';

return function () {
const desktop = gulp.src('resources/linux/code.desktop', { base: '.' })
Expand Down Expand Up @@ -208,6 +209,7 @@ function prepareRpmPackage(arch) {
.pipe(replace('@@QUALITY@@', product.quality || '@@QUALITY@@'))
.pipe(replace('@@UPDATEURL@@', product.updateUrl || '@@UPDATEURL@@'))
.pipe(replace('@@DEPENDENCIES@@', dependencies.join(', ')))
.pipe(replace('@@STRIP@@', stripBinary))
.pipe(rename('SPECS/' + product.applicationName + '.spec'))
.pipe(es.through(function (f) { that.emit('data', f); }, function () { that.emit('end'); }));
}));
Expand Down
1 change: 1 addition & 0 deletions resources/linux/rpm/code.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Visual Studio Code is a new choice of tool that combines the simplicity of a cod
# Don't generate build_id links to prevent conflicts when installing multiple
# versions of VS Code alongside each other (e.g. `code` and `code-insiders`)
%define _build_id_links none
%define __strip @@STRIP@@

%install
# Destination directories
Expand Down

0 comments on commit adac839

Please sign in to comment.