Commit 10abfd7c authored by Luke Redpath's avatar Luke Redpath

Support the setting of file-specific compiler flags when adding source files to the project.

We'll need this to support #8.
parent 6f5233ac
......@@ -50,14 +50,15 @@ module Pod
end.compact
end
def add_source_file(file)
def add_source_file(file, compiler_flags = nil)
file_ref_uuid = add_file_reference(file, 'SOURCE_ROOT')
add_file_to_group(file_ref_uuid, 'Pods')
if file.extname == '.h'
build_file_uuid = add_build_file(file_ref_uuid, "settings" => { "ATTRIBUTES" => ["Public"] })
add_file_to_list('PBXHeadersBuildPhase', build_file_uuid)
else
build_file_uuid = add_build_file(file_ref_uuid)
extra = compiler_flags ? {"settings" => { "COMPILER_FLAGS" => compiler_flags }} : {}
build_file_uuid = add_build_file(file_ref_uuid, extra)
add_file_to_list('PBXSourcesBuildPhase', build_file_uuid)
end
file_ref_uuid
......
......@@ -38,6 +38,19 @@ describe "Pod::Xcode::Project" do
end
end
it "adds custom compiler flags to the PBXBuildFile object if specified" do
build_file_uuids = []
%w{ m mm c cpp }.each do |ext|
path = Pathname.new("path/to/file.#{ext}")
file_ref_uuid = @project.add_source_file(path, '-fno-obj-arc')
@project.find_object({
'isa' => 'PBXBuildFile',
'fileRef' => file_ref_uuid,
'settings' => {'COMPILER_FLAGS' => '-fno-obj-arc' }
}).should.not == nil
end
end
it "adds a `h' file as a build file and adds it to the `headers build' phase list" do
path = Pathname.new("path/to/file.h")
file_ref_uuid = @project.add_source_file(path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment