Files
bun.sh/scripts/setup.sh
Jarred Sumner 7a4e0158d6 Lots of stuff (#7027)
* Use debug mode by default

* Enable build with assertions enabled

* Update cli.zig

* Update bun-linux-build.yml

* Fixes

* Fix `ASSERT_ENABLED`

* try this

* Update Dockerfile

* mimalloc debug

* Update CMakeLists.txt

* `Bun.deepMatch` - fix assertion failures

cc @dylan-conway, looks like we need to use `putDirectMayBeIndex` and check for `isCell` more carefully.

* Object.create support in code generator and callbacks wrapper

* Remove unused file

* zig upgrade

* zls

* Fix various errors

* Support `BuiltinAccessor` in create_hash_table script

* Fix assertion failure in `process.mainModule`

* Fix assertion failure in `onerror`

* Fix assertion failure when creating a Worker

* Fix asssertion failure when loading lots of files in bun test

* Fix assertion failure when termating a `Worker`

* Add helper for converting BunString to a WTFString

* Fix assertion failure in notifyNeedTermination

* Add more debug logs in `bun test`

* Fix compiler warning in usockets

* Fix assertion failure with `Worker` termination (another)

* Fix assertion failure in `coerceToInt64`

* Fix assertion failure in `BroadcastChannel`

* Fix assertion failure in `Headers.prototype.getAll`

* Fixes #7067

* Add heap analyzer label for CommonJS modules

* Fix assertion failure in module.require && module.require.resolve

* Remove unused code

* Fix assertion failure in debugger

* Fix crash in debugger

* Fix assertion failures in bun:sqlite

* Bump zig

* Bump WebKit

* Fix assertion failure in JSPromise::reject && JSInternalPromise::reject

* Fix assertion failure in ReadableStream::cancel

* Fix assertion failure in AsyncContextFrame::create

* Fix assertion failure in bun:sqlite

* Fix assertion failure in mocks

* Fix assertion failure in ServerWebSocket.close

* Fix assertion failure in N-API with subclasses

* [napi] Make promises cheaper

* undo

* Don't check for exceptions in ObjectInitializationScope

* Add separate entry point for test runner that doesn't generate code

* Don't deref builtin code

* Fix preload test

* Fix assertion failure in memoryUsage()

* Fix preload test, part 2

* Ensure that the env map for a Worker is empty after it is used

* The pointer for the Arena allocator used in parsing should not change

* Terminate thread on exit

* Start to implement scriptExecutionStatus

* Update worker.test.ts

* Fix Dirent.name setter

* Update settings.json

* Fix assertion failure in node:http

* Use correct value for `JSFinalObject::maxInlineCapacity`

* JSFinalObject::maxInlineCapacity x2

* Don't strip when assertions are enabled

* Make `m_wasTerminated` atomic

* Preserve directives in the transpiler

cc @ctjlewis

* Workaround assertion failure in ServerWebSocket.sendBinary and ServerWebSocket.sendText

* windows

* Buffer lockfile serialization in-memory

* PR feedback

* PR feedback

* PR feedback

* Windows

* quotes

* Update CMakeLists.txt

* Update bun-linux-build.yml

* Update bun-linux-build.yml

* Move this code to BunString.cpp

* Update BunString.cpp

---------

Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
2023-11-13 22:10:09 -08:00

101 lines
3.0 KiB
Bash
Executable File

#!/usr/bin/env bash
set -e
C_BOLD="\e[1;1m"
C_GREEN="\e[32m"
C_RED="\e[31m"
C_BLUE="\e[34m"
C_RESET="\e[0m"
has_exec() {
which "$1" >/dev/null 2>&1 || return 1
}
fail() {
printf "${C_RED}setup error${C_RESET}: %s\n" "$@"
exit 1
}
LLVM_VERSION=16
# this compiler detection could be better
# it is copy pasted from ./env.sh
CC=${CC:-$(which clang-16 || which clang || which cc)}
CXX=${CXX:-$(which clang++-16 || which clang++ || which c++)}
test -n "$CC" || fail "missing LLVM $LLVM_VERSION (could not find clang)"
test -n "$CXX" || fail "missing LLVM $LLVM_VERSION (could not find clang++)"
for type in CC CXX; do
compiler="${!type}"
$(
"$compiler" --version | grep "clang version ${LLVM_VERSION}." >/dev/null 2>&1
) || fail "LLVM ${LLVM_VERSION} is required. Detected $type as '$compiler'"
done
has_exec "bun" || fail "you need an existing copy of 'bun' in your path to build bun"
has_exec "cmake" || fail "'cmake' is missing"
has_exec "ninja" || fail "'ninja' is missing"
$(
has_exec "rustc" \
&& (test $(cargo --version | awk '{print $2}' | cut -d. -f2) -gt 57) \
&& has_exec "cargo"
) || fail "Rust and Cargo version must be installed (minimum version 1.57)"
has_exec "go" || fail "'go' is missing"
has_exec "pkg-config" || fail "'pkg-config' is missing"
has_exec "automake" || fail "'automake' is missing"
has_exec "perl" || fail "'perl' is missing"
has_exec "ruby" || fail "'ruby' is missing"
rm -f .vscode/clang++
ln -s "$CXX" .vscode/clang++
printf "All system dependencies OK\n"
printf "C Compiler for dependencies: ${CC}\n"
printf "C++ Compiler for dependencies: ${CXX}\n"
cd "$(dirname "${BASH_SOURCE[0]}")"
bash ./update-submodules.sh
bash ./all-dependencies.sh
cd ../
# Install bun dependencies
bun i
# Install test dependencies
cd test; bun i; cd ..
# TODO(@paperdave): do not use the Makefile please
make runtime_js fallback_decoder bun_error node-fallbacks
mkdir -p build
rm -f build/CMakeCache.txt
cmake -B build -S . -DUSE_DEBUG_JSC=ON -DCMAKE_BUILD_TYPE=Debug -G Ninja -DCMAKE_C_COMPILER="$CC" -DCMAKE_CXX_COMPILER="$CXX"
ninja -C build
printf "Checking if built bun functions\n"
BUN_VERSION=$(BUN_DEBUG_QUIET_LOGS=1 ./build/bun-debug --version)
printf "\n"
printf "🎉 ${C_GREEN}${C_BOLD}Development environment setup complete!${C_RESET}\n"
printf "${C_BLUE}bun v${BUN_VERSION} is located at ./build/bun-debug${C_RESET}\n"
if has_exec bun-debug; then
bun_is_at=$(which bun-debug)
if [ "$(realpath "$bun_is_at")" != "$(realpath "./build/bun-debug")" ]; then
printf "\n"
printf "${C_RED}"'Your $PATH is not configured correctly!\n'"${C_RESET}"
printf "\n"
printf "which bun-debug --> %s\n" "${bun_is_at}"
printf "\n"
printf "You should remove this binary and switch it to ./build:\n"
printf ' export PATH="$PATH:%s"\n' $(realpath "$PWD/build")
fi
else
printf "\n"
printf "You should add ./build to your path:\n"
printf ' export PATH="$PATH:%s"\n' $(realpath "$PWD/build")
fi
printf "\n"
printf "To rebuild bun, run '${C_GREEN}bun run build${C_RESET}'\n\n"