|
|
|
@@ -0,0 +1,77 @@
|
|
|
|
|
# This is the source.sh script. It is executed by BPM in a temporary directory when compiling a source package
|
|
|
|
|
# BPM Expects the source code to be extracted into the automatically created 'source' directory which can be accessed using $BPM_SOURCE
|
|
|
|
|
# BPM Expects the output files to be present in the automatically created 'output' directory which can be accessed using $BPM_OUTPUT
|
|
|
|
|
|
|
|
|
|
DOWNLOAD="https://nim-lang.org/download/nim-${BPM_PKG_VERSION}.tar.xz"
|
|
|
|
|
FILENAME="${DOWNLOAD##*/}"
|
|
|
|
|
|
|
|
|
|
# The prepare function is executed in the root of the temp directory
|
|
|
|
|
# This function is used for downloading files and putting them into the correct location
|
|
|
|
|
prepare() {
|
|
|
|
|
wget "$DOWNLOAD"
|
|
|
|
|
tar -xvf "$FILENAME" --strip-components=1 -C "$BPM_SOURCE"
|
|
|
|
|
|
|
|
|
|
cd "$BPM_SOURCE"
|
|
|
|
|
for nimcfg in {compiler,config}/nim.cfg; do
|
|
|
|
|
echo "gcc.options.always %= \"\${gcc.options.always} ${CFLAGS:-} ${CPPFLAGS}\"" >> "$nimcfg"
|
|
|
|
|
echo "gcc.options.linker %= \"\${gcc.options.linker} ${LDFLAGS:-}\"" >> "$nimcfg"
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The build function is executed in the source directory
|
|
|
|
|
# This function is used to compile the source code
|
|
|
|
|
build() {
|
|
|
|
|
# Compile nim
|
|
|
|
|
sh build.sh
|
|
|
|
|
|
|
|
|
|
# Compile koch
|
|
|
|
|
./bin/nim c -d:release koch
|
|
|
|
|
./koch boot -d:release -d:nativeStacktrace -d:useGnuReadline
|
|
|
|
|
|
|
|
|
|
# Compile libraries
|
|
|
|
|
( cd lib; ../bin/nim c --app:lib -d:createNimRtl -d:release nimrtl.nim )
|
|
|
|
|
|
|
|
|
|
# Compile tools
|
|
|
|
|
./koch tools
|
|
|
|
|
( cd tools; ../bin/nim c -d:release nimgrep.nim )
|
|
|
|
|
|
|
|
|
|
# Compile nimsuggest
|
|
|
|
|
./bin/nim c -d:release nimsuggest/nimsuggest.nim
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# The package function is executed in the source directory
|
|
|
|
|
# This function is used to move the compiled files into the output directory
|
|
|
|
|
package() {
|
|
|
|
|
./koch install "$BPM_OUTPUT"
|
|
|
|
|
|
|
|
|
|
# Install libraries and compiler
|
|
|
|
|
install -d "$BPM_OUTPUT"/usr/lib
|
|
|
|
|
cp -a lib "$BPM_OUTPUT"/usr/lib/nim
|
|
|
|
|
cp -a compiler "$BPM_OUTPUT"/usr/lib/nim
|
|
|
|
|
install -Dm644 nim.nimble "$BPM_OUTPUT"/usr/lib/nim/compiler
|
|
|
|
|
install -m755 lib/libnimrtl.so "$BPM_OUTPUT"/usr/lib/libnimrtl.so
|
|
|
|
|
|
|
|
|
|
# Install binaries
|
|
|
|
|
install -Dm755 bin/* -t "$BPM_OUTPUT"/usr/bin
|
|
|
|
|
|
|
|
|
|
# Install configuration
|
|
|
|
|
install -Dm644 config/* -t "$BPM_OUTPUT"/etc/nim
|
|
|
|
|
|
|
|
|
|
# Move header files
|
|
|
|
|
install -d "$BPM_OUTPUT"/usr/include
|
|
|
|
|
cp -a "$BPM_OUTPUT"/usr/lib/nim/*.h -t "$BPM_OUTPUT"/usr/include
|
|
|
|
|
|
|
|
|
|
# Fix wrong path for system.nim
|
|
|
|
|
ln -s /usr/lib/nim "$BPM_OUTPUT"/usr/lib/nim/lib
|
|
|
|
|
|
|
|
|
|
# Install shell completion
|
|
|
|
|
install -Dm644 tools/nim.bash-completion "$BPM_OUTPUT"/usr/share/bash-completion/completions/nim
|
|
|
|
|
install -Dm644 tools/nim.zsh-completion "$BPM_OUTPUT"/usr/share/zsh/site-functions/_nim
|
|
|
|
|
|
|
|
|
|
# Remove unwanted files
|
|
|
|
|
rm -r "$BPM_OUTPUT"/nim
|
|
|
|
|
|
|
|
|
|
# Install package license
|
|
|
|
|
install -Dm644 "$BPM_SOURCE"/copying.txt "$BPM_OUTPUT"/usr/share/licenses/nim/copying.txt
|
|
|
|
|
}
|