blob: dd1d3d82a1f35505d344a274b79a44482c018fdb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
# Maintainer: Daniele Basso <d dot bass 05 at proton dot me>
pkgname=bun
pkgver=1.1.8
pkgrel=1
pkgdesc="Bun is a fast JavaScript all-in-one toolkit. This PKGBUILD builds from source, resulting into a smaller and faster binary depending on your CPU."
arch=(x86_64)
url="https://github.com/oven-sh/bun"
license=('GPL')
depends=(zlib libarchive mimalloc libuv sqlite)
makedepends=(
clang16 cmake esbuild git go icu libiconv libtool lld16 llvm16 ninja pkg-config python ruby rust unzip zig
)
conflicts=(bun-bin)
source=(git+$url.git#tag=bun-v$pkgver
bun-linux-x64-$pkgver.zip::https://github.com/oven-sh/bun/releases/download/bun-v$pkgver/bun-linux-x64.zip) # add "baseline" here to download the avx2-less build of bun!
b2sums=('d9f34e29168c098c14c5a5615ced208db1ae8b26ce1922eb05184db0899ccf4cca53848d23d1f1e65237c1a1566ce2ee12fae9694388da48c3bb51213609a011'
'6baced56b92e9577859c58f71d4f5ac036c08d972e51a4bf77b5223e385476ef21a689aac76fccd92debb18db55865042838361144d3ab8936dd94564a6329e6')
options=(!lto)
_j=$(($(nproc)/2)) #change for your system
prepare() {
cd bun
bash ./scripts/update-submodules.sh --webkit
bash ./scripts/set-webkit-submodule-to-cmake.sh
}
build() {
export PATH="${srcdir}/bun-linux-x64:$PATH"
cd bun
bun i
bash ./scripts/all-dependencies.sh
make runtime_js fallback_decoder bun_error node-fallbacks
cd src/bun.js/WebKit/
# Adapted from https://github.com/oven-sh/WebKit/blob/main/Dockerfile#L84
COMMON_FLAGS="-mno-omit-leaf-frame-pointer -fno-omit-frame-pointer -ffunction-sections -fdata-sections"
CC="/usr/bin/clang" CXX="/usr/bin/clang++" CFLAGS="${DEFAULT_CFLAGS} $CFLAGS" CXXFLAGS="${DEFAULT_CFLAGS} $CXXFLAGS" cmake \
-S . \
-B ./build \
-Wno-dev \
-DPORT="JSCOnly" \
-DENABLE_STATIC_JSC=ON \
-DENABLE_BUN_SKIP_FAILING_ASSERTIONS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DUSE_THIN_ARCHIVES=OFF \
-DUSE_BUN_JSC_ADDITIONS=ON \
-DENABLE_FTL_JIT=ON \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DALLOW_LINE_AND_COLUMN_NUMBER_IN_BUILTINS=ON \
-DENABLE_SINGLE_THREADED_VM_ENTRY_SCOPE=ON \
-DENABLE_REMOTE_INSPECTOR=ON \
-DCMAKE_EXE_LINKER_FLAGS="-fuse-ld=lld" \
-DCMAKE_AR="/usr/bin/llvm-ar" \
-DCMAKE_RANLIB="/usr/bin/llvm-ranlib" \
-GNinja
ninja -C ./build jsc -j$_j
mkdir -p ./output/{lib,include/JavaScriptCore,Source/JavaScriptCore}
cp -r ./build/lib/*.a ./output/lib
cp ./build/*.h ./output/include
find ./build/JavaScriptCore/Headers/JavaScriptCore/ -name "*.h" -exec cp {} ./output/include/JavaScriptCore/ \;
find ./build/JavaScriptCore/PrivateHeaders/JavaScriptCore/ -name "*.h" -exec cp {} ./output/include/JavaScriptCore/ \;
cp -r ./build/WTF/Headers/wtf/ ./output/include
cp -r ./build/bmalloc/Headers/bmalloc/ ./output/include
cp -r ./Source/JavaScriptCore/Scripts ./output/Source/JavaScriptCore
cp ./Source/JavaScriptCore/create_hash_table ./output/Source/JavaScriptCore
rm -rf ./output/include/unicode
cp -r /usr/include/unicode ./output/include/unicode
ln -sf /lib/libicudata.so ./output/lib/libicudata.a
ln -sf /lib/libicui18n.so ./output/lib/libicui18n.a
ln -sf /lib/libicuuc.so ./output/lib/libicuuc.a
CXXFLAGS="-Wno-unused-result ${CXXFLAGS}" cmake -B $srcdir/build -S $srcdir/$pkgname -Wno-dev -DCMAKE_BUILD_TYPE=Release -GNinja -DUSE_STATIC_LIBATOMIC=OFF \
-DLLVM_PREFIX=/usr/lib/llvm16/ -DWEBKIT_DIR=$srcdir/bun/src/bun.js/WebKit/output -DUSE_DEBUG_JSC=OFF -DZIG_OPTIMIZE=ReleaseFast #-DUSE_LTO=ON # -DZIG_COMPILER=system
#-DUSE_CUSTOM_ZLIB=OFF -DUSE_CUSTOM_LIBARCHIVE=OFF -DUSE_CUSTOM_MIMALLOC=OFF -DUSE_CUSTOM_LIBUV=OFF -DUSE_STATIC_SQLITE=OFF
ninja -C $srcdir/build -j$_j
}
package() {
install -Dm755 $srcdir/build/bun $pkgdir/usr/bin/bun
ln -s /usr/bin/bun $pkgdir/usr/bin/bunx
SHELL=zsh $pkgdir/usr/bin/bun completions > bun.zsh
SHELL=bash $pkgdir/usr/bin/bun completions > bun.bash
SHELL=fish $pkgdir/usr/bin/bun completions > bun.fish
install -Dm644 bun.zsh $pkgdir/usr/share/zsh/site-functions/_bun
install -Dm644 bun.bash $pkgdir/usr/share/bash-completion/completions/bun
install -Dm644 bun.fish $pkgdir/usr/share/fish/vendor_completions.d/bun.fish
}
|