@@ -91,6 +91,90 @@ mkdir -p "$ARTIFACTS_DIR"
9191
9292export CN1_BUILD_STATS_FILE=" $ARTIFACTS_DIR /iphone-builder-stats.txt"
9393
94+ copy_tree_contents () {
95+ local src=" $1 "
96+ local dest=" $2 "
97+ mkdir -p " $dest "
98+ if command -v rsync > /dev/null 2>&1 ; then
99+ rsync -a " $src " / " $dest " /
100+ else
101+ cp -R " $src " /. " $dest " /
102+ fi
103+ }
104+
105+ find_bytecode_translator_sources () {
106+ local root=" $1 "
107+ local best=" "
108+ local best_score=0
109+ local dir score m_count c_count h_count
110+
111+ [ -d " $root " ] || return 1
112+
113+ while IFS= read -r dir; do
114+ [ -d " $dir " ] || continue
115+
116+ score=0
117+ [ -f " $dir /cn1_globals.m" ] && score=$(( score + 100 ))
118+ [ -f " $dir /xmlvm.h" ] && score=$(( score + 100 ))
119+
120+ m_count=" $( find " $dir " -maxdepth 1 -type f -name ' *.m' 2> /dev/null | wc -l | tr -d ' ' ) "
121+ c_count=" $( find " $dir " -maxdepth 1 -type f -name ' *.c' 2> /dev/null | wc -l | tr -d ' ' ) "
122+ h_count=" $( find " $dir " -maxdepth 1 -type f -name ' *.h' 2> /dev/null | wc -l | tr -d ' ' ) "
123+
124+ score=$(( score + m_count + c_count + h_count))
125+
126+ if [ " $score " -gt " $best_score " ]; then
127+ best=" $dir "
128+ best_score=" $score "
129+ fi
130+ done < <(
131+ find " $root " -type d \
132+ ! -path ' */Pods/*' \
133+ ! -path ' */build/*' \
134+ ! -path ' */Build/*' \
135+ ! -path ' */DerivedData/*' \
136+ ! -path ' */xcuserdata/*' \
137+ 2> /dev/null
138+ )
139+
140+ [ -n " $best " ] || return 1
141+ printf ' %s\n' " $best "
142+ }
143+
144+ stage_bytecode_translator_sources () {
145+ local project_dir=" $1 "
146+ local artifacts_dir=" $2 "
147+
148+ local bt_dir=" "
149+ local out_dir=" $artifacts_dir /bytecode-translator-sources"
150+ local zip_file=" $artifacts_dir /bytecode-translator-sources.zip"
151+ local listing_file=" $artifacts_dir /bytecode-translator-files.txt"
152+
153+ bt_dir=" $( find_bytecode_translator_sources " $project_dir " || true) "
154+ if [ -z " $bt_dir " ]; then
155+ bia_log " ByteCodeTranslator source directory not found under $project_dir "
156+ return 0
157+ fi
158+
159+ bia_log " Detected ByteCodeTranslator sources at $bt_dir "
160+
161+ rm -rf " $out_dir " " $zip_file "
162+ mkdir -p " $out_dir "
163+
164+ copy_tree_contents " $bt_dir " " $out_dir "
165+
166+ find " $out_dir " -maxdepth 2 -type f \( -name ' *.m' -o -name ' *.c' -o -name ' *.h' \) \
167+ | sort > " $listing_file " || true
168+
169+ (
170+ cd " $artifacts_dir "
171+ zip -qry " $( basename " $zip_file " ) " " $( basename " $out_dir " ) "
172+ )
173+
174+ bia_log " Staged ByteCodeTranslator sources in $out_dir "
175+ bia_log " Created archive $zip_file "
176+ }
177+
94178bia_log " Running HelloCodenameOne Maven build with JAVA_HOME=$JAVA17_HOME "
95179(
96180 export JAVA_HOME=" $JAVA17_HOME "
@@ -162,6 +246,8 @@ if [ -z "$PROJECT_DIR" ]; then
162246fi
163247bia_log " Found generated iOS project at $PROJECT_DIR "
164248
249+ stage_bytecode_translator_sources " $PROJECT_DIR " " $ARTIFACTS_DIR "
250+
165251if [ -f " $PROJECT_DIR /Podfile" ]; then
166252 if ! command -v pod > /dev/null 2>&1 ; then
167253 bia_log " Generated project requires CocoaPods but the pod command is not installed." >&2
0 commit comments