Blob Blame Raw
# Generated by go2rpm 1
%bcond_without check

%global __brp_strip_static_archive %{nil}

%global goipath
Version:                0.7.0

%global CMSIS_commit        9fe411cef1cef5de58e5957b89760759de44e393
%global avr_commit          6624554c02b237b23dc17d53e992bf54033fc228
%global clang_version       8.0.0
%global cmsis_svd_commit    5910f3d115a53ead55c8158da24a8fa8bda1eb50
%global compiler_rt_version 8.0.0
%global nrfx_commit         3ab39a9d457bfe627473ed0e03a7f1161d9e4f27

# To match regular Go's /usr/share/gocode
%global tinygoroot %{_prefix}/share/tinygo


%global common_description %{expand:
Go compiler for small places. Microcontrollers, WebAssembly, and command-line
tools. Based on LLVM.}

#global godocs
#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:        2%{?dist}
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 (subsetted)
# compiler-rt: NCSA or MIT
# nrfx: BSD and ASL 2.0
License:        BSD and MIT and (NCSA or MIT) and ASL 2.0
URL:            %{gourl}
Source0:        %{gosource}
Source2:        cmsis-%{CMSIS_commit}-clean.tar.xz
Source4:        cmsis_svd-%{cmsis_svd_commit}-clean.tar.xz
# Fedora-specific.
Patch0001:      0001-Use-system-path-for-TINYGOROOT-default.patch
Patch0002:      0002-Use-Fedora-command-names.patch
# We don't have ARM glibc to build these.
Patch0003:      0003-Skip-ARM-Linux-tests.patch
# We can't include STM32 .svd files because of their weird license.
Patch0004:      0004-Skip-STM32-tests.patch

# Not supported upstream yet.
ExcludeArch:    %{ix86} armv7hl ppc64le s390x

BuildRequires:  clang-devel = %{clang_version}
BuildRequires:  golang(
BuildRequires:  golang(
BuildRequires:  golang(
BuildRequires:  golang(
BuildRequires:  golang(

# 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:       clang-libs%{?isa} = %{clang_version}
Requires:       golang
Requires:       lld
Recommends:     clang
Recommends:     qemu-system-arm-core



%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/

mkdir lib/clang
ln -s /usr/lib64/clang/%{clang_version}/include lib/clang/include

%gobuild -o %{gobuilddir}/bin/tinygo %{goipath}
GO111MODULE=off %make_build gen-device
for target in armv6m-none-eabi armv7m-none-eabi armv7em-none-eabi; do
        %{gobuilddir}/bin/tinygo \
            build-builtins -target=$target -o ${target}-compiler-rt.a

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/ %{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/clang
cp -pP lib/clang/include %{buildroot}%{tinygoroot}/lib/clang/
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}/pkg
for target in armv6m-none-eabi armv7m-none-eabi armv7em-none-eabi; do
    install -vdm 0755 %{buildroot}%{tinygoroot}/pkg/${target}
    install -vpm 0644 ${target}-compiler-rt.a %{buildroot}%{tinygoroot}/pkg/${target}/compiler-rt.a
cp -rp src %{buildroot}%{tinygoroot}/
rm %{buildroot}%{tinygoroot}/src/examples/wasm/.gitignore
cp -rp targets %{buildroot}%{tinygoroot}/

%if %{with check}
export TINYGOROOT=%{buildroot}%{tinygoroot}
export GOPATH=%{buildroot}%{tinygoroot}
# Fedora LLVM doesn't support AVR yet, so don't run full suite.
PATH=%{buildroot}%{_bindir}:$PATH make smoketest AVR=0 RISCV=0
%gocheck -v -d tests/tinygotest

%license LICENSE
%doc %{tinygoroot}/lib/CMSIS/
%license %{tinygoroot}/lib/compiler-rt/LICENSE.TXT
%doc %{tinygoroot}/lib/compiler-rt/README.txt
%license %{tinygoroot}/lib/nrfx/LICENSE
%doc %{tinygoroot}/lib/nrfx/


* Sat Jul 27 2019 Fedora Release Engineering <> - 0.7.0-2
- Rebuilt for

* Tue Jul 23 2019 Elliott Sales de Andrade <> - 0.7.0-1
- Update to latest version

* Tue Jun 11 01:26:10 EDT 2019 Elliott Sales de Andrade <> - 0.6.0-1
- Initial package