Skip to content

Add basic cross-compile code #246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions build/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,19 @@ import * as path from "path";
import * as zlib from "zlib";

const isWin = os.platform() === "win32";
const arg = process.argv.slice(3);
const availableArches = ["ia32", "x64", "arm", "arm64"];
const linuxArch = arg.length === 0 ? "x64" : arg;
const libPath = path.join(__dirname, "../lib");
const vscodePath = path.join(libPath, "vscode");
const pkgsPath = path.join(__dirname, "../packages");
const defaultExtensionsPath = path.join(libPath, "VSCode-linux-x64/resources/app/extensions");
const defaultExtensionsPath = path.join(libPath, `VSCode-linux-${linuxArch}/resources/app/extensions`);
const vscodeVersion = "1.32.0";

const buildServerBinary = register("build:server:binary", async (runner) => {
if (!(availableArches.some(x => x === linuxArch))) {
throw new Error(`${linuxArch} is not available. Available Arches are ${availableArches}`);
}
await ensureInstalled();
await copyForDefaultExtensions();
await Promise.all([
Expand Down Expand Up @@ -64,7 +70,19 @@ const dependencyNexeBinary = register("dependency:nexe", async (runner) => {
if (!fs.existsSync(upxBinary)) {
fse.mkdirpSync(upxFolder);
runner.cwd = upxFolder;
const upxExtract = await runner.execute("bash", ["-c", "curl -L https://github.com/upx/upx/releases/download/v3.95/upx-3.95-amd64_linux.tar.xz | tar xJ --strip-components=1"]);
var upxArch = "";
if ("ia32" === linuxArch) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch (linuxArch) {
 ...
}

Might work better here.

upxArch = "i386";
} if ("x64" === linuxArch) {
upxArch = "amd64";
} if ("arm" === linuxArch) {
upxArch = "armeb";
} if ("arm64" === linuxArch) {
upxArch = "arm64";
} else {
throw new Error(`Unsupported Arch ${linuxArch}`)
}
const upxExtract = await runner.execute("bash", ["-c", `curl -L https://github.com/upx/upx/releases/download/v3.95/upx-3.95-${upxArch}_linux.tar.xz | tar xJ --strip-components=1`]);
if (upxExtract.exitCode !== 0) {
throw new Error(`Failed to extract upx: ${upxExtract.stderr}`);
}
Expand Down Expand Up @@ -197,7 +215,7 @@ const buildDefaultExtensions = register("build:default-extensions", async (runne
if (!fs.existsSync(defaultExtensionsPath)) {
await copyForDefaultExtensions();
runner.cwd = extDirPath;
const resp = await runner.execute(isWin ? "npx.cmd" : "npx", [isWin ? "gulp.cmd" : "gulp", "vscode-linux-x64", "--max-old-space-size=32384"]);
const resp = await runner.execute(isWin ? "npx.cmd" : "npx", [isWin ? "gulp.cmd" : "gulp", `vscode-linux-${linuxArch}`, "--max-old-space-size=32384"]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to target linux from any OS since it normally builds with electron. This might not be necessary.

if (resp.exitCode !== 0) {
throw new Error(`Failed to build default extensions: ${resp.stderr}`);
}
Expand Down