#!/bin/bash trace_template() { local mode=$1 installed=$2 file template available file=$(Scripts/parcel-dev.sh trace-template-field Instruments/templates.json "$mode" custom) || return if [[ $installed == 0 ]]; then [[ -f Instruments/$file ]] || { printf 'Missing genuine custom template: Instruments/%s. Export it from Instruments or explicitly select --installed-template (not equivalent).\n' "$file" >&2; return 2; } printf '%s\n' "$PWD/Instruments/$file" else template=$(Scripts/parcel-dev.sh trace-template-field Instruments/templates.json "$mode" installed) || return available=$(xcrun xctrace list templates) || return grep -Fxq "$template" <<< "$available" || { printf 'Required installed template is unavailable: %s\n' "$template" >&2; return 2; } printf 'Custom template not selected: using installed "%s"; it does NOT provide the custom combined lanes or filters.\n' "$template" >&2 printf '%s\n' "$template" fi } trace_output_path() { local mode=$1 host stamp host=$(scutil --get LocalHostName) || return [[ $host =~ ^[A-Za-z0-9._-]+$ ]] || { printf 'Unsafe or empty host name.\n' >&2; return 2; } stamp=$(date -u +%Y%m%dT%H%M%SZ) || return mkdir -p build/traces printf '%s/build/traces/%s-%s-%s.trace\n' "$PWD" "$mode" "$host" "$stamp" }