道化プログラミング

開発メモとか道化とか色々

TextMate2のビルドにハマった対処メモ

Hacke Newsletter - Issue#109に"Textmate2 Goes Open Source"とかあって超ビックリして、早速ビルドしてやろうと思い立った。何年か前にTextMate(ver.1の方)を4000円くらい出して買ったのになんてことだ。かねかえせ...
https://github.com/textmate/textmate

まずは結論から。後に経緯。
ちなみにOSは

です。

対処まとめ

  • clangのバージョン古すぎ→ XcodeアップデートしてPreference > Downloads > ComponentsからCommand Line Toolsいんすこ→スイッチする。
$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer
  • で、結局は:
$ brew install –-HEAD https://raw.github.com/adamv/homebrew-alt/master/head-only/ninja.rb
$ brew install ragel boost multimarkdown hg
$ git clone --recursive https://github.com/textmate/textmate.git textmate
$ cd textmate
$ ./configure && ninja

でおk

いかにしてハマったか

クローン。

$ git clone https://github.com/textmate/textmate.git
$ cd textmate

まずはprerequisitesとか書いてあるものを入れてあげる

$ brew install proctools

ほい。

$ brew install ragel boost multimarkdown hg ninja

だがしかしninjaなんてformula無いんだけど!って言われた。

$ brew install ragel boost multimarkdown hg

とりあえず忍者はあとまわし
調べると次のようにすれば良いと分かった

$ brew install –-HEAD https://raw.github.com/adamv/homebrew-alt/master/head-only/ninja.rb

おー。忍者入った。

あとはビルドするだけ。だったんだけど

$ ./configure && ninja

ってしたら

/Developer/usr/bin/clang is too old to build this project.

Please see README.md for build instructions.
ninja: error: loading 'build.ninja': No such file or directory

って言われた。は?古すぎるやと?ちょっとくらい頑張れや?

$ which clang
/usr/local/bin/clang

あれ?場所ちがくね?なんで?は?
configureファイルを見てみると

if which -s xcrun; then
	: ${CC:=$(xcrun -find clang)}
	: ${CXX:=$(xcrun -find clang++)}
fi

for cc in /{opt,usr}/local/bin/clang /usr/bin/clang; do
	if [[ ! -x "$CC" || ! -x "$CXX" ]]; then
		CC="${cc}"
		CXX="${cc}++"
	fi
done

test -x "$CC" || error "*** clang not installed."
"$CC" &>/dev/null -x objective-c -include Foundation/Foundation.h -c -o /dev/null - <<< 'int main () { id str = @("str"); return 0; }' || error "$CC is too old to build this project."

ここ超あやしーな。

$ xcrun -find clang
/Developer/usr/bin/clang

あ、やっぱり。ここか。ってことでxcrunって書いてる部分をwhichに書き換えて再度実行。

$ ./configure && ninja
/usr/local/bin/clang is too old to build this project.

Please see README.md for build instructions.
ninja: error: loading 'build.ninja': No such file or directory

まだ古いん???なんなん???
とりあえずいじった部分はもとにもどす。
Xcodeが4.2と古かったので4.4にアップデート。
なにもかわらず。
また調べる。command line toolsはどうやらPreference > Downloads > Componentsのとこから手動で入れなアカンっぽい。入れる。
なんもかわらへん。なんなん?
よく見るとXCODE-SELECTがなんたらって書いてある。
ってか4.2までは/Developerにあったのにいつの間にか/Applicationsに移動してるやん!なんで!
とりあえず

$ sudo xcode-select -switch /Applications/Xcode.app/Contents/Developer

おし、これでどうや。

$ xcrun clang --version
Apple clang version 4.0 (tags/Apple/clang-421.0.60) (based on LLVM 3.1svn)
Target: x86_64-apple-darwin11.4.0
Thread model: posix

キタコレ!ってわけでビルドじゃ

$ ./configure && ninja
Create fixtures for Software Update tests…
rm /Users/takuma7/build/TextMate/Frameworks/SoftwareUpdate/fixtures/secret.pem
bin/gen_build:391:in `dynamic_lib': undefined method `[]' for nil:NilClass (NoMethodError)
	from bin/gen_build:391:in `map'
	from bin/gen_build:391:in `dynamic_lib'
	from bin/gen_build:640
	from bin/gen_build:638:in `each'
	from bin/gen_build:638
	from bin/gen_build:590:in `open'
	from bin/gen_build:590

は?もうなんなん?
調べたらIssueにあがってた。Issue #21
とりあえずtextmateフォルダいったん削除して

$ git clone --recursive https://github.com/textmate/textmate.git textmate
$ cd textmate
$ ./configure && ninja

できた!!!動いたよ!!!