Skip to content

Instantly share code, notes, and snippets.

@drodriguez
Created March 18, 2019 22:03
Show Gist options
  • Save drodriguez/8bc2a0c228b7afad5cec97448dd04bec to your computer and use it in GitHub Desktop.
Save drodriguez/8bc2a0c228b7afad5cec97448dd04bec to your computer and use it in GitHub Desktop.
Testing the dry-run of the Swift presets
for pre in *.pre.txt
diff -urN \
(sed -E "s/ '--(swift|llvm)-cmake-options=[^']+'//g" $pre | psub)
(sed -E "s/ '--(swift|llvm)-cmake-options=[^']+'//g" (string replace -r '\.pre\.' '.output.' $pre) | psub)
or read
end
#!/usr/bin/env bash
set -o errexit
set -o errtrace
set -o nounset
set -o pipefail
# set -o xtrace
readonly orig_cwd="$PWD"
readonly script_path="${BASH_SOURCE[0]}"
readonly script_dir="$(dirname "$script_path")"
readonly script_name="$(basename "$script_path")"
function script_usage() {
cat << EOF
Usage: ${script_name} [--suffix SUFFIX] BUILD_SCRIPT PRESET_FILE
-h|--help Displays this help
--build-script PATH Path to the build-script
--suffix SUFFIX Use suffix for the generated files.
EOF
}
function parse_params() {
local positional
local param
while [[ $# -gt 0 ]]; do
param="${1}"
shift
case $param in
-h|--help)
script_usage
exit 0
;;
--suffix)
suffix=${1}
shift
;;
*)
positional+=("${param}")
;;
esac
done
if [[ ${#positional[@]} -ne 2 ]]; then
echo "Invalid parameters" >2
script_usage
exit -1
fi
build_script="${positional[0]}"
presets_file="${positional[1]}"
}
function main() {
parse_params "$@"
presets=($(cat ${presets_file} | grep -e '\[preset' | cut -d' ' -f 2 | sed -e 's/\]$//' | grep -v -e '^mixin' | grep -v 'buildbot_iphoneos_arm64_crosscompiler'))
local idx=0
local total=${#presets[@]}
for preset in ${presets[@]}; do
echo "Processing ${preset} (${idx}/${total})"
idx=$((${idx}+1))
# NOTE:
# - install_destdir and installable_package are used by almost all presets.
# - extra_swift_args is used by buildbot_incremental_extra_swift_args,tools=RA,stdlib=RD
# - ndk_path and arm_dir are used by buildbot_linux_crosscompile_android,tools=RA,stdlib=RD,build
# - install_symroot, install_toolchain_dir, symbols_package, darwin_toolchain_bundle_identifier, darwin_toolchain_display_name, darwin_toolchain_display_name_short, darwin_toolchain_xctoolchain_name, darwin_toolchain_version and darwin_toolchain_alias are used by mixin_osx_package_base
# - swift_install_destdir is used by LLDB_Nested
"${build_script}" "--dry-run" "--preset=${preset}" \
install_destdir=/install_destdir \
installable_package=/installable_package.tgz \
'extra_swift_args=^EXTRA_SWIFT_ARGS$' \
ndk_path=/ndk_path \
arm_dir=/arm_dir \
install_symroot=/install_symroot \
install_toolchain_dir=/install_toolchain_dir \
symbols_package=/symbols_package.tgz \
darwin_toolchain_bundle_identifier=DarwinToolchainBundleIdentifer \
darwin_toolchain_display_name=DarwinToolchainDisplayName \
darwin_toolchain_display_name_short=DarwinToolchainDisplayNameShort \
darwin_toolchain_xctoolchain_name=DarwinToolchainXCToolchainName \
darwin_toolchain_version=1.2.3 \
darwin_toolchain_alias=DarwinToolchainAlias \
swift_install_destdir=/swift_install_destdir \
> "${preset}.${suffix-output}.txt" 2>&1
done
}
main "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment