1# create osx_ruby.h and osx_intern.h 2# avoid `ID' and `T_DATA' confict headers between Cocoa and Ruby. 3new_filename_prefix = 'osx_' 4ruby_h = File.join(@config['ruby-header-dir'], 'ruby.h') 5intern_h = File.join(@config['ruby-header-dir'], 'intern.h') 6[ ruby_h, intern_h ].each do |src_path| 7 dst_fname = new_filename_prefix + File.basename(src_path) 8 dst_fname = "src/objc/" + dst_fname 9 $stderr.puts "create #{File.expand_path(dst_fname)} ..." 10 File.open(dst_fname, 'w') do |dstfile| 11 IO.foreach(src_path) do |line| 12 unless @config['macosx-deployment-target'].to_f > 10.5 13 line.gsub!( /\b(ID|T_DATA)\b/, 'RB_\1' ) 14 line.gsub!( /\bintern\.h\b/, "#{new_filename_prefix}intern.h" ) 15 end 16 dstfile.puts( line ) 17 end 18 end 19end 20 21if @config['gen-bridge-support'] != 'no' 22 # generate bridge support metadata files 23 out_dir = File.join(Dir.pwd, 'bridge-support') 24 sdkroot = @config['sdkroot'] 25 archs = @config['target-archs'] 26 cflags = '' 27 cflags << archs.gsub(/\A|\s+/, ' -arch ') if archs.size > 0 28 cflags << " -isysroot #{sdkroot}" if sdkroot.size > 0 29 Dir.chdir('../misc/bridgesupport') do 30 command("BSROOT=\"#{out_dir}\" CFLAGS=\"#{cflags}\" #{@config['ruby-prog']} build.rb") 31 end 32end 33