Runs make clean after make-install to reduce used disk (#855)

* Runs `make clean` after `make-install` to reduce used disk
Make install leaves many .o and other files
Fixes problems with disk space on github actions runner

* Create a flag --clean-after-install that can be passed as the second argument to `make_build` function.

* Create a flag --clean-after-install that can be passed as the second argument to `make_build` function.
Ups tools-cache-version to v7

* Now running clean after install just depends on adding an environment variable when using scripts
that call `module_make` or `module_build`. Those two bash functions will check CLEANAFTERINSTALL and if
it is non-empty, they will call `make clean` after other `make` calls.

* build-toolchains.sh gets new flag
--clean-after-install to turn enable
`make clean` in `module_make` and `module_run`
This commit is contained in:
Chick Markley
2021-04-19 14:57:34 -07:00
committed by GitHub
parent 22f6fd5d11
commit 70afebae9f
3 changed files with 19 additions and 9 deletions

View File

@@ -6,7 +6,7 @@ version: 2.1
parameters: parameters:
tools-cache-version: tools-cache-version:
type: string type: string
default: "v6" default: "v7"
# default execution env.s # default execution env.s
executors: executors:

View File

@@ -18,11 +18,12 @@ usage() {
echo " ec2fast: if set, pulls in a pre-compiled RISC-V toolchain for an EC2 manager instance" echo " ec2fast: if set, pulls in a pre-compiled RISC-V toolchain for an EC2 manager instance"
echo "" echo ""
echo "Options" echo "Options"
echo " --prefix PREFIX : Install destination. If unset, defaults to $(pwd)/riscv-tools-install" echo " --prefix PREFIX : Install destination. If unset, defaults to $(pwd)/riscv-tools-install"
echo " or $(pwd)/esp-tools-install" echo " or $(pwd)/esp-tools-install"
echo " --ignore-qemu : Ignore installing QEMU" echo " --ignore-qemu : Ignore installing QEMU"
echo " --arch -a : Architecture (e.g., rv64gc)" echo " --clean-after-install : Run make clean in calls to module_make and module_build"
echo " --help -h : Display this message" echo " --arch -a : Architecture (e.g., rv64gc)"
echo " --help -h : Display this message"
exit "$1" exit "$1"
} }
@@ -37,6 +38,7 @@ die() {
TOOLCHAIN="riscv-tools" TOOLCHAIN="riscv-tools"
EC2FASTINSTALL="false" EC2FASTINSTALL="false"
IGNOREQEMU="" IGNOREQEMU=""
CLEANAFTERINSTALL=""
RISCV="" RISCV=""
ARCH="" ARCH=""
@@ -51,9 +53,11 @@ do
RISCV=$(realpath $1) ;; RISCV=$(realpath $1) ;;
--ignore-qemu ) --ignore-qemu )
IGNOREQEMU="true" ;; IGNOREQEMU="true" ;;
-a | --arch ) -a | --arch )
shift shift
ARCH=$1 ;; ARCH=$1 ;;
--clean-after-install )
CLEANAFTERINSTALL="true" ;;
riscv-tools | esp-tools) riscv-tools | esp-tools)
TOOLCHAIN=$1 ;; TOOLCHAIN=$1 ;;
ec2fast ) ec2fast )

View File

@@ -49,6 +49,9 @@ module_make() ( # <submodule> <target..>
cd "${SRCDIR}/${1}/build" cd "${SRCDIR}/${1}/build"
shift shift
"${MAKE}" "$@" | tee "build-${1:-make}.log" "${MAKE}" "$@" | tee "build-${1:-make}.log"
if [ -n "$CLEANAFTERINSTALL" ] ; then
"${MAKE}" clean # get rid of intermediate files
fi
) )
module_build() ( # <submodule> [configure-arg..] module_build() ( # <submodule> [configure-arg..]
@@ -81,6 +84,9 @@ module_build() ( # <submodule> [configure-arg..]
"${MAKE}" "${MAKE}"
echo "==> Installing ${name}" echo "==> Installing ${name}"
"${MAKE}" install "${MAKE}" install
if [ -n "$CLEANAFTERINSTALL" ] ; then
"${MAKE}" clean # get rid of intermediate files
fi
} 2>&1 | tee build.log } 2>&1 | tee build.log
) )