231 lines
8.5 KiB
RPMSpec
231 lines
8.5 KiB
RPMSpec
# Generated by go2rpm 1
|
|
%bcond_without check
|
|
|
|
%global __brp_strip_lto %{nil}
|
|
%global __brp_strip_static_archive %{nil}
|
|
|
|
# https://github.com/tinygo-org/tinygo
|
|
%global goipath github.com/tinygo-org/tinygo
|
|
Version: 0.20.0
|
|
|
|
%global CMSIS_commit 9fe411cef1cef5de58e5957b89760759de44e393
|
|
%global avr_commit 6624554c02b237b23dc17d53e992bf54033fc228
|
|
%global clang_llvm_version 11
|
|
%global cmsis_svd_commit df75ff974c76a911fc2815e29807f5ecaae06fc2
|
|
%global compiler_rt_version 9.0.0
|
|
%global nrfx_commit d779b49fc59c7a165e7da1d7cd7d57b28a059f16
|
|
%global picolibc_commit 80528c684b10aaee977397e7eb40c4784e6dc433
|
|
%global wasi_libc_commit 215adc8ac9f91eb055311acc72683fd2eb1ae15a
|
|
|
|
# No longer matching regular Go's /usr/share/gocode because it also provides
|
|
# pre-compiled binaries, and symlinks to arch-specific clang headers.
|
|
%global tinygoroot %{_libdir}/tinygo
|
|
|
|
%gometa
|
|
|
|
%global common_description %{expand:
|
|
Go compiler for small places. Microcontrollers, WebAssembly, and command-line
|
|
tools. Based on LLVM.}
|
|
|
|
#global godocs CHANGELOG.md BUILDING.md CONTRIBUTING.md README.md
|
|
#global golicenses LICENSE LICENSE.TXT
|
|
#global gosupfiles lib/CMSIS/CMSIS/Include/*.h lib/compiler-rt/lib/builtins/*/*.S lib/nrfx/mdk/*.{ld,S} src/examples/wasm/*/*.js targets/*.{js,json,ld,S}
|
|
|
|
Name: tinygo
|
|
Release: %autorelease
|
|
Summary: Go compiler for small places
|
|
|
|
# Main files: BSD
|
|
# CMSIS: BSD (subsetted)
|
|
# avr-mcu: ASL 2.0 (packs) and MIT (Rust code, unused by this package)
|
|
# cmsis-svd: ASL 2.0 and BSD and ISC and MIT (subsetted)
|
|
# compiler-rt: NCSA or MIT
|
|
# nrfx: BSD and ASL 2.0
|
|
# picolibc: BSD and ISC and MIT and GPLv2 (testing code only, unused by this package)
|
|
# wasi-libc: BSD and CC0 and ISC and MIT and Public Domain
|
|
License: BSD and ASL 2.0 and CC0 and ISC and MIT and (NCSA or MIT) and Public Domain
|
|
URL: %{gourl}
|
|
Source0: %{gosource}
|
|
Source1: clean_tarballs.sh
|
|
Source2: cmsis-%{CMSIS_commit}-clean.tar.xz
|
|
Source3: https://github.com/avr-rust/avr-mcu/archive/%{avr_commit}/avr-%{avr_commit}.tar.gz
|
|
Source4: cmsis_svd-%{cmsis_svd_commit}-clean.tar.xz
|
|
Source5: https://releases.llvm.org/%{compiler_rt_version}/compiler-rt-%{compiler_rt_version}.src.tar.xz
|
|
Source6: https://github.com/NordicSemiconductor/nrfx/archive/%{nrfx_commit}/nrfx-%{nrfx_commit}.tar.gz
|
|
Source7: https://github.com/keith-packard/picolibc/archive/%{picolibc_commit}/picolibc-%{picolibc_commit}.tar.gz
|
|
Source8: https://github.com/WebAssembly/wasi-libc/archive/%{wasi_libc_commit}/wasi-libc-%{wasi_libc_commit}.tar.gz
|
|
# We don't have wasmtime to run these.
|
|
Patch0001: 0001-Skip-WASI-tests.patch
|
|
# We don't have cross-compiled glibc to build these.
|
|
Patch0002: 0002-Only-run-native-Linux-tests-on-their-own-GOARCH.patch
|
|
# https://github.com/tinygo-org/tinygo/pull/1538
|
|
Patch0003: 0003-Use-clang-to-do-linking.patch
|
|
Patch0004: 0004-Add-canThrow-argument-to-llvm.InlineAsm-calls.patch
|
|
|
|
# Not supported upstream yet.
|
|
ExcludeArch: armv7hl ppc64le s390x
|
|
|
|
BuildRequires: (clang-devel >= %{clang_llvm_version} with clang-devel < %{lua: print(tonumber(rpm.expand('%{clang_llvm_version}')) + 1)})
|
|
BuildRequires: golang(github.com/blakesmith/ar)
|
|
%ifnarch %{ix86}
|
|
BuildRequires: chromium
|
|
BuildRequires: golang(github.com/chromedp/chromedp) >= 0.6.4
|
|
BuildRequires: golang(github.com/chromedp/cdproto/cdp)
|
|
%endif
|
|
BuildRequires: golang(github.com/google/shlex)
|
|
BuildRequires: golang(github.com/marcinbor85/gohex)
|
|
BuildRequires: golang(github.com/mattn/go-colorable) >= 0.1.8
|
|
BuildRequires: golang(go.bug.st/serial) >= 1.1.2
|
|
BuildRequires: golang(golang.org/x/tools/go/ast/astutil)
|
|
BuildRequires: golang(golang.org/x/tools/go/ssa) >= 0.1.7
|
|
BuildRequires: golang(tinygo.org/x/go-llvm)
|
|
BuildRequires: llvm-devel(major) = %{clang_llvm_version}
|
|
BuildRequires: make
|
|
|
|
BuildRequires: avr-gcc
|
|
BuildRequires: avr-libc
|
|
# We don't have glibc for arm, so skip these.
|
|
#BuildRequires: gcc-arm-linux-gnu
|
|
#BuildRequires: gcc-aarch64-linux-gnu
|
|
BuildRequires: lld
|
|
BuildRequires: nodejs
|
|
BuildRequires: qemu-system-arm-core
|
|
|
|
Requires: golang
|
|
Requires: lld
|
|
Recommends: avr-gcc
|
|
Recommends: avr-libc
|
|
Recommends: clang
|
|
# Add this when LLVM supports ESP natively.
|
|
# Recommends: esptool
|
|
Recommends: qemu-system-arm-core
|
|
|
|
%description
|
|
%{common_description}
|
|
|
|
#gopkg
|
|
|
|
|
|
%prep
|
|
%goprep
|
|
%patch0001 -p1
|
|
%patch0002 -p1
|
|
%patch0003 -p1
|
|
%patch0004 -p1
|
|
|
|
tar -C lib -xf %{SOURCE2}
|
|
rmdir lib/CMSIS
|
|
mv lib/CMSIS-%{CMSIS_commit} lib/CMSIS
|
|
|
|
tar -C lib -xf %{SOURCE3}
|
|
rmdir lib/avr
|
|
mv lib/avr-mcu-%{avr_commit} lib/avr
|
|
|
|
tar -C lib -xf %{SOURCE4}
|
|
rmdir lib/cmsis-svd
|
|
mv lib/cmsis-svd-%{cmsis_svd_commit} lib/cmsis-svd
|
|
|
|
tar -C lib -xf %{SOURCE5}
|
|
rmdir lib/compiler-rt
|
|
mv lib/compiler-rt-%{compiler_rt_version}.src lib/compiler-rt
|
|
|
|
tar -C lib -xf %{SOURCE6}
|
|
rmdir lib/nrfx
|
|
mv lib/nrfx-%{nrfx_commit} lib/nrfx
|
|
rm lib/nrfx/.gitignore
|
|
chmod -x lib/nrfx/doc/generate_html_doc.sh
|
|
|
|
tar -C lib -xf %{SOURCE7}
|
|
rmdir lib/picolibc
|
|
mv lib/picolibc-%{picolibc_commit} lib/picolibc
|
|
|
|
tar -C lib -xf %{SOURCE8}
|
|
rmdir lib/wasi-libc
|
|
mv lib/wasi-libc-%{wasi_libc_commit} lib/wasi-libc
|
|
|
|
|
|
%build
|
|
# Use only GOBUILDTAGS when https://pagure.io/go-rpm-macros/pull-request/34 is
|
|
# merged and released.
|
|
export BUILDTAGS="llvm%{clang_llvm_version}" LDFLAGS="-X github.com/tinygo-org/tinygo/goenv.TINYGOROOT=%{tinygoroot} "
|
|
%gobuild -o %{gobuilddir}/bin/tinygo %{goipath}
|
|
GO111MODULE=off %make_build gen-device STM32=0
|
|
for target in armv6m-none-eabi armv7m-none-eabi armv7em-none-eabi; do
|
|
for libc in compiler-rt picolibc; do
|
|
TINYGOROOT=$PWD \
|
|
%{gobuilddir}/bin/tinygo \
|
|
build-library -target=$target -o ${target}-${libc}.a ${libc}
|
|
done
|
|
done
|
|
%make_build wasi-libc CLANG=clang-%{clang_llvm_version} LLVM_AR=llvm-ar LLVM_NM=llvm-nm
|
|
|
|
|
|
%install
|
|
#gopkginstall
|
|
install -vdm 0755 %{buildroot}%{_bindir}
|
|
install -vpm 0755 %{gobuilddir}/bin/* %{buildroot}%{_bindir}/
|
|
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/CMSIS
|
|
install -vpm 0644 lib/CMSIS/README.md %{buildroot}%{tinygoroot}/lib/CMSIS/
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/CMSIS/CMSIS/Include
|
|
install -vpm 0644 lib/CMSIS/CMSIS/Include/* %{buildroot}%{tinygoroot}/lib/CMSIS/CMSIS/Include/
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/compiler-rt
|
|
install -vpm 0644 lib/compiler-rt/README.txt %{buildroot}%{tinygoroot}/lib/compiler-rt/
|
|
install -vpm 0644 lib/compiler-rt/LICENSE.TXT %{buildroot}%{tinygoroot}/lib/compiler-rt/
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/compiler-rt/lib
|
|
cp -rp lib/compiler-rt/lib/builtins %{buildroot}%{tinygoroot}/lib/compiler-rt/lib/
|
|
cp -rp lib/nrfx %{buildroot}%{tinygoroot}/lib/
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/wasi-libc
|
|
cp -rp lib/wasi-libc/sysroot %{buildroot}%{tinygoroot}/lib/wasi-libc/
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc/newlib/libc/ctype %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc/newlib/libc/include %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc/newlib/libc/locale %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc/newlib/libc/string %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc/newlib/libc/tinystdio %{buildroot}%{tinygoroot}/lib/picolibc/newlib/libc
|
|
cp -rp lib/picolibc-include %{buildroot}%{tinygoroot}/lib
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/pkg
|
|
for target in armv6m-none-eabi armv7m-none-eabi armv7em-none-eabi; do
|
|
for libc in compiler-rt picolibc; do
|
|
install -vdm 0755 %{buildroot}%{tinygoroot}/pkg/${target}
|
|
install -vpm 0644 ${target}-${libc}.a %{buildroot}%{tinygoroot}/pkg/${target}/${libc}.a
|
|
done
|
|
done
|
|
cp -rp src %{buildroot}%{tinygoroot}/
|
|
rm %{buildroot}%{tinygoroot}/src/examples/wasm/.gitignore
|
|
cp -rp targets %{buildroot}%{tinygoroot}/
|
|
|
|
|
|
%if %{with check}
|
|
%global gotestflags %gocompilerflags -tags="llvm%{clang_llvm_version}"
|
|
%check
|
|
export TINYGOROOT=%{buildroot}%{tinygoroot}
|
|
export GOPATH=%{buildroot}%{tinygoroot}:%{gopath}
|
|
export PATH=%{buildroot}%{_bindir}:$PATH
|
|
export GO111MODULE=off
|
|
%gocheck -v -d tests/tinygotest
|
|
make smoketest STM32=0 XTENSA=0
|
|
%ifnarch %{ix86} aarch64
|
|
make wasmtest
|
|
%endif
|
|
%endif
|
|
|
|
|
|
%files
|
|
%doc README.md CHANGELOG.md CONTRIBUTING.md
|
|
%license LICENSE
|
|
%{_bindir}/tinygo
|
|
%{tinygoroot}
|
|
%doc %{tinygoroot}/lib/CMSIS/README.md
|
|
%license %{tinygoroot}/lib/compiler-rt/LICENSE.TXT
|
|
%doc %{tinygoroot}/lib/compiler-rt/README.txt
|
|
%license %{tinygoroot}/lib/nrfx/LICENSE
|
|
%doc %{tinygoroot}/lib/nrfx/README.md
|
|
|
|
#gopkgfiles
|
|
|
|
|
|
%changelog
|
|
%autochangelog
|