From 77a59d9d35a456e759f1af1dee6ef21aeb77e59c Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Tue, 11 Oct 2022 11:37:55 +0700 Subject: [PATCH] use caching? --- .github/workflows/autobuild.yml | 1 + anda/rust/zellij/rust-zellij.spec | 45 ++++++++++++++++++++++++++++++- anda/srpm-macros/macros.caching | 45 +++++++++++++++++++++++++------ 3 files changed, 82 insertions(+), 9 deletions(-) diff --git a/.github/workflows/autobuild.yml b/.github/workflows/autobuild.yml index 4ac4a87a00..20ae70e4a1 100644 --- a/.github/workflows/autobuild.yml +++ b/.github/workflows/autobuild.yml @@ -70,6 +70,7 @@ jobs: with: name: "${{ matrix.pkg }}pkg" mockConfig: anda-37-${{ matrix.arch }} + extraArgs: -D "sccache_bucket ${{secrets.SCCACHE_BUCKET}}" -D "sccache_endpoint ${{secrets.SCCACHE_ENDPOINT}}" -D "sccache_secret ${{secrets.SCCACHE_SECRET}}" -D "sccache_accesskey ${{secrets.SCCACHE_ACCESSKEY}}" andaRepo: https://github.com/andaman-common-pkgs/subatomic-repos/raw/main/ad37.repo - name: Install Subatomic client diff --git a/anda/rust/zellij/rust-zellij.spec b/anda/rust/zellij/rust-zellij.spec index fe851d0922..9a5da37462 100644 --- a/anda/rust/zellij/rust-zellij.spec +++ b/anda/rust/zellij/rust-zellij.spec @@ -1,7 +1,48 @@ # Generated by rust2rpm 22 %global debug_package %{nil} %bcond_without check +%define sccache_prep (\ +export CC="%{_sccache} gcc" \ +export CXX="%{_sccache} g++" \ +export RUSTC_WRAPPER="sccache" \ +\ +export SCCACHE_BUCKET=%{?sccache_bucket}\ +export SCCACHE_ENDPOINT=%{?sccache_endpoint}\ +export AWS_SECRET_ACCESS_KEY=%{?sccache_secret}\ +export AWS_ACCESS_KEY_ID=%{?sccache_accesskey}\ +export SCCACHE_S3_USE_SSL=true\ +) + +%define cargo_prep_online_sccache (\ +set -eu \ +%{__mkdir} -p .cargo \ +cat > .cargo/config << EOF \ +[build]\ +rustc = "%{__rustc}"\ +rustc-wrapper = "%{_sccache}"\ +rustdoc = "%{__rustdoc}"\ +\ +[env]\ +CFLAGS = "%{build_cflags}"\ +CXXFLAGS = "%{build_cxxflags}"\ +LDFLAGS = "%{build_ldflags}"\ +\ +[install]\ +root = "%{buildroot}%{_prefix}"\ +\ +[term]\ +verbose = true\ +\ +[source]\ +\ +[source.local-registry]\ +directory = "%{cargo_registry}"\ +\ +EOF\ +%{__rm} -f Cargo.lock \ +%{__rm} -f Cargo.toml.orig \ +) %global crate zellij Name: rust-zellij @@ -18,6 +59,7 @@ ExclusiveArch: %{rust_arches} BuildRequires: anda-srpm-macros BuildRequires: rust-packaging BuildRequires: openssl-devel +BuildRequires: sccache #BuildRequires: external:crate:sccache @@ -38,10 +80,11 @@ Summary: %{summary} %prep %autosetup -n %{crate}-%{version_no_tilde} -%cargo_prep_online +%cargo_prep_online_sccache %build +%sccache_prep %cargo_build %install diff --git a/anda/srpm-macros/macros.caching b/anda/srpm-macros/macros.caching index 2948d2a58a..627b244518 100644 --- a/anda/srpm-macros/macros.caching +++ b/anda/srpm-macros/macros.caching @@ -3,14 +3,43 @@ %_sccache %{_bindir}/sccache %sccache_prep (\ -export CC="sccache gcc" \ -export CXX="sccache g++" \ +export CC="%{_sccache} gcc" \ +export CXX="%{_sccache} g++" \ export RUSTC_WRAPPER="sccache" \ -%if %{with dist_cache} && %{?sccache_endpoint} && %{?sccache_accesskey} && %{?sccache_secret} && %{?sccache_bucket} \ -export SCCACHE_BUCKET=%{sccache_bucket}\ -export SCCACHE_ENDPOINT=%{sccache_endpoint}\ -export AWS_SECRET_ACCESS_KEY=%{sccache_secret}\ -export AWS_ACCESS_KEY_ID=%{sccache_accesskey}\ +\ +export SCCACHE_BUCKET=%{?sccache_bucket}\ +export SCCACHE_ENDPOINT=%{?sccache_endpoint}\ +export AWS_SECRET_ACCESS_KEY=%{?sccache_secret}\ +export AWS_ACCESS_KEY_ID=%{?sccache_accesskey}\ export SCCACHE_S3_USE_SSL=true\ -%endif \ +) + +(\ +set -eu \ +%{__mkdir} -p .cargo \ +cat > .cargo/config << EOF \ +[build]\ +rustc = "%{__rustc}"\ +rustc-wrapper = "%{_sccache}"\ +rustdoc = "%{__rustdoc}"\ +\ +[env]\ +CFLAGS = "%{build_cflags}"\ +CXXFLAGS = "%{build_cxxflags}"\ +LDFLAGS = "%{build_ldflags}"\ +\ +[install]\ +root = "%{buildroot}%{_prefix}"\ +\ +[term]\ +verbose = true\ +\ +[source]\ +\ +[source.local-registry]\ +directory = "%{cargo_registry}"\ +\ +EOF\ +%{__rm} -f Cargo.lock \ +%{__rm} -f Cargo.toml.orig \ ) \ No newline at end of file