commit 3478a1efe21661cda3227e77f3510f61e0f72410 Author: EnumDev Date: Fri Sep 19 22:13:51 2025 +0300 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3e58e5f --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Exclude bpm archives +*.bpm \ No newline at end of file diff --git a/check-version.sh b/check-version.sh new file mode 100644 index 0000000..c0c6d2c --- /dev/null +++ b/check-version.sh @@ -0,0 +1,12 @@ +#!/bin/bash + +# Github repository +REPO="nim-lang/Nim" + +# Get tag name using Github Rest API +TAG_NAME=$(curl -s -L -H "X-GitHub-Api-Version: 2022-11-28" -H "Authorization: token ${GITHUB_API_TOKEN}" https://api.github.com/repos/"$REPO"/tags | jq -r '.[0].name') + +# Trim 'v' character in TAG_NAME variable +VERSION=$(echo "$TAG_NAME" | tr -d 'v') + +echo "$VERSION" diff --git a/pkg.info b/pkg.info new file mode 100644 index 0000000..48505a4 --- /dev/null +++ b/pkg.info @@ -0,0 +1,8 @@ +name: nim +description: Statically typed compiled systems programming language +version: 2.2.4 +url: https://nim-lang.org/ +license: MIT +architecture: any +depends: ["bash","gcc","gcc-libs","glibc"] +type: source diff --git a/source.sh b/source.sh new file mode 100644 index 0000000..5c5d5b3 --- /dev/null +++ b/source.sh @@ -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 +}