Skip to content

Commit 5677ff2

Browse files
committed
Add build scripts
1 parent 61c281e commit 5677ff2

11 files changed

Lines changed: 374 additions & 88 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules
2+
build
3+
release

.travis.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,20 @@ matrix:
88
- os: linux
99
dist: trusty
1010
env:
11-
- VSCODE_VERSION="1.33.1" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION" TARGET="centos"
11+
- VSCODE_VERSION="1.36.0" MAJOR_VERSION="2" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER" TARGET="centos"
1212
- os: linux
1313
dist: trusty
1414
env:
15-
- VSCODE_VERSION="1.33.1" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION" TARGET="alpine"
15+
- VSCODE_VERSION="1.36.0" MAJOR_VERSION="2" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER" TARGET="alpine"
1616
- os: osx
1717
env:
18-
- VSCODE_VERSION="1.33.1" MAJOR_VERSION="1" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER-vsc$VSCODE_VERSION"
18+
- VSCODE_VERSION="1.36.0" MAJOR_VERSION="2" VERSION="$MAJOR_VERSION.$TRAVIS_BUILD_NUMBER"
1919
before_install:
20-
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install libxkbfile-dev
21-
libsecret-1-dev; fi
20+
- if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install -y libxkbfile-dev libsecret-1-dev; fi
2221
- npm install -g yarn@1.12.3
22+
- npm install -g @coder/nbin
2323
script:
24-
- scripts/build.sh
24+
- scripts/ci.bash
2525
before_deploy:
2626
- echo "$VERSION" "$TRAVIS_COMMIT"
2727
- git config --local user.name "$USER_NAME"

README.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,19 @@ Quickstart guides for [Google Cloud](doc/admin/install/google_cloud.md), [AWS](d
5151
How to [secure your setup](/doc/security/ssl.md).
5252
5353
## Build
54-
- Run `yarn build ${vscodeVersion}`in this directory (for example, `yarn build 1.35.0`).
54+
- If you also plan on developing, set the `OUT` environment variable: `
55+
export OUT=/path/to/some/directory`. Otherwise it will build in this
56+
directory which will cause issues because then `yarn watch` will try to
57+
compile the build directory as well.
58+
- Run `yarn build ${vscodeVersion} ${target} ${arch}`in this directory (for example:
59+
`yarn build 1.35.0 linux x64`).
5560
5661
## Development
5762
5863
- Clone VS Code.
59-
- Clone code-server to `src/vs/server` in the VS Code source.
60-
- Run `yarn` in this directory (only need to do this once).
64+
- Run `yarn` in the VS Code root directory.
65+
- Clone this repository to `src/vs/server` in the VS Code source.
66+
- Run `yarn` in this directory.
6167
- Run `yarn watch` in this directory.
6268
- Wait for the initial compilation to complete.
6369
- Run `yarn start` in this directory.

main.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1+
try {
2+
const nbin = require("nbin");
3+
const path = require("path");
4+
const rootPath = path.resolve(__dirname, "../../..");
5+
console.log("Shimming", rootPath);
6+
nbin.shimNativeFs(rootPath);
7+
} catch (error) {
8+
console.log("Not in the binary");
9+
}
10+
111
require("../../bootstrap-amd").load("vs/server/cli");

package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
{
2+
"license": "MIT",
23
"scripts": {
4+
"postinstall": "rm -r node_modules/@types/node # I keep getting type conflicts",
35
"start": "nodemon ../../../out/vs/server/main.js --watch ../../../out --verbose",
46
"watch": "cd ../../../ && yarn watch-client",
5-
"build": "echo TODO && exit 1"
7+
"build": "bash ./scripts/tasks.bash build",
8+
"package": "bash ./scripts/tasks.bash package",
9+
"vstar": "bash ./scripts/tasks.bash vstar",
10+
"binary": "bash ./scripts/tasks.bash binary"
611
},
712
"devDependencies": {
813
"@types/tar-stream": "^1.6.1",

scripts/build.sh

Lines changed: 0 additions & 51 deletions
This file was deleted.

scripts/ci.bash

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
# Build using a Docker container using the specified image and version.
5+
function docker-build() {
6+
local image="${1}" ; shift
7+
local version="${1}" ; shift
8+
local vscodeVersion="${1}" ; shift
9+
local target="${1}" ; shift
10+
local arch="${1}" ; shift
11+
12+
local containerId
13+
containerId=$(docker create --network=host --rm -it -v "$(pwd)"/.cache:/src/.cache "${image}")
14+
docker start "${containerId}"
15+
docker exec "${containerId}" mkdir -p /src
16+
17+
function docker-exec() {
18+
docker exec "${containerId}" bash -c "$@"
19+
}
20+
21+
docker cp ./. "${containerId}":/src
22+
docker-exec "cd /src && CI=true yarn build \"${vscodeVersion}\" \"${target}\" \"${arch}\""
23+
docker-exec "cd /src && CI=true yarn binary \"${vscodeVersion}\" \"${target}\" \"${arch}\""
24+
docker-exec "cd /src && CI=true yarn package \"${vscodeVersion}\" \"${target}\" \"${arch}\" \"${version}\""
25+
docker cp "${containerId}":/src/release/. ./release/
26+
27+
docker stop "${containerId}"
28+
}
29+
30+
# Build code-server in the CI.
31+
function main() {
32+
local version="${VERSION:-}"
33+
local vscodeVersion="${VSCODE_VERSION:-}"
34+
local ostype="${OSTYPE:-}"
35+
local target="${TARGET:-}"
36+
local arch=x64
37+
38+
if [[ -z "${version}" ]] ; then
39+
>&2 echo "Must set VERSION environment variable"; exit 1
40+
fi
41+
42+
if [[ -z "${vscodeVersion}" ]] ; then
43+
>&2 echo "Must set VSCODE_VERSION environment variable"; exit 1
44+
fi
45+
46+
if [[ "${ostype}" == "darwin"* ]]; then
47+
target=darwin
48+
CI=true yarn build "${vscodeVersion}" "${target}" "${arch}"
49+
CI=true yarn binary "${vscodeVersion}" "${target}" "${arch}"
50+
CI=true yarn package "${vscodeVersion}" "${target}" "${arch}" "${version}"
51+
else
52+
local image
53+
if [[ "${target}" == alpine ]]; then
54+
image=codercom/nbin-alpine
55+
target=musl
56+
else
57+
image=codercom/nbin-centos
58+
target=linux
59+
fi
60+
docker-build "${image}" "${version}" "${vscodeVersion}" "${target}" "${arch}"
61+
fi
62+
}
63+
64+
main "$@"

scripts/nbin.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* global require, __dirname, process */
2+
const { Binary } = require("@coder/nbin");
3+
const fs = require("fs");
4+
const path = require("path");
5+
6+
const target = process.argv[2];
7+
const arch = process.argv[3];
8+
const source = process.argv[4];
9+
10+
const bin = new Binary({
11+
mainFile: path.join(source, "out/vs/server/main.js"),
12+
target: target,
13+
});
14+
15+
bin.writeFiles(path.join(source, "**"));
16+
17+
bin.build().then((binaryData) => {
18+
const outputPath = path.join(source, "code-server");
19+
fs.writeFileSync(outputPath, binaryData);
20+
fs.chmodSync(outputPath, "755");
21+
}).catch((ex) => {
22+
console.error(ex);
23+
process.exit(1);
24+
});

0 commit comments

Comments
 (0)