From d6617563fc8b5b22326a33c4cdb449ef862d2e32 Mon Sep 17 00:00:00 2001 From: Maarten Billemont Date: Sun, 1 Jul 2018 21:20:56 -0400 Subject: [PATCH] Clean libs when cleaning build. --- Dockerfile | 7 +++--- lib/bin/build_lib | 27 ++++++++++++++---------- lib/libjson-c | 2 +- lib/libsodium | 2 +- platform-independent/c/core/build.gradle | 6 ++++++ 5 files changed, 27 insertions(+), 17 deletions(-) diff --git a/Dockerfile b/Dockerfile index 9011403f..22c7bf34 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,5 @@ FROM alpine -WORKDIR /mpw/gradle -ADD . /mpw -RUN apk update && apk add libtool automake autoconf make g++ openjdk8 -RUN ./gradlew -i build +RUN apk add --no-cache git libtool automake autoconf make g++ bash openjdk8 +RUN git clone --depth=3 $(: --shallow-submodules) --recurse-submodules https://gitlab.com/MasterPassword/MasterPassword.git /mpw +RUN cd /mpw/gradle && ./gradlew -i clean build diff --git a/lib/bin/build_lib b/lib/bin/build_lib index ff2942a8..9ce6c288 100755 --- a/lib/bin/build_lib +++ b/lib/bin/build_lib @@ -69,16 +69,15 @@ _initialize_needs() { # By default, this will wipe the prefix, run `make distclean` and `git clean -fdx`. clean() { _clean "$@"; } _clean() { - rm -rf "$prefix" - if [[ $platform = windows ]]; then printf '"%%VSINSTALLDIR%%\Common7\Tools\VsMSBuildCmd.bat" && msbuild /t:Clean' > .clean.bat cmd //c .clean.bat rm -f .clean.bat + elif [[ -e Makefile ]] && make -s distclean; then : + elif [[ -e .git ]] && git clean -fdx; then : fi - [[ ! -e Makefile ]] || make -s distclean - [[ ! -e .git ]] || git clean -fdx + rm -rf "$prefix" } # prepare [ ... ] @@ -104,7 +103,7 @@ _prepare_clean() { local prefix=$1 platform=$2; shift 2 rm -rf "$prefix" - install -d "$prefix" + install -d "$prefix/out" } # prepare_config [ ... ] @@ -116,9 +115,14 @@ prepare_config() { _prepare_config "$@"; } _prepare_config() { local prefix=$1 platform=$2; shift 2 - [[ $platform = windows ]] && return + [[ -e "$prefix/out/.prepared" ]] && return - [[ -e configure ]] || autoreconf --verbose --install --symlink 2> >(sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /') + if [[ $platform = windows ]]; then : + else + autoreconf --verbose --install --symlink 2> >(sed 's/^\([^:]*\):[0-9]\{1,\}: /\1: /') + fi + + touch "$prefix/out/.prepared" } # target @@ -142,9 +146,10 @@ target_prepare() { _target_prepare "$@"; } _target_prepare() { local prefix=$1 platform=$2 arch=$3; shift 3 - [[ $platform = windows ]] && return - - [[ ! -e Makefile ]] || make -s clean + if [[ $platform = windows ]]; then : + else + [[ ! -e Makefile ]] || make -s clean + fi } # target_configure [ ... ] @@ -220,7 +225,7 @@ _finalize_merge() { [[ -e "$prefix/$archs/include" ]] && mv -f -- "$prefix/$archs/include" "$prefix/out/" - mkdir -p "$prefix/out/lib" + install -d "$prefix/out/lib" case "$platform" in 'linux') for arch in "${archs[@]}"; do diff --git a/lib/libjson-c b/lib/libjson-c index e3752b58..3df1f98b 160000 --- a/lib/libjson-c +++ b/lib/libjson-c @@ -1 +1 @@ -Subproject commit e3752b58945d23895535857ed136a5185bad02ce +Subproject commit 3df1f98b4ab52f271dba5e13ec59cf4d1d093e1a diff --git a/lib/libsodium b/lib/libsodium index cfb0f947..850edc11 160000 --- a/lib/libsodium +++ b/lib/libsodium @@ -1 +1 @@ -Subproject commit cfb0f94704841f943a5a11d9e335da409c55d58a +Subproject commit 850edc1175c78ed72124cfbef073c7ecc655c476 diff --git a/platform-independent/c/core/build.gradle b/platform-independent/c/core/build.gradle index 8237f9ad..61128857 100644 --- a/platform-independent/c/core/build.gradle +++ b/platform-independent/c/core/build.gradle @@ -67,10 +67,16 @@ library { commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libsodium-${system}" privateHeaders.from "$rootDir/../lib/libsodium/src/libsodium/include" } + clean.dependsOn project.tasks.maybeCreate( "clean_libsodium-${system}", Exec.class ).configure { + commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libsodium-${system}", 'clean' + } archive.dependsOn project.tasks.maybeCreate( "build_libjson-c-${system}", Exec.class ).configure { commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libjson-c-${system}" privateHeaders.from "$rootDir/../lib/libjson-c/build-${system}~/out" } + clean.dependsOn project.tasks.maybeCreate( "clean_libjson-c-${system}", Exec.class ).configure { + commandLine 'bash', '-x', "$rootDir/../lib/bin/build_libjson-c-${system}", 'clean' + } } } }