From 614163ed0f25484f3b2ffbb3c5eabbbe8c6d3a5e Mon Sep 17 00:00:00 2001 From: Noah Elzner <78953604+enteraga6@users.noreply.github.com> Date: Mon, 23 Oct 2023 16:20:57 -0500 Subject: [PATCH] Update build.sh Signed-off-by: Noah Elzner <78953604+enteraga6@users.noreply.github.com> --- internal/builders/bazel/build.sh | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/internal/builders/bazel/build.sh b/internal/builders/bazel/build.sh index 5c411a3578..447749498f 100755 --- a/internal/builders/bazel/build.sh +++ b/internal/builders/bazel/build.sh @@ -22,12 +22,12 @@ binaries_dir="bazel_builder_binaries_to_upload_to_gh_7bc972367cb286b7f36ab4457f0 mkdir ${binaries_dir} # Transfer flags and targets to their respective arrays -IFS=' ' read -r -a build_flags <<< "${FLAGS}" -IFS=' ' read -r -a build_targets <<< "${TARGETS}" +IFS=' ' read -r -a build_flags <<< "${UNTRUSTED_FLAGS}" +IFS=' ' read -r -a build_targets <<< "${UNTRUSTED_TARGETS}" # If the targets includes Java targets, include Java build flag # and add Github Runner Java rule to WORKSPACE -if [[ "${INCLUDES_JAVA}" == "true" ]] +if [[ "${UNTRUSTED_INCLUDES_JAVA}" == "true" ]] then build_flags+=("--java_runtime_version=myjdk") @@ -52,7 +52,7 @@ declare -A targets_set ################################################ for input in "${build_targets[@]}"; do - + # Using bazel query extracts all targets from a glob pattern. # Thus we can change Java targets to their _deploy.jar target. for target in $(bazel query "$input"); do @@ -60,12 +60,12 @@ for input in "${build_targets[@]}"; do # Check to see if the target is a Java target. If it is the output is a Java target. # Note: targets that already have the _deploy.jar suffix will have no output from the query output=$(bazel query "kind(java_binary, $target)" 2>/dev/null) - + # If there is a Java target without _deploy.jar suffix, add suffix, build and add to target set. if [[ -n "$output" ]] then bazel build "${build_flags[@]}" "${target}_deploy.jar" - targets_set["${target}_deploy.jar"]="1" + targets_set["${target}_deploy.jar"]="1" else # Build target regularly. bazel build "${build_flags[@]}" "$target" @@ -81,7 +81,7 @@ done ################################################ for curr_target in "${!targets_set[@]}"; do - + # Removes everything up to and including the first colon # "//src/internal:fib" --> "fib" binary_name=${curr_target#*:} @@ -107,7 +107,7 @@ for curr_target in "${!targets_set[@]}"; do # Copy JAR to artifact-specific dir in ./${binaries_dir} and remove symbolic links. file="$bazel_generated" cp -Lr "$file" "./${binaries_dir}/$run_script_name" - + # Get the path the to run-script associated with the {$curr_target}_deploy.jar # If the user inputted the path to their local JAVABIN insert that into the run-script to define it. # Inputting a local path to JAVABIN is needed or else run-script will not work as it points to Github Runner JAVABIN @@ -118,11 +118,11 @@ for curr_target in "${!targets_set[@]}"; do # to run the run-script themselves, which would not be possible as it is either set to the Github Runner VM Java bin path # if no flag to USER_LOCAL_JAVABIN is passed in their workflow or to the path passed in their flag. awk -v n=66 -v s=' --local_javabin=*) USER_JAVA_BIN=( "${1#--local_javabin=}" ) ;;' 'NR == n {print s} {print}' "$run_script_path" > temp_file && mv -f temp_file "$run_script_path" - + # Updates Java Bin in run-script after the flags get proccessed awk -v n=127 -v s='' 'NR == n {print s} {print}' "$run_script_path" > temp_file && mv -f temp_file "$run_script_path" awk -v n=128 -v s='if [[ -n $USER_JAVA_BIN ]]; then JAVABIN=$USER_JAVA_BIN; fi' 'NR == n {print s} {print}' "$run_script_path" > temp_file && mv -f temp_file "$run_script_path" - + cp -L "$run_script_path" "./${binaries_dir}/$run_script_name" ################################################ @@ -130,7 +130,7 @@ for curr_target in "${!targets_set[@]}"; do # Logic for Non-Java Targets # # # ################################################ - + else ################################################ @@ -139,7 +139,7 @@ for curr_target in "${!targets_set[@]}"; do # # ################################################ - if [[ "${NEEDS_RUNFILES}" == "true" ]] + if [[ "${UNTRUSTED_NEEDS_RUNFILES}" == "true" ]] then # Get file(s) generated from build with respect to the target bazel_generated=$(bazel cquery --output=starlark --starlark:expr="'\n'.join([f.path for f in target.files.to_list()])" "$curr_target" 2>/dev/null) @@ -178,7 +178,7 @@ for curr_target in "${!targets_set[@]}"; do else # Get file(s) generated from build with respect to the target bazel_generated=$(bazel cquery --output=starlark --starlark:expr="'\n'.join([f.path for f in target.files.to_list()])" "$curr_target" 2>/dev/null) - + # Uses a Starlark expression to pass new line seperated list of file(s) into the set of files while read -r file; do cp -L "$file" ./${binaries_dir}