diff options
author | 2021-12-24 04:56:42 +0000 | |
---|---|---|
committer | 2021-12-24 04:56:42 +0000 | |
commit | 42ff5415ba7974c1e36697121b53a8299ea703bd (patch) | |
tree | 14540a19b04cb8aaf6423fdf20a39981842cac08 | |
parent | 0e52be84271c56de6638ce968cd7b2098008a640 (diff) | |
parent | 77fc310a70aed3770331638301bdd62344742bac (diff) | |
download | bun-42ff5415ba7974c1e36697121b53a8299ea703bd.tar.gz bun-42ff5415ba7974c1e36697121b53a8299ea703bd.tar.zst bun-42ff5415ba7974c1e36697121b53a8299ea703bd.zip |
Merge branch 'main' of github.com:/Jarred-Sumner/bun into main
Diffstat (limited to '')
-rw-r--r-- | .devcontainer/devcontainer.json | 6 | ||||
-rw-r--r-- | .devcontainer/scripts/getting-started.sh | 19 | ||||
-rw-r--r-- | Dockerfile | 11 | ||||
-rw-r--r-- | README.md | 94 |
4 files changed, 53 insertions, 77 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..5fa8af83c 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 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 @@ -1070,6 +1070,34 @@ For compatibiltiy reasons, these NPM packages are embedded into Bun’s binary a Estimated: 30-90 minutes :( +### Linux + +Please use the VSCode Remote Container in this repository. + +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. + +Inside the container, run this: + +```bash +# First time setup +gh auth login +gh repo clone Jarred-Sumner/bun . -- --depth=1 --progress -j8 + +# 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 + +# Compile bun dependencies (zig is already compiled) +make devcontainer + +# Build Bun for development +make dev + +# Run bun +bun-debug +``` + +This container has Zig, zls, vscode-zig, and more setup automatically for you. It is very similar to my own development environment. + ### MacOS Install LLVM 12 and homebrew dependencies: @@ -1152,75 +1180,17 @@ brew install pkg-config If you see an error about missing files on `zig build obj`, make sure you built the headers -### 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. - -#### Compile Zig (Linux) - -```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) - -```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 -``` - -#### Verify it worked (Lunux) - -First ensure the node dependencies are installed - -```bash -cd integration/snippets -npm i -``` - -Then - -```bash -# if you’re not already in the bun root directory -cd ../../ -make test-dev-all -``` - -Run bun: - -```bash -packages/debug-bun-cli-darwin-x64/bin/bun-debug -``` - ## 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> |