Skip to content

Commit

Permalink
fix: nim (#1550)
Browse files Browse the repository at this point in the history
Signed-off-by: madomado <[email protected]>
  • Loading branch information
madonuko authored Jul 18, 2024
1 parent 4098ed0 commit e0831f3
Showing 1 changed file with 46 additions and 31 deletions.
77 changes: 46 additions & 31 deletions anda/langs/nim/nim/nim.spec
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ Release: 1%?dist
Summary: Imperative, multi-paradigm, compiled programming language
License: MIT and BSD
URL: https://nim-lang.org
Source0: https://nim-lang.org/download/nim-%{version}-linux_x64.tar.xz
Source1: nim.1
Source2: nimgrep.1
Source3: nimble.1
Source4: nimsuggest.1
BuildRequires: gcc mold git gcc-c++ nodejs openssl-devel pkgconfig(bash-completion) gc-devel pcre-devel
BuildRequires: gcc mold git-core gcc-c++ nodejs openssl-devel pkgconfig(bash-completion) gc-devel pcre-devel
Requires: gcc


Expand Down Expand Up @@ -46,7 +45,11 @@ and its standard library.


%prep
%autosetup -n nim-%{version}
rm -rf ./*
# using git clone to include submodules
git clone --recurse-submodules -j8 https://github.com/nim-lang/Nim -b v%version --depth 1 .
# hack
cp /usr/bin/mold /usr/bin/ld


%build
Expand All @@ -57,15 +60,18 @@ export FCFLAGS="${FCFLAGS} -Ofast"

export PATH="$(pwd):$(pwd)/bin:${PATH}"

mold -run nim c -d:danger koch.nim
mold -run koch boot -d:useLinenoise -t:-fPIE -l:-pie -d:release -d:nativeStacktrace -d:useGnuReadline
. ci/funs.sh
nimBuildCsourcesIfNeeded CFLAGS="${CFLAGS} -Ic_code -w -O3 -fno-strict-aliasing -fPIE" LDFLAGS="-ldl -lm -lrt -pie"

nim c --noNimblePath --skipUserCfg --skipParentCfg --hints:off -d:danger koch.nim
koch boot -d:release -d:nimStrictMode --lib:lib

%ifarch x86_64
mold -run koch docs &
koch docs &
%endif
(cd lib && nim c --app:lib -d:createNimRtl -d:release nimrtl.nim) &
mold -run koch tools -t:-fPIE -l:-pie &
mold -run nim c -t:-fPIE -l:-pie -d:release nimsuggest/nimsuggest.nim &
koch tools -t:-fPIE -l:-pie &
nim c -d:danger -t:-fPIE -l:-pie nimsuggest/nimsuggest.nim &
wait

%ifarch x86_64
Expand All @@ -75,24 +81,24 @@ sed -i '/<link.*fonts.googleapis.com/d' doc/html/*.html

%install
export PATH="$(pwd):$(pwd)/bin:${PATH}"
sh install.sh %{buildroot}usr/bin

mkdir -p %buildroot{%_bindir,%_prefix/lib/nim}
install -Dp -m755 bin/nim{,ble,grep,suggest,pretty} %buildroot/%_bindir
install -Dp -m644 dist/nimble/nimble.bash-completion %{buildroot}%{bashcompdir}/nimble
install -Dp -m644 -t%{buildroot}%{_mandir}/man1 %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4
# completions
for comp in tools/*.bash-completion; do
install -Dm644 $comp %bashcompdir/$(basename "${comp/.bash-completion}")
done
for comp in tools/*.zsh-completion; do
install -Dm644 $comp %zshcompdir/_$(basename "${comp/.zsh-completion}")
done

# --main:compiler/nim.nim
bin/nim cc -d:nimCallDepthLimit=10000 -r tools/niminst/niminst --var:version=%ver --var:mingw=none scripts compiler/installer.ini

sh ./install.sh %buildroot/usr/bin

mkdir -p %buildroot/%_bindir %buildroot/%_datadir/bash-completion/completions %buildroot/usr/lib/nim %buildroot%_datadir
install -Dpm755 bin/nim{grep,suggest,pretty} %buildroot/%_bindir
install -Dpm644 tools/nim.bash-completion %buildroot/%_datadir/bash-completion/completions/nim
install -Dpm644 dist/nimble/nimble.bash-completion %buildroot/%_datadir/bash-completion/completions/nimble
install -Dpm644 -t%buildroot/%_mandir/man1 %SOURCE1 %SOURCE2 %SOURCE3 %SOURCE4
mv %buildroot%_bindir/nim %buildroot%_datadir/
ln -s %_datadir/nim/bin/nim %buildroot%_bindir/nim

%ifarch x86_64
mkdir -p %buildroot%_docdir/%name/html
cp -a doc/html/*.html %buildroot%_docdir/%name/html/
cp tools/dochack/dochack.js %{buildroot}%{_docdir}/%{name}/
mkdir -p %buildroot/%_docdir/%name/html || true
cp -a doc/html/*.html %buildroot/%_docdir/%name/html/ || true
cp tools/dochack/dochack.js %buildroot/%_docdir/%name/ || true
ln -s %_datadir/nim/doc %buildroot%_prefix/lib/nim/doc
%endif

Expand All @@ -109,32 +115,41 @@ ln -s %_prefix/lib/nim %buildroot%_prefix/lib/nim/lib # compiler needs lib from
ln -s %_prefix/lib/nim/system.nim %_prefix/lib/system.nim # nimsuggest bug
rm -rf %buildroot/nim || true
rm %buildroot%_bindir/*.bat || true
rm -rf %buildroot%_bindir/empty.txt


%files
%license copying.txt dist/nimble/license.txt
%doc doc/readme.txt
/etc/nim/
%_sysconfdir/nim/
%_bindir/atlas
%_bindir/nim_dbg
%_bindir/nim-gdb
%_bindir/testament
%_bindir/nim
%_bindir/nimble
%_bindir/nim_csources_*
%_mandir/man1/nim.1*
%_mandir/man1/nimble.1*
%_prefix/lib/nim/
%_prefix/lib/libnimrtl.so
%{_bindir}/nim{,ble}
%{_mandir}/man1/nim{,ble}.1*
%_includedir/cycle.h
%_includedir/nimbase.h
%_datadir/nim
%bash_completion_dir/nim
%bash_completion_dir/nimble

%files tools
%license copying.txt
%_prefix/lib/nim/
%{_bindir}/nim{grep,suggest,pretty}
%{_mandir}/man1/nim{grep,suggest}.1*
%_bindir/nimgrep
%_bindir/nimsuggest
%_bindir/nimpretty
%_mandir/man1/nimgrep.1*
%_mandir/man1/nimsuggest.1*

%ifarch x86_64
%files doc
%doc %{_docdir}/nim
%doc %_docdir/nim
%endif

%changelog
Expand Down

0 comments on commit e0831f3

Please sign in to comment.