-
Notifications
You must be signed in to change notification settings - Fork 458
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resolve variable substitution for xcconfig declared build settings #501
Changes from 5 commits
ba03682
3738989
e348184
b7aa0ee
7f4ff33
32d4e8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,15 +77,20 @@ def type | |
# @param [String] key | ||
# the key of the build setting. | ||
# | ||
# @param [PBXNativeTarget] root_target | ||
# use this to resolve complete recursion between project and targets | ||
# | ||
# @return [String] The value of the build setting | ||
# | ||
def resolve_build_setting(key) | ||
def resolve_build_setting(key, root_target = nil) | ||
setting = build_settings[key] | ||
setting = resolve_variable_substitution(setting, root_target) if !setting.nil? && setting.is_a?(String) | ||
config_setting = base_configuration_reference && config[key] | ||
config_setting = resolve_variable_substitution(config_setting, root_target) if !config_setting.nil? && config_setting.is_a?(String) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. checking both nil? and is_a? is redundant There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes totally sense! |
||
|
||
project_setting = project.build_configuration_list[name] | ||
project_setting = nil if project_setting == self | ||
project_setting &&= project_setting.resolve_build_setting(key) | ||
project_setting &&= project_setting.resolve_build_setting(key, root_target) | ||
|
||
[project_setting, config_setting, setting].compact.reduce do |inherited, value| | ||
expand_build_setting(value, inherited) | ||
|
@@ -103,6 +108,20 @@ def expand_build_setting(build_setting_value, config_value) | |
build_setting_value.map { |value| Constants::INHERITED_KEYWORDS.include?(value) ? inherited : value }.flatten | ||
end | ||
|
||
def resolve_variable_substitution(config_setting, root_target) | ||
expression = /\$[{(]([^inherited][$(){}_a-zA-Z0-9]*?)[})]/ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract this into a constant and please comment the regexp There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
match_data = config_setting.match(expression) | ||
if match_data.nil? | ||
return name if config_setting.eql?('CONFIGURATION') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is an exhaustive way to resolve the value, would love feedback on this. |
||
if root_target | ||
return root_target.build_configuration_list[name].resolve_build_setting(config_setting, root_target) || config_setting | ||
else | ||
return resolve_build_setting(config_setting, root_target) || config_setting | ||
end | ||
end | ||
resolve_variable_substitution(config_setting.sub(expression, resolve_variable_substitution(match_data.captures.first, root_target)), root_target) | ||
end | ||
|
||
def sorted_build_settings | ||
sorted = {} | ||
build_settings.keys.sort.each do |key| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,17 @@ | ||
USER_DEFINED = PROJECT_XCCONFIG_VALUE | ||
OTHER_LDFLAGS = -framework UIKit | ||
PRODUCT_BUNDLE_IDENTIFIER_Release = com.cocoapods.app | ||
PRODUCT_BUNDLE_IDENTIFIER_Debug = com.cocoapods.app.dev | ||
PRODUCT_BUNDLE_IDENTIFIER = $(PRODUCT_BUNDLE_IDENTIFIER_$(CONFIGURATION)) | ||
DEVELOPMENT_TEAM = $(USER_DEFINED) | ||
CONFIG_APPEND = $(USER_DEFINED)_$(CONFIGURATION) | ||
|
||
USER_DEFINED_XCCONFIG_PROJECT_Release = User Defined xcconfig project Release | ||
USER_DEFINED_XCCONFIG_PROJECT_Debug = User Defined xcconfig project Debug | ||
USER_DEFINED_XCCONFIG_PROJECT = $(USER_DEFINED_XCCONFIG_PROJECT_$(CONFIGURATION)) | ||
|
||
PROJECT_REFERENCE_TARGET = $(TARGET_USER_DEFINED) | ||
PROJECT_REFERENCE_PROJECT = $(PROJECT_USER_DEFINED) | ||
PROJECT_REFERENCE_XCCONFIG_TARGET = $(USER_DEFINED_XCCONFIG_TARGET) | ||
PROJECT_REFERENCE_XCCONFIG_PROJECT = $(USER_DEFINED_XCCONFIG_PROJECT) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,11 @@ | ||
USER_DEFINED = ${inherited} TARGET_XCCONFIG_VALUE | ||
OTHER_LDFLAGS = ${inherited} -framework CoreAnimation | ||
|
||
USER_DEFINED_XCCONFIG_TARGET_Release = User Defined xcconfig target Release | ||
USER_DEFINED_XCCONFIG_TARGET_Debug = User Defined xcconfig target Debug | ||
USER_DEFINED_XCCONFIG_TARGET = $(USER_DEFINED_XCCONFIG_TARGET_$(CONFIGURATION)) | ||
|
||
TARGET_REFERENCE_TARGET = $(TARGET_USER_DEFINED) | ||
TARGET_REFERENCE_PROJECT = $(PROJECT_USER_DEFINED) | ||
TARGET_REFERENCE_XCCONFIG_TARGET = $(USER_DEFINED_XCCONFIG_TARGET) | ||
TARGET_REFERENCE_XCCONFIG_PROJECT = $(USER_DEFINED_XCCONFIG_PROJECT) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
checking both
nil?
andis_a?
is redundantThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes totally sense!