mirror of
https://github.com/textmate/textmate.git
synced 2026-01-22 13:17:55 -05:00
Motivated by a lot of “where is the syntax highlight?” questions from users that build from source, we now always create the DefaultBundles.tbz (if it doesn’t exist).
118 lines
3.7 KiB
Bash
Executable File
118 lines
3.7 KiB
Bash
Executable File
#!/bin/sh
|
||
# set -u
|
||
function error () { printf >&2 "%s\n\nPlease see README.md for build instructions.\n" "$1"; exit 1; }
|
||
|
||
# =================================================
|
||
# = Fallback build directory and signing identity =
|
||
# =================================================
|
||
|
||
: ${builddir:=$HOME/build/TextMate}
|
||
: ${identity:=-}
|
||
: ${rest_api:=https://api.textmate.org}
|
||
|
||
# ========================================================
|
||
# = Application name, version, revision, and required OS =
|
||
# ========================================================
|
||
|
||
name=TextMate
|
||
ver=2.0
|
||
rev=1
|
||
min_os=10.7
|
||
|
||
rev=$(( $(curl -sf "${rest_api}/releases/nightly/revision")+1 )) || \
|
||
if test -d .git && which -s git; then
|
||
rev=$(git log --oneline master | wc -l)
|
||
fi
|
||
|
||
# ===============================================
|
||
# = Find clang via xcrun, MacPorts, or Homebrew =
|
||
# ===============================================
|
||
|
||
clang_good_enough() {
|
||
[[ -x "$CC" && -x "$CXX" ]] && "$CC" &>/dev/null -x objective-c -include Foundation/Foundation.h -c -o /dev/null - <<< 'int main () { id str = @("str"); return 0; }'
|
||
}
|
||
test_xcode_clang() {
|
||
if which -s xcrun; then
|
||
CC=$(xcrun -find clang)
|
||
CXX=$(xcrun -find clang++)
|
||
clang_good_enough && return
|
||
fi
|
||
false
|
||
}
|
||
test_local_clang() {
|
||
for cc in /{opt,usr}/local/bin/clang /usr/bin/clang; do
|
||
CC="${cc}"
|
||
CXX="${cc}++"
|
||
clang_good_enough && return
|
||
done
|
||
false
|
||
}
|
||
|
||
clang_good_enough || test_xcode_clang || test_local_clang || error "$CC is too old to build this project."
|
||
|
||
# ===============================
|
||
# = Check if boost is installed =
|
||
# ===============================
|
||
|
||
if which -s brew && [[ -z "$boostdir" && ! -d /usr/local/include/boost ]]; then
|
||
boostdir=$(brew --prefix boost)/include/boost
|
||
fi
|
||
|
||
for dir in "${boostdir:-/usr/include/boost}" /{opt,usr}/local/include/boost ${CPATH//:/ }; do
|
||
if [[ ! -L "${builddir}/include/boost" && -d "${dir}" ]]; then
|
||
mkdir -p "${builddir}/include" && ln -fs "${dir}" "${builddir}/include/boost"
|
||
fi
|
||
done
|
||
|
||
test -L "${builddir}/include/boost" || error "*** boost not installed."
|
||
|
||
# ==================================
|
||
# = Locate Xcode directory and SDK =
|
||
# ==================================
|
||
|
||
xcodedir=/Developer
|
||
sdk="/Developer/SDKs/${sdk:-MacOSX10.7}.sdk"
|
||
|
||
if which -s xcode-select; then
|
||
xcodedir=$(xcode-select -print-path)
|
||
if ! [[ -e "$sdk" ]]; then
|
||
sdk="$xcodedir/Platforms/MacOSX.platform$sdk"
|
||
fi
|
||
fi
|
||
|
||
if ! [[ -e "$sdk" ]]; then
|
||
sdk=""
|
||
echo 2>&1 "WARNING: Building without platform-specific SDK."
|
||
fi
|
||
|
||
# ===============================================
|
||
# = Check if we can use pbzip2 instead of bzip2 =
|
||
# ===============================================
|
||
|
||
bzip2_flag="-j"
|
||
if which -s pbzip2; then
|
||
bzip2_flag="--use-compress-prog=pbzip2"
|
||
fi
|
||
|
||
# ==============================
|
||
# = Check various dependencies =
|
||
# ==============================
|
||
|
||
which -s multimarkdown || which -s maruku || which -s Markdown.pl || error "*** no markdown converter installed."
|
||
|
||
for dep in ninja ragel pgrep pkill "$CC" "$CXX"; do
|
||
which -s "$dep" || error "*** dependency missing: ‘${dep}’."
|
||
done
|
||
|
||
# =====================================
|
||
# = Generate fixtures and build files =
|
||
# =====================================
|
||
|
||
mkdir -p "$builddir/Frameworks/SoftwareUpdate/fixtures"
|
||
DST=$(cd >/dev/null "$builddir/Frameworks/SoftwareUpdate/fixtures"; pwd) make -C Frameworks/SoftwareUpdate/fixtures
|
||
|
||
bin/gen_build -o build.ninja -C "$builddir" -dAPP_NAME="$name" -dAPP_VERSION="$ver" -dAPP_REVISION="$rev" -dAPP_MIN_OS="$min_os" -dCC="$CC" -dCXX="$CXX" -dxcodedir="$xcodedir" -didentity="$identity" -drest_api="$rest_api" -dsdk="$sdk" -dbzip2_flag="$bzip2_flag" target
|
||
|
||
BUNDLES_TBZ=Applications/TextMate/resources/DefaultBundles.tbz
|
||
test -e "$BUNDLES_TBZ" || builddir="$builddir" bin/create_default_bundles_tbz "$BUNDLES_TBZ"
|