build.sh raw

   1  #!/bin/bash
   2  set -e
   3  cd "$(dirname "$0")"
   4  ROOT="${MOXIEROOT:-../..}"
   5  OUT="${1:-/tmp/mxlex}"
   6  
   7  # Try new moxie first
   8  if command -v moxie >/dev/null 2>&1; then
   9      echo "trying: moxie (new)" >&2
  10      if MOXIEROOT="$ROOT" moxie build -o "$OUT" . 2>&1; then
  11          echo "built with new moxie: $OUT" >&2
  12          exit 0
  13      fi
  14      echo "new moxie failed, falling back to legacy" >&2
  15  fi
  16  
  17  # Fall back to legacy
  18  LEGACY="$ROOT/legacy/moxie"
  19  if [ ! -x "$LEGACY" ]; then
  20      echo "error: no legacy compiler at $LEGACY" >&2
  21      exit 1
  22  fi
  23  echo "trying: legacy moxie" >&2
  24  MOXIEROOT="$ROOT" "$LEGACY" build -gc=dealloc -o "$OUT" . 2>&1
  25  echo "built with legacy: $OUT" >&2
  26