Skip to content

Commit 3b69d86

Browse files
authored
Artefact extra clean from bundle (#389)
* Artefact extra clean from bundle (cherry picked from commit 1046495) * Set output dir
1 parent 1a9bfd2 commit 3b69d86

File tree

4 files changed

+153
-0
lines changed

4 files changed

+153
-0
lines changed

.github/workflows/build-ios.yml

+7
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,13 @@ jobs:
137137
ARCH: SIM_arm64
138138
- name: List output directory
139139
run: ls -lah out/
140+
- name: Cleanup out of bundle
141+
working-directory: ${{ env.GITHUB_WORKSPACE }}
142+
run: scripts/artifact-clean.sh
143+
env:
144+
BUNDLE: ${{ matrix.bundle }}
145+
- name: List output directory2
146+
run: ls -lah out/
140147
- name: Package Binaries for Artifact
141148
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
142149
working-directory: ${{ env.GITHUB_WORKSPACE }}

.github/workflows/build-macos.yml

+7
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,13 @@ jobs:
129129
ARCH: arm64
130130
- name: List output directory
131131
run: ls -lah out/
132+
- name: Cleanup out of bundle
133+
working-directory: ${{ env.GITHUB_WORKSPACE }}
134+
run: scripts/artifact-clean.sh
135+
env:
136+
BUNDLE: ${{ matrix.bundle }}
137+
- name: List output directory2
138+
run: ls -lah out/
132139
- name: Package Binaries for Artifact
133140
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
134141
working-directory: ${{ env.GITHUB_WORKSPACE }}

.github/workflows/build-tvos.yml

+6
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,12 @@ jobs:
136136
ARCH: SIM_arm64
137137
- name: List output directory
138138
run: ls -lah out/
139+
- name: Cleanup out of bundle
140+
working-directory: ${{ env.GITHUB_WORKSPACE }}
141+
run: scripts/artifact-clean.sh
142+
env:
143+
BUNDLE: ${{ matrix.bundle }}
144+
ARCH: SIM_arm64
139145
- name: Package Binaries for Artifact
140146
if: github.repository == 'openframeworks/apothecary' && github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/bleeding')
141147
working-directory: ${{ env.GITHUB_WORKSPACE }}

scripts/artifact-clean.sh

+133
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
# capture failing exits in commands obscured behind a pipe
4+
set -o pipefail
5+
6+
if [ -z "${NO_FORCE+x}" ]; then
7+
export FORCE="-f"
8+
else
9+
export FORCE=""
10+
fi
11+
12+
13+
14+
15+
# trap any script errors and exit
16+
# trap "trapError" ERR
17+
18+
trapError() {
19+
echo
20+
echo " ^ Received error building $formula_name ^"
21+
cat "formula_${ARCH}.log"
22+
if [ "$formula_name" == "boost" ]; then
23+
cat $APOTHECARY_PATH/build/boost/bootstrap.log
24+
fi
25+
if [ -f $APOTHECARY_PATH/build/$formula_name/config.log ]; then
26+
tail -n1000 $APOTHECARY_PATH/build/$formula_name/config.log
27+
fi
28+
exit 1
29+
}
30+
31+
if [ "$TRAVIS" = true -o "$GITHUB_ACTIONS" = true ] && [ "$TARGET" == "emscripten" ]; then
32+
run(){
33+
echo "TARGET=\"emscripten\" $@"
34+
docker exec -i emscripten sh -c "TARGET=\"emscripten\" $@"
35+
}
36+
37+
run_bg(){
38+
trap "trapError" ERR
39+
40+
#PATH=\"$DOCKER_HOME/bin:\$PATH\"
41+
echo "TARGET=\"emscripten\" $@"
42+
docker exec -i emscripten sh -c "TARGET=\"emscripten\" $@" >> "formula_${ARCH}.log" 2>&1 &
43+
apothecaryPID=$!
44+
echoDots $apothecaryPID
45+
wait $apothecaryPID
46+
47+
echo "Tail of log for $formula_name"
48+
run "tail -n 100 formula_${ARCH}.log"
49+
}
50+
51+
# DOCKER_HOME=$(docker exec -i emscripten echo '$HOME')
52+
# CCACHE_DOCKER=$(docker exec -i emscripten ccache -p | grep "cache_dir =" | sed "s/(default) cache_dir = \(.*\)/\1/")
53+
ROOT=$(docker exec -i emscripten pwd)
54+
LOCAL_ROOT=$(cd $(dirname "$0"); pwd -P)/..
55+
else
56+
run(){
57+
echo "$@"
58+
eval "$@"
59+
}
60+
61+
run_bg(){
62+
trap "trapError" ERR
63+
64+
echo "$@"
65+
eval "$@" >> "formula_${ARCH}.log" 2>&1 &
66+
apothecaryPID=$!
67+
echoDots $apothecaryPID
68+
wait $apothecaryPID
69+
70+
echo "Tail of log for $formula_name"
71+
run "tail -n 10 formula_${ARCH}.log"
72+
}
73+
74+
ROOT=$(cd $(dirname "$0"); pwd -P)/..
75+
LOCAL_ROOT=$ROOT
76+
fi
77+
78+
APOTHECARY_PATH=$ROOT/apothecary
79+
80+
if [ -z "${OUTPUT_FOLDER+x}" ]; then
81+
export OUTPUT_FOLDER="$ROOT/out"
82+
fi
83+
#OUTPUT_FOLDER=$ROOT/out
84+
85+
86+
# VERBOSE=true
87+
88+
if [ -z $TARGET ] ; then
89+
echo "Environment variable TARGET not defined. Should be target os"
90+
exit 1
91+
fi
92+
93+
echo "Running apothecary from $PWD"
94+
echo "Target: $TARGET"
95+
echo "Architecture: $ARCH"
96+
echo "Bundle: $BUNDLE"
97+
echo "Apothecary path: $APOTHECARY_PATH"
98+
echo "Output folder is: $OUTPUT_FOLDER"
99+
100+
# Source the calculate_formulas.sh script to get the list of formulas
101+
source $LOCAL_ROOT/scripts/calculate_formulas.sh
102+
103+
if [ -z "$FORMULAS" ]; then
104+
echo "No formulas to build"
105+
exit 0
106+
fi
107+
108+
# Define the base directory where the library folders are located
109+
LIBRARY_BASE_DIR="$LOCAL_ROOT/libraries"
110+
111+
# Create an associative array to keep track of the libraries to keep
112+
declare -A KEEP_LIBRARIES
113+
for formula in "${FORMULAS[@]}"; do
114+
formula_name="${formula%.*}"
115+
KEEP_LIBRARIES[$formula_name]=1
116+
done
117+
118+
# Iterate over the folders in the library base directory
119+
for library_dir in "$OUTPUT_FOLDER"/*; do
120+
library_name=$(basename "$library_dir")
121+
122+
# Check if the library name is not in the keep list
123+
if [ -z "${KEEP_LIBRARIES[$library_name]}" ]; then
124+
echo "Deleting library folder: $library_dir"
125+
rm -rf "$library_dir"
126+
else
127+
echo "Keeping library folder: $library_dir"
128+
fi
129+
done
130+
131+
132+
echo ""
133+
echo ""

0 commit comments

Comments
 (0)