File size: 1,282 Bytes
3fbbdd9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/usr/bin/env bash
#
# launch.sh — Launch the CodeEdit app built by build.sh.
#
# Works standalone (build.sh does not need to have been sourced). Locates the
# .app relative to this script and hands off to `open`.
#
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
APP_NAME="CodeEdit.app"

# Candidate locations, most-specific first:
#   1. $APP_OUTPUT_DIR (if the build was told to publish elsewhere)
#   2. next to this script (build.sh's default output location)
#   3. the raw Xcode build-products directory (fallback)
CANDIDATES=(
  "${APP_OUTPUT_DIR:-}/$APP_NAME"
  "$SCRIPT_DIR/$APP_NAME"
  "$SCRIPT_DIR/DerivedData/Build/Products/Release/$APP_NAME"
)

APP_PATH=""
for c in "${CANDIDATES[@]}"; do
  [ -n "$c" ] || continue
  if [ -d "$c" ]; then
    APP_PATH="$c"
    break
  fi
done

if [ -z "$APP_PATH" ]; then
  echo "ERROR: could not find $APP_NAME. Run 'bash build.sh' first." >&2
  exit 1
fi

echo "Launching $APP_PATH"

# CodeEdit is a self-contained .app bundle: all frameworks are embedded under
# Contents/Frameworks with @rpath, so no DYLD_* / QT_* runtime variables are
# required. `open -W` blocks until the app quits and forwards any extra args.
if [ "$#" -gt 0 ]; then
  exec open -W "$APP_PATH" --args "$@"
else
  exec open -W "$APP_PATH"
fi