aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.devcontainer/devcontainer.json70
-rw-r--r--.devcontainer/limits.conf61
-rw-r--r--.devcontainer/scripts/common-debian.sh445
-rw-r--r--.devcontainer/scripts/getting-started.sh16
-rw-r--r--.devcontainer/scripts/github.sh185
-rw-r--r--.devcontainer/scripts/nice.sh7
-rw-r--r--.devcontainer/scripts/zig-env.sh8
-rw-r--r--.devcontainer/workspace.code-workspace9
-rw-r--r--.devcontainer/zls.json9
-rw-r--r--.vscode/launch.json10
-rw-r--r--Dockerfile106
-rw-r--r--Makefile122
-rw-r--r--build.zig232
-rw-r--r--run-dockerfile.sh3
14 files changed, 1028 insertions, 255 deletions
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 000000000..ac5728382
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,70 @@
+// For format details, see https://aka.ms/devcontainer.json. For config options, see the README at:
+// https://github.com/microsoft/vscode-dev-containers/tree/v0.209.6/containers/docker-existing-dockerfile
+{
+ "name": "Bun (Ubuntu)",
+
+ // Sets the run context to one level up instead of the .devcontainer folder.
+ "context": "..",
+
+ // Update the 'dockerFile' property if you aren't using the standard 'Dockerfile' filename.
+ "dockerFile": "../Dockerfile",
+
+ // Set *default* container specific settings.json values on container create.
+ "settings": {
+ "terminal.integrated.shell.linux": "/bin/zsh",
+ "zigLanguageClient.path": "/home/ubuntu/zls/zig-out/bin/zls",
+ "zig.zigPath": "/home/ubuntu/zig/zig",
+ "editor.defaultFormatter": "esbenp.prettier-vscode",
+ "[zig]": {
+ "editor.defaultFormatter": "tiehuis.zig"
+ }
+ },
+
+ // Add the IDs of extensions you want installed when the container is created.
+ "extensions": [
+ "AugusteRame.zls-vscode",
+ "ms-vscode.cpptools",
+ "/home/ubuntu/vscode-zig.vsix",
+ "vadimcn.vscode-lldb",
+ "esbenp.prettier-vscode",
+ "xaver.clang-format"
+ ],
+
+
+ "postCreateCommand": "cd /workspaces; bash /workspaces/getting-started.sh; zsh",
+
+ "build": {
+ "target": "dev",
+ "cacheFrom": "dev:latest",
+ "args": {}
+ },
+ "runArgs": [
+ "--ulimit", "memlock=-1:-1",
+ "--ulimit", "nofile=65536:65536",
+ "--cap-add=SYS_PTRACE", "--security-opt", "seccomp=unconfined"
+ ],
+ "workspaceMount": "source=bun-dev2,target=/workspaces,type=volume",
+ "workspaceFolder": "/workspaces/bun",
+ "mounts": [
+ "source=bun-install,target=/home/ubuntu/.bun,type=volume",
+ "source=bun-config,target=/home/ubuntu/.config,type=volume"
+ ],
+
+ // Use 'forwardPorts' to make a list of ports inside the container available locally.
+ "forwardPorts": [
+ 3000,
+ 8081,
+ 8080,
+ ],
+
+ // Uncomment the next line to run commands after the container is created - for example installing curl.
+ // "postCreateCommand": "apt-get update && apt-get install -y curl",
+
+ // Uncomment when using a ptrace-based debugger like C++, Go, and Rust
+
+ // Uncomment to use the Docker CLI from inside the container. See https://aka.ms/vscode-remote/samples/docker-from-docker.
+ // "mounts": [ "source=/var/run/docker.sock,target=/var/run/docker.sock,type=bind" ],
+
+ // Uncomment to connect as a non-root user if you've added one. See https://aka.ms/vscode-remote/containers/non-root.
+ // "remoteUser": "vscode"
+}
diff --git a/.devcontainer/limits.conf b/.devcontainer/limits.conf
new file mode 100644
index 000000000..6a391200d
--- /dev/null
+++ b/.devcontainer/limits.conf
@@ -0,0 +1,61 @@
+# /etc/security/limits.conf
+#
+#Each line describes a limit for a user in the form:
+#
+#<domain> <type> <item> <value>
+#
+#Where:
+#<domain> can be:
+# - a user name
+# - a group name, with @group syntax
+# - the wildcard *, for default entry
+# - the wildcard %, can be also used with %group syntax,
+# for maxlogin limit
+# - NOTE: group and wildcard limits are not applied to root.
+# To apply a limit to the root user, <domain> must be
+# the literal username root.
+#
+#<type> can have the two values:
+# - "soft" for enforcing the soft limits
+# - "hard" for enforcing hard limits
+#
+#<item> can be one of the following:
+# - core - limits the core file size (KB)
+# - data - max data size (KB)
+# - fsize - maximum filesize (KB)
+# - memlock - max locked-in-memory address space (KB)
+# - nofile - max number of open file descriptors
+# - rss - max resident set size (KB)
+# - stack - max stack size (KB)
+# - cpu - max CPU time (MIN)
+# - nproc - max number of processes
+# - as - address space limit (KB)
+# - maxlogins - max number of logins for this user
+# - maxsyslogins - max number of logins on the system
+# - priority - the priority to run user process with
+# - locks - max number of file locks the user can hold
+# - sigpending - max number of pending signals
+# - msgqueue - max memory used by POSIX message queues (bytes)
+# - nice - max nice priority allowed to raise to values: [-20, 19]
+# - rtprio - max realtime priority
+# - chroot - change root to directory (Debian-specific)
+#
+#<domain> <type> <item> <value>
+#
+
+* soft memlock 33554432
+* hard memlock 33554432
+* soft nofile 33554432
+* hard nofile 33554432
+
+#* soft core 0
+#root hard core 100000
+#* hard rss 10000
+#@student hard nproc 20
+#@faculty soft nproc 20
+#@faculty hard nproc 50
+#ftp hard nproc 0
+#ftp - chroot /ftp
+#@student - maxlogins 4
+
+# End of file
diff --git a/.devcontainer/scripts/common-debian.sh b/.devcontainer/scripts/common-debian.sh
new file mode 100644
index 000000000..5e33c2ce9
--- /dev/null
+++ b/.devcontainer/scripts/common-debian.sh
@@ -0,0 +1,445 @@
+#!/usr/bin/env bash
+#-------------------------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
+#-------------------------------------------------------------------------------------------------------------
+#
+# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/common.md
+# Maintainer: The VS Code and Codespaces Teams
+#
+# Syntax: ./common-debian.sh [install zsh flag] [username] [user UID] [user GID] [upgrade packages flag] [install Oh My Zsh! flag] [Add non-free packages]
+
+set -e
+
+INSTALL_ZSH=${1:-"true"}
+USERNAME=${2:-"automatic"}
+USER_UID=${3:-"automatic"}
+USER_GID=${4:-"automatic"}
+UPGRADE_PACKAGES=${5:-"true"}
+INSTALL_OH_MYS=${6:-"true"}
+ADD_NON_FREE_PACKAGES=${7:-"false"}
+SCRIPT_DIR="$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)"
+MARKER_FILE="/usr/local/etc/vscode-dev-containers/common"
+
+if [ "$(id -u)" -ne 0 ]; then
+ echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
+ exit 1
+fi
+
+# Ensure that login shells get the correct path if the user updated the PATH using ENV.
+rm -f /etc/profile.d/00-restore-env.sh
+echo "export PATH=${PATH//$(sh -lc 'echo $PATH')/\$PATH}" >/etc/profile.d/00-restore-env.sh
+chmod +x /etc/profile.d/00-restore-env.sh
+
+# If in automatic mode, determine if a user already exists, if not use vscode
+if [ "${USERNAME}" = "auto" ] || [ "${USERNAME}" = "automatic" ]; then
+ USERNAME=""
+ POSSIBLE_USERS=("vscode" "node" "codespace" "$(awk -v val=1000 -F ":" '$3==val{print $1}' /etc/passwd)")
+ for CURRENT_USER in ${POSSIBLE_USERS[@]}; do
+ if id -u ${CURRENT_USER} >/dev/null 2>&1; then
+ USERNAME=${CURRENT_USER}
+ break
+ fi
+ done
+ if [ "${USERNAME}" = "" ]; then
+ USERNAME=vscode
+ fi
+elif [ "${USERNAME}" = "none" ]; then
+ USERNAME=root
+ USER_UID=0
+ USER_GID=0
+fi
+
+# Load markers to see which steps have already run
+if [ -f "${MARKER_FILE}" ]; then
+ echo "Marker file found:"
+ cat "${MARKER_FILE}"
+ source "${MARKER_FILE}"
+fi
+
+# Ensure apt is in non-interactive to avoid prompts
+export DEBIAN_FRONTEND=noninteractive
+
+# Function to call apt-get if needed
+apt_get_update_if_needed() {
+ if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
+ echo "Running apt-get update..."
+ apt-get update
+ else
+ echo "Skipping apt-get update."
+ fi
+}
+
+# Run install apt-utils to avoid debconf warning then verify presence of other common developer tools and dependencies
+if [ "${PACKAGES_ALREADY_INSTALLED}" != "true" ]; then
+
+ package_list="apt-utils \
+ openssh-client \
+ gnupg2 \
+ dirmngr \
+ iproute2 \
+ procps \
+ lsof \
+ htop \
+ net-tools \
+ psmisc \
+ curl \
+ wget \
+ rsync \
+ ca-certificates \
+ unzip \
+ zip \
+ nano \
+ vim-tiny \
+ less \
+ jq \
+ lsb-release \
+ apt-transport-https \
+ dialog \
+ libc6 \
+ libgcc1 \
+ libkrb5-3 \
+ libgssapi-krb5-2 \
+ libicu[0-9][0-9] \
+ liblttng-ust0 \
+ libstdc++6 \
+ zlib1g \
+ locales \
+ sudo \
+ ncdu \
+ man-db \
+ strace \
+ manpages \
+ manpages-dev \
+ init-system-helpers"
+
+ # Needed for adding manpages-posix and manpages-posix-dev which are non-free packages in Debian
+ if [ "${ADD_NON_FREE_PACKAGES}" = "true" ]; then
+ # Bring in variables from /etc/os-release like VERSION_CODENAME
+ . /etc/os-release
+ sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
+ sed -i -E "s/deb-src http:\/\/(deb|httredir)\.debian\.org\/debian ${VERSION_CODENAME} main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME} main contrib non-free/" /etc/apt/sources.list
+ sed -i -E "s/deb http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
+ sed -i -E "s/deb-src http:\/\/(deb|httpredir)\.debian\.org\/debian ${VERSION_CODENAME}-updates main/deb http:\/\/\1\.debian\.org\/debian ${VERSION_CODENAME}-updates main contrib non-free/" /etc/apt/sources.list
+ sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
+ sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}\/updates main contrib non-free/" /etc/apt/sources.list
+ sed -i "s/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
+ sed -i "s/deb-src http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main/deb http:\/\/deb\.debian\.org\/debian ${VERSION_CODENAME}-backports main contrib non-free/" /etc/apt/sources.list
+ # Handle bullseye location for security https://www.debian.org/releases/bullseye/amd64/release-notes/ch-information.en.html
+ sed -i "s/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
+ sed -i "s/deb-src http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main/deb http:\/\/security\.debian\.org\/debian-security ${VERSION_CODENAME}-security main contrib non-free/" /etc/apt/sources.list
+ echo "Running apt-get update..."
+ apt-get update
+ package_list="${package_list} manpages-posix manpages-posix-dev"
+ else
+ apt_get_update_if_needed
+ fi
+
+ # Install libssl1.1 if available
+ if [[ ! -z $(apt-cache --names-only search ^libssl1.1$) ]]; then
+ package_list="${package_list} libssl1.1"
+ fi
+
+ # Install appropriate version of libssl1.0.x if available
+ libssl_package=$(dpkg-query -f '${db:Status-Abbrev}\t${binary:Package}\n' -W 'libssl1\.0\.?' 2>&1 || echo '')
+ if [ "$(echo "$LIlibssl_packageBSSL" | grep -o 'libssl1\.0\.[0-9]:' | uniq | sort | wc -l)" -eq 0 ]; then
+ if [[ ! -z $(apt-cache --names-only search ^libssl1.0.2$) ]]; then
+ # Debian 9
+ package_list="${package_list} libssl1.0.2"
+ elif [[ ! -z $(apt-cache --names-only search ^libssl1.0.0$) ]]; then
+ # Ubuntu 18.04, 16.04, earlier
+ package_list="${package_list} libssl1.0.0"
+ fi
+ fi
+
+ echo "Packages to verify are installed: ${package_list}"
+ apt-get -y install --no-install-recommends ${package_list} 2> >(grep -v 'debconf: delaying package configuration, since apt-utils is not installed' >&2)
+
+ # Install git if not already installed (may be more recent than distro version)
+ if ! type git >/dev/null 2>&1; then
+ apt-get -y install --no-install-recommends git
+ fi
+
+ PACKAGES_ALREADY_INSTALLED="true"
+fi
+
+# Get to latest versions of all packages
+if [ "${UPGRADE_PACKAGES}" = "true" ]; then
+ apt_get_update_if_needed
+ apt-get -y upgrade --no-install-recommends
+ apt-get autoremove -y
+fi
+
+# Ensure at least the en_US.UTF-8 UTF-8 locale is available.
+# Common need for both applications and things like the agnoster ZSH theme.
+if [ "${LOCALE_ALREADY_SET}" != "true" ] && ! grep -o -E '^\s*en_US.UTF-8\s+UTF-8' /etc/locale.gen >/dev/null; then
+ echo "en_US.UTF-8 UTF-8" >>/etc/locale.gen
+ locale-gen
+ LOCALE_ALREADY_SET="true"
+fi
+
+# Create or update a non-root user to match UID/GID.
+group_name="${USERNAME}"
+if id -u ${USERNAME} >/dev/null 2>&1; then
+ # User exists, update if needed
+ if [ "${USER_GID}" != "automatic" ] && [ "$USER_GID" != "$(id -g $USERNAME)" ]; then
+ group_name="$(id -gn $USERNAME)"
+ groupmod --gid $USER_GID ${group_name}
+ usermod --gid $USER_GID $USERNAME
+ fi
+ if [ "${USER_UID}" != "automatic" ] && [ "$USER_UID" != "$(id -u $USERNAME)" ]; then
+ usermod --uid $USER_UID $USERNAME
+ fi
+else
+ # Create user
+ if [ "${USER_GID}" = "automatic" ]; then
+ groupadd $USERNAME
+ else
+ groupadd --gid $USER_GID $USERNAME
+ fi
+ if [ "${USER_UID}" = "automatic" ]; then
+ useradd -s /bin/bash --gid $USERNAME -m $USERNAME
+ else
+ useradd -s /bin/bash --uid $USER_UID --gid $USERNAME -m $USERNAME
+ fi
+fi
+
+# Add add sudo support for non-root user
+if [ "${USERNAME}" != "root" ] && [ "${EXISTING_NON_ROOT_USER}" != "${USERNAME}" ]; then
+ echo $USERNAME ALL=\(root\) NOPASSWD:ALL >/etc/sudoers.d/$USERNAME
+ chmod 0440 /etc/sudoers.d/$USERNAME
+ EXISTING_NON_ROOT_USER="${USERNAME}"
+fi
+
+# ** Shell customization section **
+if [ "${USERNAME}" = "root" ]; then
+ user_rc_path="/root"
+else
+ user_rc_path="/home/${USERNAME}"
+fi
+
+# Restore user .bashrc defaults from skeleton file if it doesn't exist or is empty
+if [ ! -f "${user_rc_path}/.bashrc" ] || [ ! -s "${user_rc_path}/.bashrc" ]; then
+ cp /etc/skel/.bashrc "${user_rc_path}/.bashrc"
+fi
+
+# Restore user .profile defaults from skeleton file if it doesn't exist or is empty
+if [ ! -f "${user_rc_path}/.profile" ] || [ ! -s "${user_rc_path}/.profile" ]; then
+ cp /etc/skel/.profile "${user_rc_path}/.profile"
+fi
+
+# .bashrc/.zshrc snippet
+rc_snippet="$(
+ cat <<'EOF'
+if [ -z "${USER}" ]; then export USER=$(whoami); fi
+if [[ "${PATH}" != *"$HOME/.local/bin"* ]]; then export PATH="${PATH}:$HOME/.local/bin"; fi
+# Display optional first run image specific notice if configured and terminal is interactive
+if [ -t 1 ] && [[ "${TERM_PROGRAM}" = "vscode" || "${TERM_PROGRAM}" = "codespaces" ]] && [ ! -f "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed" ]; then
+ if [ -f "/usr/local/etc/vscode-dev-containers/first-run-notice.txt" ]; then
+ cat "/usr/local/etc/vscode-dev-containers/first-run-notice.txt"
+ elif [ -f "/workspaces/.codespaces/shared/first-run-notice.txt" ]; then
+ cat "/workspaces/.codespaces/shared/first-run-notice.txt"
+ fi
+ mkdir -p "$HOME/.config/vscode-dev-containers"
+ # Mark first run notice as displayed after 10s to avoid problems with fast terminal refreshes hiding it
+ ((sleep 10s; touch "$HOME/.config/vscode-dev-containers/first-run-notice-already-displayed") &)
+fi
+# Set the default git editor if not already set
+if [ -z "$(git config --get core.editor)" ] && [ -z "${GIT_EDITOR}" ]; then
+ if [ "${TERM_PROGRAM}" = "vscode" ]; then
+ if [[ -n $(command -v code-insiders) && -z $(command -v code) ]]; then
+ export GIT_EDITOR="code-insiders --wait"
+ else
+ export GIT_EDITOR="code --wait"
+ fi
+ fi
+fi
+EOF
+)"
+
+# code shim, it fallbacks to code-insiders if code is not available
+cat <<'EOF' >/usr/local/bin/code
+#!/bin/sh
+get_in_path_except_current() {
+ which -a "$1" | grep -A1 "$0" | grep -v "$0"
+}
+code="$(get_in_path_except_current code)"
+if [ -n "$code" ]; then
+ exec "$code" "$@"
+elif [ "$(command -v code-insiders)" ]; then
+ exec code-insiders "$@"
+else
+ echo "code or code-insiders is not installed" >&2
+ exit 127
+fi
+EOF
+chmod +x /usr/local/bin/code
+
+# systemctl shim - tells people to use 'service' if systemd is not running
+cat <<'EOF' >/usr/local/bin/systemctl
+#!/bin/sh
+set -e
+if [ -d "/run/systemd/system" ]; then
+ exec /bin/systemctl/systemctl "$@"
+else
+ echo '\n"systemd" is not running in this container due to its overhead.\nUse the "service" command to start services intead. e.g.: \n\nservice --status-all'
+fi
+EOF
+chmod +x /usr/local/bin/systemctl
+
+# Codespaces bash and OMZ themes - partly inspired by https://github.com/ohmyzsh/ohmyzsh/blob/master/themes/robbyrussell.zsh-theme
+codespaces_bash="$(
+ cat \
+ <<'EOF'
+# Codespaces bash prompt theme
+__bash_prompt() {
+ local userpart='`export XIT=$? \
+ && [ ! -z "${GITHUB_USER}" ] && echo -n "\[\033[0;32m\]@${GITHUB_USER} " || echo -n "\[\033[0;32m\]\u " \
+ && [ "$XIT" -ne "0" ] && echo -n "\[\033[1;31m\]➜" || echo -n "\[\033[0m\]➜"`'
+ local gitbranch='`\
+ if [ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ]; then \
+ export BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null || git rev-parse --short HEAD 2>/dev/null); \
+ if [ "${BRANCH}" != "" ]; then \
+ echo -n "\[\033[0;36m\](\[\033[1;31m\]${BRANCH}" \
+ && if git ls-files --error-unmatch -m --directory --no-empty-directory -o --exclude-standard ":/*" > /dev/null 2>&1; then \
+ echo -n " \[\033[1;33m\]✗"; \
+ fi \
+ && echo -n "\[\033[0;36m\]) "; \
+ fi; \
+ fi`'
+ local lightblue='\[\033[1;34m\]'
+ local removecolor='\[\033[0m\]'
+ PS1="${userpart} ${lightblue}\w ${gitbranch}${removecolor}\$ "
+ unset -f __bash_prompt
+}
+__bash_prompt
+EOF
+)"
+
+codespaces_zsh="$(
+ cat \
+ <<'EOF'
+# Codespaces zsh prompt theme
+__zsh_prompt() {
+ local prompt_username
+ if [ ! -z "${GITHUB_USER}" ]; then
+ prompt_username="@${GITHUB_USER}"
+ else
+ prompt_username="%n"
+ fi
+ PROMPT="%{$fg[green]%}${prompt_username} %(?:%{$reset_color%}➜ :%{$fg_bold[red]%}➜ )" # User/exit code arrow
+ PROMPT+='%{$fg_bold[blue]%}%(5~|%-1~/…/%3~|%4~)%{$reset_color%} ' # cwd
+ PROMPT+='$([ "$(git config --get codespaces-theme.hide-status 2>/dev/null)" != 1 ] && git_prompt_info)' # Git status
+ PROMPT+='%{$fg[white]%}$ %{$reset_color%}'
+ unset -f __zsh_prompt
+}
+ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[cyan]%}(%{$fg_bold[red]%}"
+ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
+ZSH_THEME_GIT_PROMPT_DIRTY=" %{$fg_bold[yellow]%}✗%{$fg_bold[cyan]%})"
+ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg_bold[cyan]%})"
+__zsh_prompt
+EOF
+)"
+
+# Add RC snippet and custom bash prompt
+if [ "${RC_SNIPPET_ALREADY_ADDED}" != "true" ]; then
+ echo "${rc_snippet}" >>/etc/bash.bashrc
+ echo "${codespaces_bash}" >>"${user_rc_path}/.bashrc"
+ echo 'export PROMPT_DIRTRIM=4' >>"${user_rc_path}/.bashrc"
+ if [ "${USERNAME}" != "root" ]; then
+ echo "${codespaces_bash}" >>"/root/.bashrc"
+ echo 'export PROMPT_DIRTRIM=4' >>"/root/.bashrc"
+ fi
+ chown ${USERNAME}:${group_name} "${user_rc_path}/.bashrc"
+ RC_SNIPPET_ALREADY_ADDED="true"
+fi
+
+# Optionally install and configure zsh and Oh My Zsh!
+if [ "${INSTALL_ZSH}" = "true" ]; then
+ if ! type zsh >/dev/null 2>&1; then
+ apt_get_update_if_needed
+ apt-get install -y zsh
+ fi
+ if [ "${ZSH_ALREADY_INSTALLED}" != "true" ]; then
+ echo "${rc_snippet}" >>/etc/zsh/zshrc
+ ZSH_ALREADY_INSTALLED="true"
+ fi
+
+ # Adapted, simplified inline Oh My Zsh! install steps that adds, defaults to a codespaces theme.
+ # See https://github.com/ohmyzsh/ohmyzsh/blob/master/tools/install.sh for official script.
+ oh_my_install_dir="${user_rc_path}/.oh-my-zsh"
+ if [ ! -d "${oh_my_install_dir}" ] && [ "${INSTALL_OH_MYS}" = "true" ]; then
+ template_path="${oh_my_install_dir}/templates/zshrc.zsh-template"
+ user_rc_file="${user_rc_path}/.zshrc"
+ umask g-w,o-w
+ mkdir -p ${oh_my_install_dir}
+ git clone --depth=1 \
+ -c core.eol=lf \
+ -c core.autocrlf=false \
+ -c fsck.zeroPaddedFilemode=ignore \
+ -c fetch.fsck.zeroPaddedFilemode=ignore \
+ -c receive.fsck.zeroPaddedFilemode=ignore \
+ "https://github.com/ohmyzsh/ohmyzsh" "${oh_my_install_dir}" 2>&1
+ echo -e "$(cat "${template_path}")\nDISABLE_AUTO_UPDATE=true\nDISABLE_UPDATE_PROMPT=true" >${user_rc_file}
+ sed -i -e 's/ZSH_THEME=.*/ZSH_THEME="codespaces"/g' ${user_rc_file}
+
+ mkdir -p ${oh_my_install_dir}/custom/themes
+ echo "${codespaces_zsh}" >"${oh_my_install_dir}/custom/themes/codespaces.zsh-theme"
+ # Shrink git while still enabling updates
+ cd "${oh_my_install_dir}"
+ git repack -a -d -f --depth=1 --window=1
+ # Copy to non-root user if one is specified
+ if [ "${USERNAME}" != "root" ]; then
+ cp -rf "${user_rc_file}" "${oh_my_install_dir}" /root
+ chown -R ${USERNAME}:${group_name} "${user_rc_path}"
+ fi
+ fi
+fi
+
+# Persist image metadata info, script if meta.env found in same directory
+meta_info_script="$(
+ cat <<'EOF'
+#!/bin/sh
+. /usr/local/etc/vscode-dev-containers/meta.env
+# Minimal output
+if [ "$1" = "version" ] || [ "$1" = "image-version" ]; then
+ echo "${VERSION}"
+ exit 0
+elif [ "$1" = "release" ]; then
+ echo "${GIT_REPOSITORY_RELEASE}"
+ exit 0
+elif [ "$1" = "content" ] || [ "$1" = "content-url" ] || [ "$1" = "contents" ] || [ "$1" = "contents-url" ]; then
+ echo "${CONTENTS_URL}"
+ exit 0
+fi
+#Full output
+echo
+echo "Development container image information"
+echo
+if [ ! -z "${VERSION}" ]; then echo "- Image version: ${VERSION}"; fi
+if [ ! -z "${DEFINITION_ID}" ]; then echo "- Definition ID: ${DEFINITION_ID}"; fi
+if [ ! -z "${VARIANT}" ]; then echo "- Variant: ${VARIANT}"; fi
+if [ ! -z "${GIT_REPOSITORY}" ]; then echo "- Source code repository: ${GIT_REPOSITORY}"; fi
+if [ ! -z "${GIT_REPOSITORY_RELEASE}" ]; then echo "- Source code release/branch: ${GIT_REPOSITORY_RELEASE}"; fi
+if [ ! -z "${BUILD_TIMESTAMP}" ]; then echo "- Timestamp: ${BUILD_TIMESTAMP}"; fi
+if [ ! -z "${CONTENTS_URL}" ]; then echo && echo "More info: ${CONTENTS_URL}"; fi
+echo
+EOF
+)"
+if [ -f "${SCRIPT_DIR}/meta.env" ]; then
+ mkdir -p /usr/local/etc/vscode-dev-containers/
+ cp -f "${SCRIPT_DIR}/meta.env" /usr/local/etc/vscode-dev-containers/meta.env
+ echo "${meta_info_script}" >/usr/local/bin/devcontainer-info
+ chmod +x /usr/local/bin/devcontainer-info
+fi
+
+# Write marker file
+mkdir -p "$(dirname "${MARKER_FILE}")"
+echo -e "\
+ PACKAGES_ALREADY_INSTALLED=${PACKAGES_ALREADY_INSTALLED}\n\
+ LOCALE_ALREADY_SET=${LOCALE_ALREADY_SET}\n\
+ EXISTING_NON_ROOT_USER=${EXISTING_NON_ROOT_USER}\n\
+ RC_SNIPPET_ALREADY_ADDED=${RC_SNIPPET_ALREADY_ADDED}\n\
+ ZSH_ALREADY_INSTALLED=${ZSH_ALREADY_INSTALLED}" >"${MARKER_FILE}"
+
+echo "Done!"
diff --git a/.devcontainer/scripts/getting-started.sh b/.devcontainer/scripts/getting-started.sh
new file mode 100644
index 000000000..a315f0fc0
--- /dev/null
+++ b/.devcontainer/scripts/getting-started.sh
@@ -0,0 +1,16 @@
+#!/bin/bash
+
+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 ""
+echo " gh auth login;"
+echo " gh repo clone Jarred-Sumner/bun -- --depth=1 --progress --recursive -j8"
+echo " cd bun;"
+echo " make devcontainer"
+echo ""
+echo "To build for development:"
+echo " make dev"
+echo ""
+echo "To run:"
+echo " bun-debug"
+echo ""
diff --git a/.devcontainer/scripts/github.sh b/.devcontainer/scripts/github.sh
new file mode 100644
index 000000000..0cc321dce
--- /dev/null
+++ b/.devcontainer/scripts/github.sh
@@ -0,0 +1,185 @@
+#!/usr/bin/env bash
+#-------------------------------------------------------------------------------------------------------------
+# Copyright (c) Microsoft Corporation. All rights reserved.
+# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
+#-------------------------------------------------------------------------------------------------------------
+#
+# Docs: https://github.com/microsoft/vscode-dev-containers/blob/main/script-library/docs/github.md
+# Maintainer: The VS Code and Codespaces Teams
+#
+# Syntax: ./github-debian.sh [version]
+
+CLI_VERSION=${1:-"latest"}
+
+GITHUB_CLI_ARCHIVE_GPG_KEY=C99B11DEB97541F0
+GPG_KEY_SERVERS="keyserver hkp://keyserver.ubuntu.com:80
+keyserver hkps://keys.openpgp.org
+keyserver hkp://keyserver.pgp.com"
+
+set -e
+
+if [ "$(id -u)" -ne 0 ]; then
+ echo -e 'Script must be run as root. Use sudo, su, or add "USER root" to your Dockerfile before running this script.'
+ exit 1
+fi
+
+# Get central common setting
+get_common_setting() {
+ if [ "${common_settings_file_loaded}" != "true" ]; then
+ curl -sfL "https://aka.ms/vscode-dev-containers/script-library/settings.env" -o /tmp/vsdc-settings.env 2>/dev/null || echo "Could not download settings file. Skipping."
+ common_settings_file_loaded=true
+ fi
+ if [ -f "/tmp/vsdc-settings.env" ]; then
+ local multi_line=""
+ if [ "$2" = "true" ]; then multi_line="-z"; fi
+ local result="$(grep ${multi_line} -oP "$1=\"?\K[^\"]+" /tmp/vsdc-settings.env | tr -d '\0')"
+ if [ ! -z "${result}" ]; then declare -g $1="${result}"; fi
+ fi
+ echo "$1=${!1}"
+}
+
+# Import the specified key in a variable name passed in as
+receive_gpg_keys() {
+ get_common_setting $1
+ local keys=${!1}
+ get_common_setting GPG_KEY_SERVERS true
+
+ # Use a temporary locaiton for gpg keys to avoid polluting image
+ export GNUPGHOME="/tmp/tmp-gnupg"
+ mkdir -p ${GNUPGHOME}
+ chmod 700 ${GNUPGHOME}
+ echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" >${GNUPGHOME}/dirmngr.conf
+ # GPG key download sometimes fails for some reason and retrying fixes it.
+ local retry_count=0
+ local gpg_ok="false"
+ set +e
+ until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; do
+ echo "(*) Downloading GPG key..."
+ (echo "${keys}" | xargs -n 1 gpg --recv-keys) 2>&1 && gpg_ok="true"
+ if [ "${gpg_ok}" != "true" ]; then
+ echo "(*) Failed getting key, retring in 10s..."
+ ((retry_count++))
+ sleep 10s
+ fi
+ done
+ set -e
+ if [ "${gpg_ok}" = "false" ]; then
+ echo "(!) Failed to get gpg key."
+ exit 1
+ fi
+}
+
+# Figure out correct version of a three part version number is not passed
+find_version_from_git_tags() {
+ local variable_name=$1
+ local requested_version=${!variable_name}
+ if [ "${requested_version}" = "none" ]; then return; fi
+ local repository=$2
+ local prefix=${3:-"tags/v"}
+ local separator=${4:-"."}
+ local last_part_optional=${5:-"false"}
+ if [ "$(echo "${requested_version}" | grep -o "." | wc -l)" != "2" ]; then
+ local escaped_separator=${separator//./\\.}
+ local last_part
+ if [ "${last_part_optional}" = "true" ]; then
+ last_part="(${escaped_separator}[0-9]+)?"
+ else
+ last_part="${escaped_separator}[0-9]+"
+ fi
+ local regex="${prefix}\\K[0-9]+${escaped_separator}[0-9]+${last_part}$"
+ local version_list="$(git ls-remote --tags ${repository} | grep -oP "${regex}" | tr -d ' ' | tr "${separator}" "." | sort -rV)"
+ if [ "${requested_version}" = "latest" ] || [ "${requested_version}" = "current" ] || [ "${requested_version}" = "lts" ]; then
+ declare -g ${variable_name}="$(echo "${version_list}" | head -n 1)"
+ else
+ set +e
+ declare -g ${variable_name}="$(echo "${version_list}" | grep -E -m 1 "^${requested_version//./\\.}([\\.\\s]|$)")"
+ set -e
+ fi
+ fi
+ if [ -z "${!variable_name}" ] || ! echo "${version_list}" | grep "^${!variable_name//./\\.}$" >/dev/null 2>&1; then
+ echo -e "Invalid ${variable_name} value: ${requested_version}\nValid values:\n${version_list}" >&2
+ exit 1
+ fi
+ echo "${variable_name}=${!variable_name}"
+}
+
+# Import the specified key in a variable name passed in as
+receive_gpg_keys() {
+ get_common_setting $1
+ local keys=${!1}
+ get_common_setting GPG_KEY_SERVERS true
+ local keyring_args=""
+ if [ ! -z "$2" ]; then
+ keyring_args="--no-default-keyring --keyring $2"
+ fi
+
+ # Use a temporary locaiton for gpg keys to avoid polluting image
+ export GNUPGHOME="/tmp/tmp-gnupg"
+ mkdir -p ${GNUPGHOME}
+ chmod 700 ${GNUPGHOME}
+ echo -e "disable-ipv6\n${GPG_KEY_SERVERS}" >${GNUPGHOME}/dirmngr.conf
+ # GPG key download sometimes fails for some reason and retrying fixes it.
+ local retry_count=0
+ local gpg_ok="false"
+ set +e
+ until [ "${gpg_ok}" = "true" ] || [ "${retry_count}" -eq "5" ]; do
+ echo "(*) Downloading GPG key..."
+ (echo "${keys}" | xargs -n 1 gpg -q ${keyring_args} --recv-keys) 2>&1 && gpg_ok="true"
+ if [ "${gpg_ok}" != "true" ]; then
+ echo "(*) Failed getting key, retring in 10s..."
+ ((retry_count++))
+ sleep 10s
+ fi
+ done
+ set -e
+ if [ "${gpg_ok}" = "false" ]; then
+ echo "(!) Failed to get gpg key."
+ exit 1
+ fi
+}
+
+# Function to run apt-get if needed
+apt_get_update_if_needed() {
+ if [ ! -d "/var/lib/apt/lists" ] || [ "$(ls /var/lib/apt/lists/ | wc -l)" = "0" ]; then
+ echo "Running apt-get update..."
+ apt-get update
+ else
+ echo "Skipping apt-get update."
+ fi
+}
+
+# Checks if packages are installed and installs them if not
+check_packages() {
+ if ! dpkg -s "$@" >/dev/null 2>&1; then
+ apt_get_update_if_needed
+ apt-get -y install --no-install-recommends "$@"
+ fi
+}
+
+export DEBIAN_FRONTEND=noninteractive
+
+# Install curl, apt-transport-https, curl, gpg, or dirmngr, git if missing
+check_packages curl ca-certificates apt-transport-https dirmngr gnupg2
+if ! type git >/dev/null 2>&1; then
+ apt_get_update_if_needed
+ apt-get -y install --no-install-recommends git
+fi
+
+# Soft version matching
+if [ "${CLI_VERSION}" != "latest" ] && [ "${CLI_VERSION}" != "lts" ] && [ "${CLI_VERSION}" != "stable" ]; then
+ find_version_from_git_tags CLI_VERSION "https://github.com/cli/cli"
+ version_suffix="=${CLI_VERSION}"
+else
+ version_suffix=""
+fi
+
+# Install the GitHub CLI
+echo "Downloading github CLI..."
+# Import key safely (new method rather than deprecated apt-key approach) and install
+. /etc/os-release
+receive_gpg_keys GITHUB_CLI_ARCHIVE_GPG_KEY /usr/share/keyrings/githubcli-archive-keyring.gpg
+echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages ${VERSION_CODENAME} main" >/etc/apt/sources.list.d/github-cli.list
+apt-get update
+apt-get -y install "gh${version_suffix}"
+rm -rf "/tmp/gh/gnupg"
+echo "Done!"
diff --git a/.devcontainer/scripts/nice.sh b/.devcontainer/scripts/nice.sh
new file mode 100644
index 000000000..d5f2a0601
--- /dev/null
+++ b/.devcontainer/scripts/nice.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+chsh -s $(which zsh)
+sh -c "$(curl -fsSL https://starship.rs/install.sh) -- --platform linux_musl"
+echo "eval \"$(starship init zsh)\"" >>~/.zshrc
+
+curl https://github.com/Jarred-Sumner/vscode-zig/releases/download/fork-v1/zig-0.2.5.vsix >/home/ubuntu/vscode-zig.vsix
diff --git a/.devcontainer/scripts/zig-env.sh b/.devcontainer/scripts/zig-env.sh
new file mode 100644
index 000000000..a0d3193c2
--- /dev/null
+++ b/.devcontainer/scripts/zig-env.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+curl -L https://github.com/Jarred-Sumner/vscode-zig/releases/download/fork-v1/zig-0.2.5.vsix >/home/ubuntu/vscode-zig.vsix
+git clone https://github.com/zigtools/zls /home/ubuntu/zls
+cd /home/ubuntu/zls
+git checkout e472fca3be6335f16032b48e40ca0d5ffda6ab0a
+git submodule update --init --recursive --progress --depth=1
+zig build -Drelease-fast
diff --git a/.devcontainer/workspace.code-workspace b/.devcontainer/workspace.code-workspace
new file mode 100644
index 000000000..1f83a1162
--- /dev/null
+++ b/.devcontainer/workspace.code-workspace
@@ -0,0 +1,9 @@
+{
+ "folders": [
+ {
+ // Source code
+ "name": "Bun",
+ "path": "bun"
+ },
+ ]
+} \ No newline at end of file
diff --git a/.devcontainer/zls.json b/.devcontainer/zls.json
new file mode 100644
index 000000000..832c8af47
--- /dev/null
+++ b/.devcontainer/zls.json
@@ -0,0 +1,9 @@
+{
+ "zig_exe_path": "/home/ubuntu/zig/zig",
+ "enable_snippets": true,
+ "warn_style": false,
+ "enable_semantic_tokens": true,
+ "operator_completions": true,
+ "include_at_in_builtins": false,
+ "max_detail_length": 1048576
+}
diff --git a/.vscode/launch.json b/.vscode/launch.json
index 2401938ca..8678aa0ca 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -1,12 +1,13 @@
{
"version": "0.2.0",
"configurations": [
+
{
"type": "lldb",
"request": "launch",
"name": "HTTP bench",
"program": "${workspaceFolder}/misctools/http_bench",
- "args": ["https://registry.npmjs.org/next", "--count=1"],
+ "args": ["https://example.com", "--count=80"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
@@ -15,7 +16,7 @@
"request": "launch",
"name": "fetch debug",
"program": "${workspaceFolder}/misctools/fetch",
- "args": ["https://api.github.com/repos/hanford/trends/tarball", "--verbose"],
+ "args": ["https://lodash.com", "--verbose"],
"cwd": "${workspaceFolder}",
"console": "internalConsole"
},
@@ -364,11 +365,10 @@
"request": "launch",
"name": "Install",
"program": "bun-debug",
- "args": ["install", "--backend=clonefile"],
- "cwd": "/Users/jarred/Build/athena",
+ "args": ["install", "--backend=clonefile", "--force"],
+ "cwd": "/Users/jarred/Build/octokit-test",
"env": {
- "BUN_CONFIG_NO_DEDUPLICATE": "1"
},
"console": "internalConsole"
},
diff --git a/Dockerfile b/Dockerfile
index ebf579284..b47f4ee2a 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,5 +1,4 @@
-# This builds bun in release mode
-FROM ubuntu:20.04
+FROM ubuntu:20.04 as ubuntu-base
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install --no-install-recommends -y wget gnupg2 curl lsb-release wget software-properties-common
@@ -36,7 +35,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
wget \
unzip \
tar \
- golang-go chromium-browser ninja-build pkg-config automake autoconf libtool
+ golang-go chromium-browser ninja-build pkg-config automake autoconf libtool curl
RUN update-alternatives --install /usr/bin/cc cc /usr/bin/clang-12 90 && \
update-alternatives --install /usr/bin/cpp cpp /usr/bin/clang++-12 90 && \
@@ -51,52 +50,113 @@ ENV ARCH "$BUILDARCH"
RUN npm install -g esbuild
-RUN wget https://github.com/Jarred-Sumner/zig/releases/download/dec20/zig-linux-$BUILDARCH.zip; \
- unzip zig-linux-$BUILDARCH.zip; \
+RUN curl -L https://github.com/Jarred-Sumner/zig/releases/download/dec20/zig-linux-$BUILDARCH.zip > zig-linux-$BUILDARCH.zip; \
+ unzip -q zig-linux-$BUILDARCH.zip; \
rm zig-linux-$BUILDARCH.zip;
ENV WEBKIT_OUT_DIR /home/ubuntu/bun-webkit
WORKDIR /home/ubuntu
-RUN wget https://github.com/Jarred-Sumner/WebKit/releases/download/Bun-v0/bun-webkit-linux-$BUILDARCH.tar.gz; \
- tar -xzvf bun-webkit-linux-$BUILDARCH.tar.gz; \
- rm bun-webkit-linux-$BUILDARCH.tar.gz && cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null
-ADD . /home/ubuntu/bun
+RUN curl -L https://github.com/Jarred-Sumner/WebKit/releases/download/Bun-v0/bun-webkit-linux-$BUILDARCH.tar.gz > bun-webkit-linux-$BUILDARCH.tar.gz; \
+ tar -xzf bun-webkit-linux-$BUILDARCH.tar.gz; \
+ rm bun-webkit-linux-$BUILDARCH.tar.gz && cat $WEBKIT_OUT_DIR/include/cmakeconfig.h > /dev/null
WORKDIR /home/ubuntu
-RUN wget https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz && \
+RUN curl -L https://github.com/unicode-org/icu/releases/download/release-66-1/icu4c-66_1-src.tgz > icu4c-66_1-src.tgz && \
tar -xzf icu4c-66_1-src.tgz && \
rm icu4c-66_1-src.tgz && \
cd icu/source && \
./configure --enable-static --disable-shared && \
- make -j$(nproc) && \
- make install
+ make -j$(nproc)
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
WORKDIR /home/ubuntu/bun
-RUN mkdir -p $BUN_RELEASE_DIR; \
- make \
- api \
- analytics \
- node-fallbacks \
- runtime_js \
- fallback_decoder \
- bun_error \
+
+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
+COPY src/js_lexer/identifier_cache.zig /home/ubuntu/bun/src/js_lexer/identifier_cache.zig
+COPY src/node-fallbacks /home/ubuntu/bun/src/node-fallbacks
+
+WORKDIR /home/ubuntu/bun
+
+RUN mkdir -p $BUN_DEPS_OUT_DIR; make \
mimalloc \
zlib \
libarchive \
boringssl \
picohttp \
- jsc-bindings-headers \
- jsc-bindings-mac \
identifier-cache \
- release \
+ node-fallbacks
+
+FROM ubuntu-base as prebuild
+
+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
+COPY --from=build_dependencies /home/ubuntu/bun/src/js_lexer/*.blob /home/ubuntu/bun/src/js_lexer
+
+WORKDIR /home/ubuntu/bun
+
+RUN make \
+ jsc-bindings-headers \
+ api \
+ analytics \
+ bun_error \
+ fallback_decoder
+
+FROM prebuild as build_release
+
+WORKDIR /home/ubuntu/bun
+
+RUN release \
copy-to-bun-release-dir
+
+
+FROM ubuntu:20.04 as release
+
+COPY --from=build_release /home/ubuntu/bun-release/bun /opt/bun/bin/bun
+COPY .devcontainer/limits.conf /etc/security/limits.conf
+
+ENV BUN_INSTALL /opt/bun
+ENV PATH "/opt/bun/bin:$PATH"
+
+
+FROM ubuntu-base as dev
+
+ENV WEBKIT_OUT_DIR /home/ubuntu/bun-webkit
+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"
+
+ENV BUN_INSTALL /home/ubuntu/.bun
+ENV XDG_CONFIG_HOME /home/ubuntu/.config
+
+RUN update-alternatives --install /usr/bin/lldb lldb /usr/bin/lldb-12 90
+
+COPY .devcontainer/workspace.code-workspace /workspaces/workspace.code-workspace
+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
+COPY .devcontainer/zls.json /home/ubuntu/.config/zls.json
+
+
+FROM release \ No newline at end of file
diff --git a/Makefile b/Makefile
index cb8c425ce..12524d58d 100644
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,8 @@ CXX = $(shell which clang++-12 || which clang++)
# macOS sed is different
SED = $(shell which gsed || which sed)
-DEPS_DIR = $(shell pwd)/src/deps
+BUN_DEPS_DIR ?= $(shell pwd)/src/deps
+BUN_DEPS_OUT_DIR ?= $(BUN_DEPS_DIR)
CPUS ?= $(shell nproc)
USER ?= $(echo $USER)
@@ -64,7 +65,7 @@ BUN_RELEASE_DIR ?= $(shell pwd)/../bun-release
OPENSSL_VERSION = OpenSSL_1_1_1l
LIBICONV_PATH ?= $(BREW_PREFIX_PATH)/opt/libiconv/lib/libiconv.a
-OPENSSL_LINUX_DIR = $(DEPS_DIR)/openssl/openssl-OpenSSL_1_1_1l
+OPENSSL_LINUX_DIR = $(BUN_DEPS_DIR)/openssl/openssl-OpenSSL_1_1_1l
CMAKE_FLAGS_WITHOUT_RELEASE = -DCMAKE_C_COMPILER=$(CC) -DCMAKE_CXX_COMPILER=$(CXX) -DCMAKE_OSX_DEPLOYMENT_TARGET=$(MIN_MACOS_VERSION)
CMAKE_FLAGS = $(CMAKE_FLAGS_WITHOUT_RELEASE) -DCMAKE_BUILD_TYPE=Release
@@ -79,9 +80,6 @@ ifeq ($(OS_NAME),linux)
LIBICONV_PATH =
endif
-build-iconv-linux:
- cd src/deps/libiconv/libiconv-1.16; ./configure --enable-static; make -j 12; cp ./lib/.libs/libiconv.a $(DEPS_DIR)/libiconv.a
-
BUN_TMP_DIR := /tmp/make-bun
BUN_DEPLOY_DIR = /tmp/bun-v$(PACKAGE_JSON_VERSION)/$(PACKAGE_NAME)
@@ -98,14 +96,14 @@ DEFAULT_JSC_LIB = $(JSC_BASE_DIR)/lib
endif
ifeq ($(OS_NAME),darwin)
-DEFAULT_JSC_LIB = src/deps
+DEFAULT_JSC_LIB = $(BUN_DEPS_DIR)
endif
JSC_LIB ?= $(DEFAULT_JSC_LIB)
JSC_INCLUDE_DIR ?= $(JSC_BASE_DIR)/include
-ZLIB_INCLUDE_DIR ?= $(DEPS_DIR)/zlib
-ZLIB_LIB_DIR ?= $(DEPS_DIR)/zlib
+ZLIB_INCLUDE_DIR ?= $(BUN_DEPS_DIR)/zlib
+ZLIB_LIB_DIR ?= $(BUN_DEPS_DIR)/zlib
JSC_FILES := $(JSC_LIB)/libJavaScriptCore.a $(JSC_LIB)/libWTF.a $(JSC_LIB)/libbmalloc.a
@@ -170,7 +168,7 @@ ICU_FLAGS :=
# TODO: find a way to make this more resilient
# Ideally, we could just look up the linker search paths
-LIB_ICU_PATH ?= $(DEPS_DIR)
+LIB_ICU_PATH ?= $(BUN_DEPS_DIR)
ifeq ($(OS_NAME),linux)
ICU_FLAGS += $(LIB_ICU_PATH)/libicuuc.a $(LIB_ICU_PATH)/libicudata.a $(LIB_ICU_PATH)/libicui18n.a
@@ -183,7 +181,7 @@ ICU_FLAGS += -l icucore \
endif
-BORINGSSL_PACKAGE = --pkg-begin boringssl $(DEPS_DIR)/boringssl.zig --pkg-end
+BORINGSSL_PACKAGE = --pkg-begin boringssl $(BUN_DEPS_DIR)/boringssl.zig --pkg-end
CLANG_FLAGS = $(INCLUDE_DIRS) \
-std=gnu++17 \
@@ -209,13 +207,13 @@ endif
-ARCHIVE_FILES_WITHOUT_LIBCRYPTO = src/deps/mimalloc/libmimalloc.a \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/picohttpparser.o \
+ARCHIVE_FILES_WITHOUT_LIBCRYPTO = $(BUN_DEPS_OUT_DIR)/libmimalloc.a \
+ $(BUN_DEPS_OUT_DIR)/libz.a \
+ $(BUN_DEPS_OUT_DIR)/libarchive.a \
+ $(BUN_DEPS_OUT_DIR)/libssl.a \
+ $(BUN_DEPS_OUT_DIR)/picohttpparser.o \
-ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) src/deps/libcrypto.boring.a
+ARCHIVE_FILES = $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) $(BUN_DEPS_OUT_DIR)/libcrypto.boring.a
PLATFORM_LINKER_FLAGS =
@@ -249,47 +247,38 @@ bun: vendor identifier-cache build-obj bun-link-lld-release bun-codesign-release
vendor-without-check: api analytics node-fallbacks runtime_js fallback_decoder bun_error mimalloc picohttp zlib boringssl libarchive
boringssl-build:
- cd $(DEPS_DIR)/boringssl && mkdir -p build && cd build && cmake $(CMAKE_FLAGS) -GNinja .. && ninja
+ cd $(BUN_DEPS_DIR)/boringssl && mkdir -p build && cd build && cmake $(CMAKE_FLAGS) -GNinja .. && ninja
boringssl-copy:
- cp $(DEPS_DIR)/boringssl/build/ssl/libssl.a $(DEPS_DIR)/libssl.a
- cp $(DEPS_DIR)/boringssl/build/crypto/libcrypto.a $(DEPS_DIR)/libcrypto.boring.a
+ cp $(BUN_DEPS_DIR)/boringssl/build/ssl/libssl.a $(BUN_DEPS_OUT_DIR)/libssl.a
+ cp $(BUN_DEPS_DIR)/boringssl/build/crypto/libcrypto.a $(BUN_DEPS_OUT_DIR)/libcrypto.boring.a
boringssl: boringssl-build boringssl-copy
libarchive:
- cd src/deps/libarchive; \
+ cd $(BUN_DEPS_DIR)/libarchive; \
(make clean || echo ""); \
(./build/clean.sh || echo ""); \
./build/autogen.sh; \
CFLAGS=$(CFLAGS) CC=$(CC) ./configure --disable-shared --enable-static --with-pic --disable-bsdtar --disable-bsdcat --disable-rpath --enable-posix-regex-lib --without-xml2 --without-expat --without-openssl --without-iconv --without-zlib; \
make -j${CPUS}; \
- cp ./.libs/libarchive.a $(DEPS_DIR)/libarchive.a;
+ cp ./.libs/libarchive.a $(BUN_DEPS_OUT_DIR)/libarchive.a;
tgz:
$(ZIG) build tgz-obj -Drelease-fast
- $(CXX) $(PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o
+ $(CXX) $(PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/tgz.o
tgz-debug:
$(ZIG) build tgz-obj
- $(CXX) $(DEBUG_PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o
+ $(CXX) $(DEBUG_PACKAGE_DIR)/tgz.o -g -o ./misctools/tgz $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(DEBUG_PACKAGE_DIR)/tgz.o
vendor: require init-submodules vendor-without-check
zlib:
- cd src/deps/zlib; cmake $(CMAKE_FLAGS) .; make CFLAGS=$(CFLAGS);
+ cd $(BUN_DEPS_DIR)/zlib; cmake $(CMAKE_FLAGS) .; make CFLAGS=$(CFLAGS);
+ cp $(BUN_DEPS_DIR)/zlib/libz.a $(BUN_DEPS_OUT_DIR)/libz.a
require:
@echo "Checking if the required utilities are available..."
@@ -353,45 +342,23 @@ generate-install-script:
fetch:
$(ZIG) build -Drelease-fast fetch-obj
- $(CXX) $(PACKAGE_DIR)/fetch.o -g -O3 -o ./misctools/fetch $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/mimalloc/libmimalloc.a \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o
+ $(CXX) $(PACKAGE_DIR)/fetch.o -g -O3 -o ./misctools/fetch $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/fetch.o
fetch-debug:
$(ZIG) build fetch-obj
- $(CXX) $(DEBUG_PACKAGE_DIR)/fetch.o -g -O3 -o ./misctools/fetch $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/mimalloc/libmimalloc.a \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o
+ $(CXX) $(DEBUG_PACKAGE_DIR)/fetch.o -g -O3 -o ./misctools/fetch $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
httpbench-debug:
$(ZIG) build httpbench-obj
- $(CXX) $(DEBUG_PACKAGE_DIR)/httpbench.o -g -o ./misctools/http_bench $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o \
+ $(CXX) $(DEBUG_PACKAGE_DIR)/httpbench.o -g -o ./misctools/http_bench $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(DEBUG_PACKAGE_DIR)/httpbench.o
httpbench-release:
$(ZIG) build -Drelease-fast httpbench-obj
- $(CXX) $(PACKAGE_DIR)/httpbench.o -g -O3 -o ./misctools/http_bench $(DEFAULT_LINKER_FLAGS) -lc \
- src/deps/zlib/libz.a \
- src/deps/libarchive.a \
- src/deps/libssl.a \
- src/deps/libcrypto.boring.a \
- src/deps/picohttpparser.o
+ $(CXX) $(PACKAGE_DIR)/httpbench.o -g -O3 -o ./misctools/http_bench $(DEFAULT_LINKER_FLAGS) -lc $(ARCHIVE_FILES)
rm -rf $(PACKAGE_DIR)/httpbench.o
bun-codesign-debug:
@@ -420,7 +387,9 @@ endif
jsc: jsc-build jsc-copy-headers jsc-bindings
jsc-build: $(JSC_BUILD_STEPS)
jsc-bindings: jsc-bindings-headers jsc-bindings-mac
-
+
+devcontainer: mimalloc zlib libarchive boringssl picohttp identifier-cache node-fallbacks jsc-bindings-headers api analytics bun_error fallback_decoder jsc-bindings-mac dev
+
jsc-bindings-headers:
rm -f /tmp/build-jsc-headers src/javascript/jsc/bindings/headers.zig
touch src/javascript/jsc/bindings/headers.zig
@@ -643,26 +612,27 @@ jsc-build-mac: jsc-build-mac-compile jsc-build-mac-copy
jsc-build-linux: jsc-build-linux-compile-config jsc-build-linux-compile-build jsc-build-mac-copy
jsc-build-mac-copy:
- cp $(WEBKIT_RELEASE_DIR)/lib/libJavaScriptCore.a src/deps/libJavaScriptCore.a
- cp $(WEBKIT_RELEASE_DIR)/lib/libWTF.a src/deps/libWTF.a
- cp $(WEBKIT_RELEASE_DIR)/lib/libbmalloc.a src/deps/libbmalloc.a
+ cp $(WEBKIT_RELEASE_DIR)/lib/libJavaScriptCore.a $(BUN_DEPS_OUT_DIR)/libJavaScriptCore.a
+ cp $(WEBKIT_RELEASE_DIR)/lib/libWTF.a $(BUN_DEPS_OUT_DIR)/libWTF.a
+ cp $(WEBKIT_RELEASE_DIR)/lib/libbmalloc.a $(BUN_DEPS_OUT_DIR)/libbmalloc.a
clean-bindings:
rm -rf $(OBJ_DIR)/*.o
clean: clean-bindings
- rm src/deps/*.a src/deps/*.o
- (cd src/deps/mimalloc && make clean) || echo "";
- (cd src/deps/libarchive && make clean) || echo "";
- (cd src/deps/boringssl && make clean) || echo "";
- (cd src/deps/picohttp && make clean) || echo "";
- (cd src/deps/zlib && make clean) || echo "";
+ rm $(BUN_DEPS_DIR)/*.a $(BUN_DEPS_DIR)/*.o
+ (cd $(BUN_DEPS_DIR)/mimalloc && make clean) || echo "";
+ (cd $(BUN_DEPS_DIR)/libarchive && make clean) || echo "";
+ (cd $(BUN_DEPS_DIR)/boringssl && make clean) || echo "";
+ (cd $(BUN_DEPS_DIR)/picohttp && make clean) || echo "";
+ (cd $(BUN_DEPS_DIR)/zlib && make clean) || echo "";
jsc-bindings-mac: $(OBJ_FILES)
mimalloc:
- cd src/deps/mimalloc; cmake $(CMAKE_FLAGS) .; make;
+ cd $(BUN_DEPS_DIR)/mimalloc; cmake $(CMAKE_FLAGS) .; make;
+ cp $(BUN_DEPS_DIR)/mimalloc/libmimalloc.a $(BUN_DEPS_OUT_DIR)/libmimalloc.a
bun-link-lld-debug:
$(CXX) $(BUN_LLD_FLAGS) \
@@ -703,7 +673,7 @@ sizegen:
$(BUN_TMP_DIR)/sizegen > src/javascript/jsc/bindings/sizes.zig
picohttp:
- $(CC) $(MARCH_NATIVE) $(MACOS_MIN_FLAG) -O3 -g -fPIE -c src/deps/picohttpparser/picohttpparser.c -Isrc/deps -o src/deps/picohttpparser.o; cd ../../
+ $(CC) $(MARCH_NATIVE) $(MACOS_MIN_FLAG) -O3 -g -fPIE -c $(BUN_DEPS_DIR)/picohttpparser/picohttpparser.c -I$(BUN_DEPS_DIR) -o $(BUN_DEPS_OUT_DIR)/picohttpparser.o; cd ../../
analytics:
./node_modules/.bin/peechy --schema src/analytics/schema.peechy --zig src/analytics/analytics_schema.zig
@@ -799,8 +769,8 @@ build-unit:
@mkdir -p zig-out/bin
zig test $(realpath $(testpath)) \
$(testfilterflag) \
- --pkg-begin picohttp $(DEPS_DIR)/picohttp.zig --pkg-end \
- --pkg-begin clap $(DEPS_DIR)/zig-clap/clap.zig --pkg-end \
+ --pkg-begin picohttp $(BUN_DEPS_DIR)/picohttp.zig --pkg-end \
+ --pkg-begin clap $(BUN_DEPS_DIR)/zig-clap/clap.zig --pkg-end \
--main-pkg-path $(shell pwd) \
--test-no-exec \
-fPIC \
@@ -809,9 +779,7 @@ build-unit:
-lc -lc++ \
--cache-dir /tmp/zig-cache-bun-$(testname)-$(basename $(lastword $(testfilter))) \
-fallow-shlib-undefined \
- -L$(LIBCRYPTO_PREFIX_DIR)/lib \
- -lcrypto -lssl \
- $(ARCHIVE_FILES_WITHOUT_LIBCRYPTO) $(ICU_FLAGS) && \
+ $(ARCHIVE_FILES) $(ICU_FLAGS) && \
cp zig-out/bin/$(testname) $(testbinpath)
run-unit:
diff --git a/build.zig b/build.zig
index afd7a601e..b2bbe861e 100644
--- a/build.zig
+++ b/build.zig
@@ -106,6 +106,28 @@ fn panicIfNotFound(comptime filepath: []const u8) []const u8 {
return filepath;
}
+fn updateRuntime() anyerror!void {
+ var runtime_out_file = try std.fs.cwd().openFile("src/runtime.out.js", .{ .read = true });
+ const runtime_hash = std.hash.Wyhash.hash(
+ 0,
+ try runtime_out_file.readToEndAlloc(std.heap.page_allocator, try runtime_out_file.getEndPos()),
+ );
+ const runtime_version_file = std.fs.cwd().createFile("src/runtime.version", .{ .truncate = true }) catch std.debug.panic("Failed to create src/runtime.version", .{});
+ defer runtime_version_file.close();
+ runtime_version_file.writer().print("{x}", .{runtime_hash}) catch unreachable;
+ var fallback_out_file = try std.fs.cwd().openFile("src/fallback.out.js", .{ .read = true });
+ const fallback_hash = std.hash.Wyhash.hash(
+ 0,
+ try fallback_out_file.readToEndAlloc(std.heap.page_allocator, try fallback_out_file.getEndPos()),
+ );
+
+ const fallback_version_file = std.fs.cwd().createFile("src/fallback.version", .{ .truncate = true }) catch std.debug.panic("Failed to create src/fallback.version", .{});
+
+ fallback_version_file.writer().print("{x}", .{fallback_hash}) catch unreachable;
+
+ fallback_version_file.close();
+}
+
var x64 = "x64";
var mode: std.builtin.Mode = undefined;
pub fn build(b: *std.build.Builder) !void {
@@ -220,184 +242,101 @@ pub fn build(b: *std.build.Builder) !void {
exe.setOutputDir(output_dir);
var cwd_dir = std.fs.cwd();
- var runtime_out_file = try std.fs.cwd().openFile("src/runtime.out.js", .{ .read = true });
- const runtime_hash = std.hash.Wyhash.hash(
- 0,
- try runtime_out_file.readToEndAlloc(b.allocator, try runtime_out_file.getEndPos()),
- );
- const runtime_version_file = std.fs.cwd().createFile("src/runtime.version", .{ .truncate = true }) catch std.debug.panic("Failed to create src/runtime.version", .{});
- defer runtime_version_file.close();
- runtime_version_file.writer().print("{x}", .{runtime_hash}) catch unreachable;
- var fallback_out_file = try std.fs.cwd().openFile("src/fallback.out.js", .{ .read = true });
- const fallback_hash = std.hash.Wyhash.hash(
- 0,
- try fallback_out_file.readToEndAlloc(b.allocator, try fallback_out_file.getEndPos()),
- );
-
- const fallback_version_file = std.fs.cwd().createFile("src/fallback.version", .{ .truncate = true }) catch std.debug.panic("Failed to create src/fallback.version", .{});
-
- fallback_version_file.writer().print("{x}", .{fallback_hash}) catch unreachable;
-
- defer fallback_version_file.close();
+ updateRuntime() catch {};
exe.setTarget(target);
exe.setBuildMode(mode);
b.install_path = output_dir;
- var javascript = b.addExecutable("spjs", "src/main_javascript.zig");
var typings_exe = b.addExecutable("typescript-decls", "src/javascript/jsc/typescript.zig");
- javascript.setMainPkgPath(b.pathFromRoot("."));
typings_exe.setMainPkgPath(b.pathFromRoot("."));
- exe.setMainPkgPath(b.pathFromRoot("."));
// exe.want_lto = true;
- if (!target.getCpuArch().isWasm()) {
- b.default_step.dependOn(&exe.step);
- const bindings_dir = std.fs.path.join(
- b.allocator,
- &.{
- cwd,
- "src",
- "javascript",
- "jsc",
- "bindings-obj",
+ {
+ b.default_step.dependOn(&b.addLog(
+ "Build {s} v{} - v{}",
+ .{
+ triplet,
+ target.getOsVersionMin().semver,
+ target.getOsVersionMax().semver,
},
- ) catch unreachable;
-
- var bindings_dir_ = cwd_dir.openDir(bindings_dir, .{ .iterate = true }) catch std.debug.panic("Error opening bindings directory. Please make sure you ran `make jsc`. {s} should exist", .{bindings_dir});
- var bindings_walker = bindings_dir_.walk(b.allocator) catch std.debug.panic("Error reading bindings directory {s}", .{bindings_dir});
+ ).step);
+ }
- var bindings_files = std.ArrayList([]const u8).init(b.allocator);
+ var obj_step = b.step("obj", "Build Bun as a .o file");
+ var obj = b.addObject(bun_executable_name, exe.root_src.?.path);
- while (bindings_walker.next() catch unreachable) |entry| {
- if (std.mem.eql(u8, std.fs.path.extension(entry.basename), ".o")) {
- bindings_files.append(bindings_dir_.realpathAlloc(b.allocator, entry.path) catch unreachable) catch unreachable;
- }
- }
+ {
+ obj.setTarget(target);
+ addPicoHTTP(obj, false);
+ obj.setMainPkgPath(b.pathFromRoot("."));
- // // References:
- // // - https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/webkit.gyp
- // // - https://github.com/mceSystems/node-jsc/blob/master/deps/jscshim/docs/webkit_fork_and_compilation.md#webkit-port-and-compilation
- // const flags = [_][]const u8{
- // "-Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/JavaScriptCore/PrivateHeaders",
- // "-Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/WTF/Headers",
- // "-Isrc/javascript/jsc/WebKit/WebKitBuild/Release/ICU/Headers",
- // "-DSTATICALLY_LINKED_WITH_JavaScriptCore=1",
- // "-DSTATICALLY_LINKED_WITH_WTF=1",
- // "-DBUILDING_WITH_CMAKE=1",
- // "-DNOMINMAX",
- // "-DENABLE_INSPECTOR_ALTERNATE_DISPATCHERS=0",
- // "-DBUILDING_JSCONLY__",
- // "-DASSERT_ENABLED=0", // missing symbol errors like this will happen "JSC::DFG::DoesGCCheck::verifyCanGC(JSC::VM&)"
- // "-Isrc/JavaScript/jsc/WebKit/WebKitBuild/Release/", // config.h,
- // "-Isrc/JavaScript/jsc/bindings/",
- // "-Isrc/javascript/jsc/WebKit/Source/bmalloc",
- // "-std=gnu++17",
- // if (target.getOsTag() == .macos) "-DUSE_FOUNDATION=1" else "",
- // if (target.getOsTag() == .macos) "-DUSE_CF_RETAIN_PTR=1" else "",
- // };
+ try addInternalPackages(
+ obj,
+ b.allocator,
+ target,
+ );
{
- b.default_step.dependOn(&b.addLog(
- "Build {s} v{} - v{}",
+ obj_step.dependOn(&b.addLog(
+ "Build {s} v{} - v{}\n",
.{
triplet,
- target.getOsVersionMin().semver,
- target.getOsVersionMax().semver,
+ obj.target.getOsVersionMin().semver,
+ obj.target.getOsVersionMax().semver,
},
).step);
}
- b.default_step.dependOn(&exe.step);
- {
- var obj_step = b.step("obj", "Build Bun as a .o file");
- var obj = b.addObject(bun_executable_name, exe.root_src.?.path);
- obj.setTarget(target);
- addPicoHTTP(obj, false);
-
- try addInternalPackages(
- obj,
- b.allocator,
- target,
- );
-
- {
- obj_step.dependOn(&b.addLog(
- "Build {s} v{} - v{}\n",
- .{
- triplet,
- obj.target.getOsVersionMin().semver,
- obj.target.getOsVersionMax().semver,
- },
- ).step);
- }
-
- obj_step.dependOn(&obj.step);
-
- obj.setOutputDir(output_dir);
- obj.setBuildMode(mode);
- obj.linkLibC();
- obj.linkLibCpp();
-
- obj.strip = false;
- obj.bundle_compiler_rt = true;
-
- if (target.getOsTag() == .linux) {
- // obj.want_lto = tar;
- obj.link_emit_relocs = true;
- obj.link_function_sections = true;
- }
- }
+ obj_step.dependOn(&obj.step);
- {
- const headers_step = b.step("headers-obj", "Build JavaScriptCore headers");
- var headers_obj: *std.build.LibExeObjStep = b.addObject("headers", "src/bindgen.zig");
- defer headers_step.dependOn(&headers_obj.step);
- try configureObjectStep(headers_obj, target, exe.main_pkg_path.?);
- }
+ obj.setOutputDir(output_dir);
+ obj.setBuildMode(mode);
+ obj.linkLibC();
+ obj.linkLibCpp();
- {
- const headers_step = b.step("httpbench-obj", "Build HTTPBench tool (object files)");
- var headers_obj: *std.build.LibExeObjStep = b.addObject("httpbench", "misctools/http_bench.zig");
- defer headers_step.dependOn(&headers_obj.step);
- try configureObjectStep(headers_obj, target, exe.main_pkg_path.?);
- }
+ obj.strip = false;
+ obj.bundle_compiler_rt = true;
- {
- const headers_step = b.step("fetch-obj", "Build fetch (object files)");
- var headers_obj: *std.build.LibExeObjStep = b.addObject("fetch", "misctools/fetch.zig");
- defer headers_step.dependOn(&headers_obj.step);
- try configureObjectStep(headers_obj, target, exe.main_pkg_path.?);
- }
+ b.default_step.dependOn(&obj.step);
- {
- const headers_step = b.step("tgz-obj", "Build tgz (object files)");
- var headers_obj: *std.build.LibExeObjStep = b.addObject("tgz", "misctools/tgz.zig");
- defer headers_step.dependOn(&headers_obj.step);
- try configureObjectStep(headers_obj, target, exe.main_pkg_path.?);
+ if (target.getOsTag() == .linux) {
+ // obj.want_lto = tar;
+ obj.link_emit_relocs = true;
+ obj.link_function_sections = true;
}
- } else {
- b.default_step.dependOn(&exe.step);
+ var log_step = b.addLog("Destination: {s}/{s}\n", .{ output_dir, bun_executable_name });
+ log_step.step.dependOn(&obj.step);
}
- javascript.strip = false;
- javascript.packages = std.ArrayList(std.build.Pkg).fromOwnedSlice(b.allocator, b.allocator.dupe(std.build.Pkg, exe.packages.items) catch unreachable);
-
- javascript.setOutputDir(output_dir);
- javascript.setBuildMode(mode);
+ {
+ const headers_step = b.step("headers-obj", "Build JavaScriptCore headers");
+ var headers_obj: *std.build.LibExeObjStep = b.addObject("headers", "src/bindgen.zig");
+ defer headers_step.dependOn(&headers_obj.step);
+ try configureObjectStep(headers_obj, target, obj.main_pkg_path.?);
+ }
- const run_cmd = exe.run();
- run_cmd.step.dependOn(b.getInstallStep());
- if (b.args) |args| {
- run_cmd.addArgs(args);
+ {
+ const headers_step = b.step("httpbench-obj", "Build HTTPBench tool (object files)");
+ var headers_obj: *std.build.LibExeObjStep = b.addObject("httpbench", "misctools/http_bench.zig");
+ defer headers_step.dependOn(&headers_obj.step);
+ try configureObjectStep(headers_obj, target, obj.main_pkg_path.?);
}
- const run_step = b.step("run", "Run the app");
- run_step.dependOn(&run_cmd.step);
+ {
+ const headers_step = b.step("fetch-obj", "Build fetch (object files)");
+ var headers_obj: *std.build.LibExeObjStep = b.addObject("fetch", "misctools/fetch.zig");
+ defer headers_step.dependOn(&headers_obj.step);
+ try configureObjectStep(headers_obj, target, obj.main_pkg_path.?);
+ }
- var log_step = b.addLog("Destination: {s}/{s}\n", .{ output_dir, bun_executable_name });
- log_step.step.dependOn(&exe.step);
+ {
+ const headers_step = b.step("tgz-obj", "Build tgz (object files)");
+ var headers_obj: *std.build.LibExeObjStep = b.addObject("tgz", "misctools/tgz.zig");
+ defer headers_step.dependOn(&headers_obj.step);
+ try configureObjectStep(headers_obj, target, obj.main_pkg_path.?);
+ }
var typings_cmd: *std.build.RunStep = typings_exe.run();
typings_cmd.cwd = cwd;
@@ -412,9 +351,6 @@ pub fn build(b: *std.build.Builder) !void {
var typings_step = b.step("types", "Build TypeScript types");
typings_step.dependOn(&typings_cmd.step);
-
- var javascript_cmd = b.step("spjs", "Build standalone JavaScript runtime. Must run \"make jsc\" first.");
- javascript_cmd.dependOn(&javascript.step);
}
pub var original_make_fn: ?fn (step: *std.build.Step) anyerror!void = null;
diff --git a/run-dockerfile.sh b/run-dockerfile.sh
index 63fbb04da..8817aff04 100644
--- a/run-dockerfile.sh
+++ b/run-dockerfile.sh
@@ -37,7 +37,7 @@ export TEMP=/tmp/bun-0.0.$BUILD_ID
rm -rf $TEMP
mkdir -p $TEMP
-docker build . -t $CONTAINER_NAME --progress=plain --platform=linux/$BUILDKIT_ARCH
+docker build . --target build_release --progress=plain -t $CONTAINER_NAME:latest --build-arg BUILDKIT_INLINE_CACHE=1 --platform=linux/aarch64 --cache-from $CONTAINER_NAME:latest
if (($?)); then
echo "Failed to build container"
@@ -57,7 +57,6 @@ mv $CONTAINER_NAME/bun-profile $DEBUG_CONTAINER_NAME/bun
zip -r $CONTAINER_NAME.zip $CONTAINER_NAME
zip -r $DEBUG_CONTAINER_NAME.zip $DEBUG_CONTAINER_NAME
docker rm -v $id
-docker tag $CONTAINER_NAME:latest ghcr.io/jarred-sumner/$CONTAINER_NAME:latest
abs=$(realpath $TEMP/$CONTAINER_NAME.zip)
debug_abs=$(realpath $TEMP/$DEBUG_CONTAINER_NAME.zip)