Tekkaman

导航

 

build objc4 runtime

 1、Get the latest objc4 project codes from www.opensource.apple.com.

 2、Open the projetct, compile it, you will get compile error.

 3、you need some file to complete the compilation.

  1) Create Directory: /tmp/objc.dst/usr/include

  2) from libauto project, get auto_zone.h. Put it in the directory we just created.

  3) from libclosure project, get Block_private.h. Put it in the directory we just created.

  4) from libc project, get CrashReporterClient.h. Put it in the directory we just created.

      from libc project, get pthreads/pthread_machdep.h. Put it in the directory we just created with dirname of "system".

  5) from libdispatch project, get private-dir codes. Put it in the directory we just created with dirname of "dispatch".

  6) from dyld project, get dyld_priv.h. Put it in the directory we just created with dirname of "mach-o".

      from dyld project, get objc-shared-cache.h. Put it in the directory we just created.

  7) from xnu project, get osfmk/machine/cpu_capabilities.h. Put it in the directory we just created with dirname of "system/machine".

  8) from lanuchd project, get vproc_priv. Put it in the directory we just created.

  After did all these stuff, you'll get a structure as follow:

  

 4、In step3, you find alll the header files that you need. Compile the objc project, you still get error. You need do following 3 things:

  1) add LIBC_NO_LIBCRASHREPORTERCLIENT macro into you configuration.

  

  2) add #define CRSetCrashLogMessage2(x) /* nothing */ into CrashReporterClient.h. As follow:

  

  3) remove the link to the CrashReporterClient.

 5、Compile objc project, this time you'll success. There're some warning, you can ignore it. 

  

  

 6、for convenience,I wrote the code below to help get all the headers.

View Code
 1 # $1=src & $2=dst
 2 DST_PATH="./headers/"
 3 function findAndCopyTo
 4 {
 5     src_path=`find ./.. -path $1`
 6     if [ -z $src_path ] 2>&-
 7         then 
 8         echo "error, cannot find $1"
 9         exit 0
10     fi
11 
12     echo "has find $src_path"
13 
14     dst_path=${DST_PATH}${2}
15     #echo $dst_path
16 
17     if [ ! -x $dst_path ]
18         then 
19         mkdir $dst_path
20     fi
21 
22     cp $src_path $dst_path 2>&-
23 }
24 
25 rm -rf $DST_PATH
26 mkdir $DST_PATH
27 
28 #root
29 findAndCopyTo "*/auto_zone.h" "./"
30 findAndCopyTo "*/Block_private.h" "./"
31 findAndCopyTo "*/CrashReporterClient.h" "./"
32 findAndCopyTo "*/objc-shared-cache.h" "./"
33 findAndCopyTo "*/vproc_priv.h" "./"
34 
35 #dispatch
36 findAndCopyTo "*libdispatch*/benchmark.h" "./dispatch/"
37 findAndCopyTo "*libdispatch*/data_private.h" "./dispatch"
38 findAndCopyTo "*libdispatch*/private.h" "./dispatch"
39 findAndCopyTo "*libdispatch*/queue_private.h" "./dispatch"
40 findAndCopyTo "*libdispatch*/source_private.h" "./dispatch"
41 
42 #mach-o
43 findAndCopyTo "*dyld*/dyld_priv.h" "./mach-o"
44 
45 #system
46 findAndCopyTo "*Libc*/pthread_machdep.h" "./system"
47 
48 #system/machine
49 findAndCopyTo "*xnu*machine/cpu_capabilities.h" "./system/machine"

 

posted on 2013-04-30 01:25  Tekkaman  阅读(1518)  评论(1编辑  收藏  举报