This repository has been archived by the owner on Sep 5, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·109 lines (81 loc) · 2.65 KB
/
build.sh
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
104
105
106
107
108
109
#!/bin/bash
set -e
# Ensure all submodules are present (recursive)
git submodule update --init --recursive
# Create build directory
rm -rf build
mkdir -p build
# Apply Boost patches
patch -p0 -f < boost.patch
# Configure Boost
cd boost
./bootstrap.sh
# Fix Boost config for Emscripten
sed -i "s|using gcc ;|using gcc : : \"$(which em++)\" ;|" project-config.jam
sed -i "s|toolset.flags gcc.archive .AR \\\$(condition) : \\\$(archiver\[1\])|toolset.flags gcc.archive .AR \\\$(condition) : \"$(which emar)\"|" tools/build/src/tools/gcc.jam
sed -i "s|toolset.flags gcc.archive .RANLIB \\\$(condition) : \\\$(ranlib\[1\])|toolset.flags gcc.archive .RANLIB \\\$(condition) : \"$(which emranlib)\"|" tools/build/src/tools/gcc.jam
# Build Boost
./b2 link=static variant=release threading=single runtime-link=static program_options filesystem system thread headers
# Collect Boost binaries
mkdir -p bin.v2/wasm
find bin.v2/libs -name '*.a' -exec cp -- "{}" bin.v2/wasm \;
# Clean up Boost
cd tools/build
git checkout .
cd ../../..
# Build Project Icestorm
cd icestorm
make -j `nproc`
sudo make install
cd ..
# Build Project Trellis
cd trellis/libtrellis
cmake .
make -j `nproc`
sudo make install
cd ../..
# Apply patches
patch -p0 -f < nextpnr.patch
patch -p0 -f < nextpnr-ice40.patch
cd nextpnr
### Start of nextpnr-ice40
# Configure nextpnr-ice40 natively
echo "Building nextpnr-ice40 natively..."
rm -rf CMakeCache.txt
cmake . -DARCH=ice40
# Build nextpnr-ice40 natively
(make -j `nproc` || true)
# Configure nextpnr-ice40 with Emscripten
echo "Building nextpnr-ice40 with Emscripten..."
rm -rf CMakeCache.txt
emcmake cmake . -DARCH=ice40 -DBBA_IMPORT=./bba-export.cmake -DBoost_INCLUDE_DIRS=../boost -DICESTORM_INSTALL_PREFIX=/usr/local
# Build nextpnr-ice40 with Emscripten
emmake make -j `nproc`
### End of nextpnr-ice40
### Start of nextpnr-ecp5
# Configure nextpnr-ecp5 natively
echo "Building nextpnr-ecp5 natively..."
rm -rf CMakeCache.txt
cmake . -DARCH=ecp5
# Build nextpnr-ecp5 natively
(make -j `nproc` || true)
# Configure nextpnr-ecp5 with Emscripten
echo "Building nextpnr-ecp5 with Emscripten..."
rm -rf CMakeCache.txt
emcmake cmake . -DARCH=ecp5 -DBBA_IMPORT=./bba-export.cmake -DBoost_INCLUDE_DIRS=../boost -DTRELLIS_INSTALL_PREFIX=/usr/local -DTRELLIS_LIBDIR=/usr/local/lib/trellis
# Build nextpnr-ecp5 with Emscripten
emmake make -j `nproc`
### End of nextpnr-ecp5
# Patch Emscripten build output
sed -i 's|var FS=|var FS=Module.FS=|' nextpnr*.js
mv nextpnr*.js ../build
cp nextpnr*.wasm ../build
# Clean up
make clean
cd ..
# Undo patches
patch -p0 -f -R < boost.patch
patch -p0 -f -R < nextpnr.patch
patch -p0 -f -R < nextpnr-ice40.patch
# Build npm package
yarn run build