-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #166 from mrackwitz/ext_build_settings
Generate targets with same build settings as Xcode (related to #164)
- Loading branch information
Showing
163 changed files
with
9,676 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
module Xcodeproj | ||
class Command | ||
class ConfigDump < Command | ||
def self.banner | ||
<<-eos.strip_heredoc | ||
Dumps the build settings of all project targets for all configurations in | ||
directories named by the target in given output directory. | ||
$ config-dump PROJECT OUTPUT | ||
It extracts common build settings in a per target base.xcconfig file. | ||
If no `PROJECT` is specified then the current work directory is searched | ||
for one. | ||
If no `OUTPUT` is specified then the project directory will be used.%) | ||
eos | ||
end | ||
|
||
def initialize(argv) | ||
xcodeproj_path = argv.shift_argument | ||
@xcodeproj_path = File.expand_path(xcodeproj_path) if xcodeproj_path | ||
|
||
@output_path = Pathname(argv.shift_argument || '.') | ||
unless @output_path.directory? | ||
raise Informative, 'The output path must be a directory.' | ||
end | ||
|
||
super unless argv.empty? | ||
end | ||
|
||
def run | ||
dump_all_configs(xcodeproj, 'Project') | ||
|
||
xcodeproj.targets.each do |target| | ||
dump_all_configs(target, target.name) | ||
end | ||
end | ||
|
||
def dump_all_configs(configurable, name) | ||
path = Pathname(name) | ||
|
||
# Dump base configuration to file | ||
base_settings = extract_common_settings!(configurable.build_configurations) | ||
base_file_path = path + "#{name}_base.xcconfig" | ||
dump_config_to_file(base_settings, base_file_path) | ||
|
||
# Dump each configuration to file | ||
configurable.build_configurations.each do |config| | ||
settings = config.build_settings | ||
dump_config_to_file(settings, path + "#{name}_#{config.name.downcase}.xcconfig", [base_file_path]) | ||
end | ||
end | ||
|
||
def extract_common_settings!(build_configurations) | ||
# Grasp all common build settings | ||
all_build_settings = build_configurations.map(&:build_settings) | ||
common_build_settings = all_build_settings.reduce do |settings, config_build_settings| | ||
settings.select { |key, value| value == config_build_settings[key] } | ||
end | ||
|
||
# Remove all common build settings from each configuration specific build settings | ||
build_configurations.each do |config| | ||
config.build_settings.reject! { |key| !common_build_settings[key].nil? } | ||
end | ||
|
||
common_build_settings | ||
end | ||
|
||
def dump_config_to_file(settings, file_path, includes = []) | ||
dir = @output_path + file_path + '..' | ||
dir.mkdir unless dir.exist? | ||
|
||
config = Config.new(settings) | ||
config.includes = includes | ||
config.save_as(@output_path + file_path) | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.