aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-23 19:57:47 -0800
committerGravatar Jarred Sumner <jarred@jarredsumner.com> 2021-12-23 19:57:47 -0800
commit3c3ab57cf6ef899c299b19380752add3780e951f (patch)
tree968e472ae7d23d58d968562a553b505a5091ddd3
parentb73e7a9732beefefa82934e728421275a089c49d (diff)
downloadbun-3c3ab57cf6ef899c299b19380752add3780e951f.tar.gz
bun-3c3ab57cf6ef899c299b19380752add3780e951f.tar.zst
bun-3c3ab57cf6ef899c299b19380752add3780e951f.zip
:nail_care:
-rw-r--r--.devcontainer/devcontainer.json6
-rw-r--r--.devcontainer/scripts/getting-started.sh19
-rw-r--r--Dockerfile11
-rw-r--r--README.md68
4 files changed, 40 insertions, 64 deletions
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
index ac5728382..401c7c088 100644
--- a/.devcontainer/devcontainer.json
+++ b/.devcontainer/devcontainer.json
@@ -29,9 +29,7 @@
"esbenp.prettier-vscode",
"xaver.clang-format"
],
-
-
- "postCreateCommand": "cd /workspaces; bash /workspaces/getting-started.sh; zsh",
+ "postCreateCommand": "cd /workspaces/bun; bash /workspaces/getting-started.sh; zsh",
"build": {
"target": "dev",
@@ -43,7 +41,7 @@
"--ulimit", "nofile=65536:65536",
"--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
],
- "workspaceMount": "source=bun-dev2,target=/workspaces,type=volume",
+ "workspaceMount": "source=bun,target=/workspaces/bun,type=volume",
"workspaceFolder": "/workspaces/bun",
"mounts": [
"source=bun-install,target=/home/ubuntu/.bun,type=volume",
diff --git a/.devcontainer/scripts/getting-started.sh b/.devcontainer/scripts/getting-started.sh
index a315f0fc0..ca589cbaa 100644
--- a/.devcontainer/scripts/getting-started.sh
+++ b/.devcontainer/scripts/getting-started.sh
@@ -2,15 +2,18 @@
echo "To get started, login to GitHub and clone Bun's GitHub repo into /workspaces/bun"
echo "Make sure to login with a Personal Access Token"
+echo "# First time setup"
+echo "gh auth login"
+echo "gh repo clone Jarred-Sumner/bun . -- --depth=1 --progress -j8"
echo ""
-echo " gh auth login;"
-echo " gh repo clone Jarred-Sumner/bun -- --depth=1 --progress --recursive -j8"
-echo " cd bun;"
-echo " make devcontainer"
+echo "# update all submodules except webkit because webkit takes awhile and it's already compiled for you."
+echo "git -c submodule.\"src/javascript/jsc/WebKit\".update=none submodule update --init --recursive --depth=1 --progress"
echo ""
-echo "To build for development:"
-echo " make dev"
+echo "# Compile bun dependencies (zig is are already compiled)"
+echo "make devcontainer"
echo ""
-echo "To run:"
-echo " bun-debug"
+echo "# Build Bun for development"
+echo "make dev"
echo ""
+echo "# Run bun"
+echo "bun-debug"
diff --git a/Dockerfile b/Dockerfile
index b47f4ee2a..953ddaee0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -76,7 +76,6 @@ ENV PATH "/home/ubuntu/zig:$PATH"
ENV JSC_BASE_DIR $WEBKIT_OUT_DIR
ENV LIB_ICU_PATH /home/ubuntu/icu/source/lib
ENV BUN_RELEASE_DIR /home/ubuntu/bun-release
-ENV BUN_DEPS_OUT_DIR /home/ubuntu/bun-deps
FROM ubuntu-base as build_dependencies
@@ -84,6 +83,7 @@ FROM ubuntu-base as build_dependencies
WORKDIR /home/ubuntu/bun
+
COPY Makefile /home/ubuntu/bun/Makefile
COPY src/deps /home/ubuntu/bun/src/deps
COPY src/js_lexer/identifier_data.zig /home/ubuntu/bun/src/js_lexer/identifier_data.zig
@@ -92,6 +92,9 @@ COPY src/node-fallbacks /home/ubuntu/bun/src/node-fallbacks
WORKDIR /home/ubuntu/bun
+ENV BUN_DEPS_OUT_DIR /home/ubuntu/bun-deps
+
+
RUN mkdir -p $BUN_DEPS_OUT_DIR; make \
mimalloc \
zlib \
@@ -103,6 +106,9 @@ RUN mkdir -p $BUN_DEPS_OUT_DIR; make \
FROM ubuntu-base as prebuild
+ENV BUN_DEPS_OUT_DIR /home/ubuntu/bun-deps
+
+
ADD . /home/ubuntu/bun
COPY --from=build_dependencies /home/ubuntu/bun-deps /home/ubuntu/bun-deps
COPY --from=build_dependencies /home/ubuntu/bun/src/node-fallbacks /home/ubuntu/bun/src/node-fallbacks
@@ -141,7 +147,6 @@ ENV PATH "/home/ubuntu/zig:$PATH"
ENV JSC_BASE_DIR $WEBKIT_OUT_DIR
ENV LIB_ICU_PATH /home/ubuntu/icu/source/lib
ENV BUN_RELEASE_DIR /home/ubuntu/bun-release
-ENV BUN_DEPS_OUT_DIR /home/ubuntu/bun-deps
ENV PATH "/workspaces/bun/packages/debug-bun-linux-x64:/workspaces/bun/packages/debug-bun-linux-aarch64:$PATH"
ENV PATH "/home/ubuntu/zls/zig-out/bin:$PATH"
@@ -155,7 +160,7 @@ COPY .devcontainer/zls.json /workspaces/workspace.code-workspace
COPY .devcontainer/limits.conf /etc/security/limits.conf
COPY ".devcontainer/scripts/" /scripts/
COPY ".devcontainer/scripts/getting-started.sh" /workspaces/getting-started.sh
-RUN mkdir -p /home/ubuntu/.bun /home/ubuntu/.config && bash /scripts/common-debian.sh && bash /scripts/github.sh && bash /scripts/nice.sh && bash /scripts/zig-env.sh
+RUN mkdir -p /home/ubuntu/.bun /home/ubuntu/.config /workspaces/bun && bash /scripts/common-debian.sh && bash /scripts/github.sh && bash /scripts/nice.sh && bash /scripts/zig-env.sh
COPY .devcontainer/zls.json /home/ubuntu/.config/zls.json
diff --git a/README.md b/README.md
index a9d58215c..681d0d4cd 100644
--- a/README.md
+++ b/README.md
@@ -1154,73 +1154,43 @@ If you see an error about missing files on `zig build obj`, make sure you built
### Linux
-A Dockerfile with the exact version of Zig used is availble at `Dockerfile.zig`. This installs all the system dependencies you’ll need excluding JavaScriptCore, but doesn’t currently compile Bun in one command. If you’re having trouble compiling Zig, it might be helpful to look at.
+Please use the VSCode Remote Container in this repository.
-#### Compile Zig (Linux)
+You will need to clone the GitHub repository inside that container, which also requires authenticating with GitHub (until Bun's repository is public). Make sure to login with a Personal Access Token rather than a web browser.
-```bash
-git clone https://github.com/jarred-sumner/zig
-cd zig
-git checkout jarred/zig-sloppy-with-small-structs
-cmake . -DCMAKE_BUILD_TYPE=Release && make -j $(nproc)
-```
-
-#### Compile JavaScriptCore (Linux)
+Inside the container, run this:
```bash
-# This will take a few minutes, depending on how fast your internet is
-git submodule update --init --recursive --progress --depth=1
-
-# This will take 10-30 minutes, depending on how many cores your CPU has
-DOCKER_BUILDKIT=1 docker build -t bun-webkit $(pwd)/src/javascript/jsc/WebKit -f $(pwd)/src/javascript/jsc/WebKit/Dockerfile --progress=plain
-docker container create bun-webkit
-
-# Find the docker container ID manually. If you know a better way, please submit a PR!
-docker container ls
-
-docker cp DOCKER_CONTAINER_ID_YOU_JUST_FOUND:/output $HOME/webkit-build
-```
-
-#### Build Bun (Linux)
-
-```bash
-make vendor dev
-```
+# First time setup
+gh auth login
+gh repo clone Jarred-Sumner/bun . -- --depth=1 --progress -j8
-#### Verify it worked (Lunux)
+# update all submodules except webkit because webkit takes awhile and it's already compiled for you.
+git -c submodule."src/javascript/jsc/WebKit".update=none submodule update --init --recursive --depth=1 --progress
-First ensure the node dependencies are installed
-
-```bash
-cd integration/snippets
-npm i
-```
+# Compile bun dependencies (zig is are already compiled)
+make devcontainer
-Then
+# Build Bun for development
+make dev
-```bash
-# if you’re not already in the bun root directory
-cd ../../
-make test-dev-all
+# Run bun
+bun-debug
```
-Run bun:
-
-```bash
-packages/debug-bun-cli-darwin-x64/bin/bun-debug
-```
+This container has Zig, zls, vscode-zig, and more setup automatically for you. It is very similar to my own development environment.
## vscode-zig
+Note: this is automatically installed on the devcontainer
+
You will want to install the fork of `vscode-zig` so you get a `Run test` and a `Debug test` button.
To do that:
```bash
-git clone https://github.com/jarred-sumner/vscode-zig
-cd vscode-zig
-yarn install
-yarn vsce package && code --install-extension ./zig-0.2.5.vsix
+curl -L https://github.com/Jarred-Sumner/vscode-zig/releases/download/fork-v1/zig-0.2.5.vsix > vscode-zig.vsix
+code --install-extension vscode-zig.vsix
```
<a target="_blank" href="https://github.com/jarred-sumner/vscode-zig"><img src="https://pbs.twimg.com/media/FBZsKHlUcAYDzm5?format=jpg&name=large"></a>