2010-07-05 [長年日記]

XcodeのプロジェクトをEmacsからビルド

XcodeのプロジェクトをEmcasからビルドするためのEmcas lisp。現在のディレクトリから上方向にプロジェクトとファイルを探しにいってビルドします。また、エラー出力も適当に切りだして、complilationバッファに出力します*1

(defun search-ancestors (directory pred)
  (cond ((not directory) nil)
        ((funcall pred directory) directory)
        ((string= directory "/") nil)
        (t (search-ancestors (expand-file-name (concat directory "/../")) pred))))

(defun xcode ()
  (interactive)
  (let ((directory (search-ancestors (expand-file-name "./")
                                     (lambda (directory)
                                       (directory-files directory t ".*\\.xcodeproj"))))
        (buffer "*compilation*")
        (inhibit-read-only t))
    (when directory
      (save-selected-window
        (switch-to-buffer-other-window buffer)
        (compilation-mode)
        (erase-buffer)
        (let ((process (start-process-shell-command "build"
                                                    buffer
                                                    (concat "cd " directory " && xcodebuild -activeconfiguration -sdk iphonesimulator3.2")))
              (filter (lambda (process string)
                        (with-current-buffer (process-buffer process)
                          (let ((inhibit-read-only t))
                            (save-excursion
                              (goto-char (process-mark process))
                              (mapcar (lambda (s)
                                        (when (string-match "^\\(/[A-Za-z0-9_---.]+\\)+:" s)
                                          (insert s)
                                          (insert "\n")))
                                      (split-string string "\n"))
                              (set-marker (process-mark process) (point)))
                            (goto-char (process-mark process)))))))
          (set-process-filter process filter))))))

*1  ただし、かなりいい加減です

[]

トップ «前の日記(2010-06-24) 最新