Advertisement
Guest User

xcodebuild-log-filter

a guest
Feb 13th, 2011
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 2.43 KB | None | 0 0
  1. (defpackage "XCODEBUILD-FILTER"
  2.   (:use :cl))
  3.  
  4. (in-package "XCODEBUILD-FILTER")
  5.  
  6. (defvar *known-commands* (list "cd" "setenv"
  7.                                "CompileXIB" "CopyStringsFile"
  8.                                "CopyPlistFile" "CpResource"
  9.                                "ProcessInfoPlistFile" "builtin-infoPlistUtility"
  10.                                "ProcessPCH" "CompileC"
  11.                                "PhaseScriptExecution" "Touch"
  12.                                "GenerateDSYMFile" "Ld"))
  13.  
  14. (defun line-begins (line tag)
  15.   "Return t when the string in 'line' begins with the string in 'tag'."
  16.   (when (eql 0 (search tag line))
  17.     t))
  18.  
  19. (defun empty-line? (line)
  20.   "Return t when the string in 'line' is empty."
  21.   (string-equal line ""))
  22.  
  23. (defun line-command (line)
  24.   "Get the first space separated substring from the string in 'line' and return the substring."
  25.   (let ((pos (search " " line)))
  26.     (when pos
  27.       (subseq line 0 pos))))
  28.  
  29. (defun known (command)
  30.   "Return t when the string in 'command' is known."
  31.   (member command *known-commands* :test #'string-equal))
  32.  
  33. (with-open-file (out "/tmp/sexp"
  34.                      :direction :output
  35.                      :if-exists :overwrite
  36.                      :if-does-not-exist :create)
  37.   (with-open-file (in "/Users/wg/xcodebuild-log" ; created via xcodebuild -sdk iphonesimulator4.2 -configuration Debug build>~/xcodebuild-log
  38.                       :direction :input)
  39.     (let ((line nil)
  40.           (mode 'initial)
  41.           (node nil))
  42.       (loop for line = (read-line in nil nil nil) do
  43.  
  44.            (null line
  45.                  (return))
  46.  
  47.            (setf line (string-trim " " line))
  48.  
  49.            (case mode
  50.              (initial (when (line-begins line "Check dependencies") ; This tag was found by investigating the xcodebuild output.
  51.                         (setf mode 'begin)))
  52.  
  53.              (begin (if (empty-line? line)
  54.                         (let ((msgs (cdr node)))
  55.                           (when msgs
  56.                             (print (reverse msgs) out))
  57.                           (setf node nil)
  58.                           (setf mode 'end))
  59.  
  60.                         (when (not (known (line-command line)))
  61.                           (push line node))))
  62.  
  63.              (end (when (not (empty-line? line))
  64.                     (when (not (known (line-command line)))
  65.                       (push line node))
  66.                     (setf mode 'begin))))))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement