mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-24 04:46:05 +08:00
use clang when compiling vendored projects (since it's the only compiler that supports arc)
This commit is contained in:
@@ -17,8 +17,8 @@ module Motion; module Project;
|
||||
|
||||
# Locate SDK and compilers.
|
||||
sdk = config.sdk(platform)
|
||||
cc = config.cc(platform)
|
||||
cxx = config.cxx(platform)
|
||||
cc = config.locate_compiler(platform, 'gcc')
|
||||
cxx = config.locate_compiler(platform, 'g++')
|
||||
|
||||
build_dir = File.join(config.versionized_build_dir(platform))
|
||||
App.info 'Build', build_dir
|
||||
|
||||
@@ -296,18 +296,23 @@ module Motion; module Project
|
||||
platform + sdk_version + '.sdk')
|
||||
end
|
||||
|
||||
def cc(platform)
|
||||
File.join(platform_dir(platform), 'Developer/usr/bin/gcc')
|
||||
end
|
||||
def locate_compiler(platform, *execs)
|
||||
paths = [File.join(platform_dir(platform), 'Developer/usr/bin')]
|
||||
paths.unshift File.join(xcode_dir, 'Toolchains/XcodeDefault.xctoolchain/usr/bin') if platform == 'iPhoneSimulator'
|
||||
|
||||
def cxx(platform)
|
||||
File.join(platform_dir(platform), 'Developer/usr/bin/g++')
|
||||
execs.each do |exec|
|
||||
paths.each do |path|
|
||||
cc = File.join(path, exec)
|
||||
return cc if File.exist?(cc)
|
||||
end
|
||||
end
|
||||
App.fail "Can't locate compilers for platform `#{platform}'"
|
||||
end
|
||||
|
||||
def archs(platform)
|
||||
Dir.glob(File.join(datadir, platform, '*.bc')).map do |path|
|
||||
path.scan(/kernel-(.+).bc$/)[0][0]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def arch_flags(platform)
|
||||
|
||||
@@ -40,10 +40,10 @@ module Motion; module Project;
|
||||
compiler =
|
||||
case File.extname(srcfile)
|
||||
when '.c', '.m'
|
||||
@config.cc(platform)
|
||||
@config.locate_compiler(platform, 'clang', 'gcc')
|
||||
when '.cpp', '.cxx', '.mm'
|
||||
cplusplus = true
|
||||
@config.cxx(platform)
|
||||
@config.locate_compiler(platform, 'clang++', 'g++')
|
||||
else
|
||||
# Not a valid source file, skip.
|
||||
next
|
||||
@@ -69,7 +69,7 @@ EOS
|
||||
if File.exist?(build_dir)
|
||||
libname = 'lib' + File.basename(@path) + '.a'
|
||||
Dir.chdir(build_dir) do
|
||||
objs = Dir.glob('*.o')
|
||||
objs = Dir.glob('*/**/*.o')
|
||||
FileUtils.rm_rf libname
|
||||
unless objs.empty?
|
||||
sh "#{@config.locate_binary('ar')} cq #{libname} #{objs.join(' ')}"
|
||||
@@ -85,7 +85,7 @@ EOS
|
||||
bs_file = File.basename(@path) + '.bridgesupport'
|
||||
if !File.exist?(bs_file) or headers.any? { |h| File.mtime(h) > File.mtime(bs_file) }
|
||||
includes = headers.map { |p| "-I" + File.dirname(p) }.uniq.join(' ')
|
||||
sh "/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"#{includes}\" #{headers.join(' ')} -o \"#{bs_file}\""
|
||||
sh "/usr/bin/gen_bridge_metadata --format complete --no-64-bit --cflags \"-I. #{includes}\" #{headers.join(' ')} -o \"#{bs_file}\""
|
||||
end
|
||||
bs_files << bs_file
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user