Emacs xcode-compile
OSX 2010. 6. 1. 17:31이번에는 Emacs에서 Xcode project를 build하는 것이다.
다음의 emacs lisp 코드를 .emacs 파일안에 넣어놓으면 M-x xcode-compile이 나 F10키로 바로 컴파일이 가능하다.
- (defvar xcode-compile-sdks nil)
- (defvar xcode-compile-sdk-history nil)
- (dolist (line
- (split-string
- (with-temp-buffer
- (call-process "xcodebuild" nil t nil "-showsdks")
- (buffer-string))
- "\n" t)
- )
- (let ((comps (split-string line "-sdk " t)))
- (if (> (length comps) 1)
- (add-to-list 'xcode-compile-sdks (car (last comps)))
- )
- )
- )
- (defun xcode-compile ()
- (interactive)
- (let ((command "xcodebuild -activeconfiguration -activetarget"))
- (setq command
- (concat
- command
- (if xcode-compile-sdks
- (let ((default-sdk (or (car xcode-compile-sdk-history) (car xcode-compile-sdks))))
- (concat
- " -sdk "
- (completing-read
- (format "Compile with sdk (default %s): " default-sdk)
- xcode-compile-sdks
- nil
- t
- nil
- 'xcode-compile-sdk-history
- default-sdk
- )
- )
- )
- )
- (let ((dir ".") (files nil))
- (while
- (progn
- (setq files (directory-files dir nil "\\.xcodeproj\\'"))
- (and (not (string-equal "/" (expand-file-name dir))) (null files))
- )
- (setq dir (concat (file-name-as-directory dir) ".."))
- )
- (unless (null files) (concat " -project " (file-name-as-directory dir) (car files)))
- )
- )
- )
- (compile (read-string "Compile command: " (concat command " ")))
- )
- )
- (define-key global-map [f10] 'xcode-compile)
http://han9kin.doesntexist.com/29#recentTrackback