Skip to content

Commit

Permalink
Remove manually adding delimiter
Browse files Browse the repository at this point in the history
Manually adding delimiter need to consistently update whenever parsing
parameters changes.

Signed-off-by: Sophia Guo <sophia.gwf@gmail.com>
  • Loading branch information
sophia-guo committed May 6, 2024
1 parent b74a873 commit 9133f41
Showing 1 changed file with 11 additions and 22 deletions.
33 changes: 11 additions & 22 deletions tooling/reproducible/windows_repro_build_compare.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,14 @@ Clone_Build_Repo() {
Prepare_Env_For_Build() {
echo "Setting Variables"
export BOOTJDK_HOME=$WORK_DIR/jdk-${bootJDK}

echo "Parsing Make JDK Any Platform ARGS For Build"
echo "buildargs is $buildArgs"
# Split the string into an array of words
IFS=' ' read -ra words <<< "$buildArgs"

# Add The Build Time Stamp In Case It Wasnt In The SBOM ARGS
words+=( "--build-reproducible-date \"$buildStamp\"" )
words+=("--build-reproducible-date")
words+=("\"$buildStamp\"")

# Initialize variables
param=""
Expand All @@ -570,6 +570,7 @@ Prepare_Env_For_Build() {
# Loop through the words
for word in "${words[@]}"; do
# Check if the word starts with '--'
echo "word is $word"
if [[ $word == --* ]] || [[ $word == -b* ]]; then
# If a parameter already exists, store it in the params array
if [[ -n $param ]]; then
Expand All @@ -579,10 +580,10 @@ Prepare_Env_For_Build() {
param="$word"
value=""
else
value+=" $word"
value+="$word"
fi
done

# Add the last parameter to the array
params+=("$param=$value")

Expand All @@ -596,22 +597,16 @@ Prepare_Env_For_Build() {
IGNORED_ARRAY=()

for p in "${params[@]}"; do
echo "p is $p"
IFS='=' read -ra parts <<< "$p"
prefixed_param=${parts[0]}
fixed_param="${prefixed_param%%[[:space:]]}"
prepped_value=${parts[1]}
fixed_value=$(echo "$prepped_value" | awk '{$1=$1};1')

# Handle Special parameters
if [ "$fixed_param" == "-b" ]; then fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME " ; fi
if [ "$fixed_param" == "--freetype-dir" ]; then fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion " ; fi
if [ "$fixed_param" == "--jdk-boot-dir" ]; then fixed_value="$BOOTJDK_HOME" ; fi
if [ "$fixed_param" == "--with-toolchain-version" ]; then fixed_value="$visualStudioVersion" ; fi
if [ "$fixed_param" == "--with-ucrt-dll-dir" ]; then fixed_value="temporary_speech_mark_placeholder${UCRT_PARAM_PATH}temporary_speech_mark_placeholder " ; fi
if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fixed_value="$fixed_value " ; fi
if [ "$fixed_param" == "--tag" ]; then fixed_value="$fixed_value " ; fi

if [ "$fixed_param" == "--target-file-name" ]; then target_file="$fixed_value" ; fi

# Fix Build Variant Parameter To Strip JDK Version

Expand Down Expand Up @@ -653,15 +648,9 @@ Prepare_Env_For_Build() {
fi
done

for element in "${BUILD_ARRAY[@]}"; do
build_string+="$element"
done

for element in "${CONFIG_ARRAY[@]}"; do
config_string+="$element"
done

final_params="$build_string--configure-args \"$config_string\" $jdk"
build_string="${BUILD_ARRAY[*]}"
config_string="${CONFIG_ARRAY[*]}"
final_params="$build_string --configure-args \"$config_string\" $jdk"

echo "Make JDK Any Platform Argument List = "
echo "$final_params"
Expand Down

0 comments on commit 9133f41

Please sign in to comment.