From cc4647e3b4c19d044e425cbd49ccf465401b3fc6 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 21:51:42 +0300 Subject: [PATCH 01/30] Add check on type annotation for Bool --- xcode/.swiftlint.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 4bbc84c..6c66505 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -239,6 +239,12 @@ custom_rules: message: "Use сontentView instead of self for addSubview or addSubviews methods in cell." severity: error + redundant_type_annotation_bool: + name: "Redundant type annotation for Bool" + regex: '((: *Bool *= *)|(BehaviourRelay *= *\S*\s*))((true)|(false))' + message: "Using a type annotation for Bool is redundant" + severity: error + # Rx unused_map_parameter: From 05fd54ed8db80ded84fcd56f2a91ed2d79318064 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 21:58:35 +0300 Subject: [PATCH 02/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 6c66505..b535f1e 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -241,7 +241,7 @@ custom_rules: redundant_type_annotation_bool: name: "Redundant type annotation for Bool" - regex: '((: *Bool *= *)|(BehaviourRelay *= *\S*\s*))((true)|(false))' + regex: '((var|let)) *\w+ *: *((Bool *= *)|(BehaviourRelay *= *\S*\s*))((true)|(false))' message: "Using a type annotation for Bool is redundant" severity: error From 7979e8088bfed6ef1ccffb6548a80d678567df5f Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 22:42:37 +0300 Subject: [PATCH 03/30] Update rule --- xcode/.swiftlint.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index b535f1e..bfd2f73 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -245,6 +245,12 @@ custom_rules: message: "Using a type annotation for Bool is redundant" severity: error + redundant_type_annotation_string: + name: "Redundant type annotation for Bool" + regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\(\s*value\s*:)) *((true)|(false))' + message: "Using a type annotation for Bool is redundant" + severity: error + # Rx unused_map_parameter: From 74b5c1da9115c6dd760e8c210e49c61112aacd31 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 22:43:26 +0300 Subject: [PATCH 04/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index bfd2f73..bab5181 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -247,7 +247,7 @@ custom_rules: redundant_type_annotation_string: name: "Redundant type annotation for Bool" - regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\(\s*value\s*:)) *((true)|(false))' + regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\(\ *value\ *:)) *((true)|(false))' message: "Using a type annotation for Bool is redundant" severity: error From d6589c53a3f39eb90471fd25323d0eacfec17504 Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 22:46:05 +0300 Subject: [PATCH 05/30] Update rule --- xcode/.swiftlint.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index bab5181..a22ae70 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -240,12 +240,6 @@ custom_rules: severity: error redundant_type_annotation_bool: - name: "Redundant type annotation for Bool" - regex: '((var|let)) *\w+ *: *((Bool *= *)|(BehaviourRelay *= *\S*\s*))((true)|(false))' - message: "Using a type annotation for Bool is redundant" - severity: error - - redundant_type_annotation_string: name: "Redundant type annotation for Bool" regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\(\ *value\ *:)) *((true)|(false))' message: "Using a type annotation for Bool is redundant" From 1eedb7120912f1960bad93214fd7d8d6636d47eb Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 22:48:24 +0300 Subject: [PATCH 06/30] Small corrections --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index a22ae70..6be9284 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -241,7 +241,7 @@ custom_rules: redundant_type_annotation_bool: name: "Redundant type annotation for Bool" - regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\(\ *value\ *:)) *((true)|(false))' + regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\( *value *:)) *((true)|(false))' message: "Using a type annotation for Bool is redundant" severity: error From 0e5f9b67f65ce402768438bc573b1df8f548390c Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 1 Jun 2020 23:00:46 +0300 Subject: [PATCH 07/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 6be9284..3fc2c03 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -241,7 +241,7 @@ custom_rules: redundant_type_annotation_bool: name: "Redundant type annotation for Bool" - regex: '((var|let)) *\w+ *((: *Bool *=)|([^=]*= *BehaviourRelay\( *value *:)) *((true)|(false))' + regex: '((var|let)) *\w+ *((: *Bool *=)|((\w| |<|>|:)*= *BehaviorRelay\( *value *:)) *((true)|(false))' message: "Using a type annotation for Bool is redundant" severity: error From 2ff3fb763a052e40f37c56787f029f6fce5143b9 Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Thu, 4 Jun 2020 18:53:20 +0300 Subject: [PATCH 08/30] Include numbers in build badge --- xcode/commonFastfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 382a448..34bf137 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -87,7 +87,10 @@ end private_lane :addShield do |options| buildNumber = options[:buildNumber] - buildDescription = options[:xcconfig_name].scan(/\p{Upper}/)[1..2].join + buildDescription = options[:xcconfig_name] + .split(/(?=[A-Z])/) + .map { |v| v.gsub(/[[:lower:]]+/, "") }[1..2] + .join begin add_badge( From e512ec339d1bd2b51e0a4d53a2460a004a62b10d Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 4 Jun 2020 23:15:53 +0300 Subject: [PATCH 09/30] Update script --- xcode/config_generator/render_xcconfigs.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index dbe8d84..6278cbf 100644 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -51,11 +51,26 @@ def generate_bundle_id(target_name, account_type) return config_option($bundle_id_key, bundle_id) end +def generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type) + google_service_info_plist_path = target_name + "/Resources/" + + if account_type == "AppStore" + google_service_info_plist_path += "AppStore-GoogleService-Info.plist" + elsif account_type == "Enterprise" + google_service_info_plist_path += "Enterprise-GoogleService-Info.plist" + else + google_service_info_plist_path += "Standard-GoogleService-Info.plist" + end + + return config_option(google_service_info_plist_key, google_service_info_plist_path) +end + # generate missing properties if needed def generate_missing_properties(target_name, properties, account_type) result = [] development_team_key = "DEVELOPMENT_TEAM" provisioning_key = "PROVISIONING_PROFILE_SPECIFIER" + google_service_info_plist_key = "GOOGLE_SERVICE_INFO_PLIST_PATH" unless properties.key?($bundle_id_key) bundle_id_config = generate_bundle_id(target_name, account_type) @@ -72,6 +87,10 @@ def generate_missing_properties(target_name, properties, account_type) unless properties.key?(provisioning_key) result.append(generate_provisioning_profile(provisioning_key, bundle_id, account_type)) end + + unless properties.key?(google_service_info_plist_key) + result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type)) + end return result end From 5c277597f7044ee9a6f6c56d8d4fe2fdc79f4ebe Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 4 Jun 2020 23:38:30 +0300 Subject: [PATCH 10/30] Update script --- xcode/config_generator/render_xcconfigs.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 6278cbf..2838ebd 100644 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -58,8 +58,10 @@ def generate_google_service_info_plist_path(google_service_info_plist_key, targe google_service_info_plist_path += "AppStore-GoogleService-Info.plist" elsif account_type == "Enterprise" google_service_info_plist_path += "Enterprise-GoogleService-Info.plist" - else + elsif account_type == "Standard" google_service_info_plist_path += "Standard-GoogleService-Info.plist" + else + google_service_info_plist_path = "" end return config_option(google_service_info_plist_key, google_service_info_plist_path) @@ -89,7 +91,11 @@ def generate_missing_properties(target_name, properties, account_type) end unless properties.key?(google_service_info_plist_key) - result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type)) + google_service_info_plist = generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type) + + if google_service_info_plist[google_service_info_plist_key] + result.append(google_service_info_plist) + end end return result From 4770ee7f78d3e29f86817f272fc50bf9a7d45084 Mon Sep 17 00:00:00 2001 From: Vlad Date: Thu, 4 Jun 2020 23:44:17 +0300 Subject: [PATCH 11/30] Revert "Update script" This reverts commit 5c277597f7044ee9a6f6c56d8d4fe2fdc79f4ebe. --- xcode/config_generator/render_xcconfigs.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 2838ebd..6278cbf 100644 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -58,10 +58,8 @@ def generate_google_service_info_plist_path(google_service_info_plist_key, targe google_service_info_plist_path += "AppStore-GoogleService-Info.plist" elsif account_type == "Enterprise" google_service_info_plist_path += "Enterprise-GoogleService-Info.plist" - elsif account_type == "Standard" - google_service_info_plist_path += "Standard-GoogleService-Info.plist" else - google_service_info_plist_path = "" + google_service_info_plist_path += "Standard-GoogleService-Info.plist" end return config_option(google_service_info_plist_key, google_service_info_plist_path) @@ -91,11 +89,7 @@ def generate_missing_properties(target_name, properties, account_type) end unless properties.key?(google_service_info_plist_key) - google_service_info_plist = generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type) - - if google_service_info_plist[google_service_info_plist_key] - result.append(google_service_info_plist) - end + result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type)) end return result From 0e0e66775e3a82c3767623aba251f98526fe94f4 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 5 Jun 2020 12:34:49 +0300 Subject: [PATCH 12/30] Add new rule --- xcode/.swiftlint.yml | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 3fc2c03..7a89f38 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -242,7 +242,13 @@ custom_rules: redundant_type_annotation_bool: name: "Redundant type annotation for Bool" regex: '((var|let)) *\w+ *((: *Bool *=)|((\w| |<|>|:)*= *BehaviorRelay\( *value *:)) *((true)|(false))' - message: "Using a type annotation for Bool is redundant" + message: "Using a type annotation for Bool is redundant." + severity: error + + parameter_repetition: + name: "Parameter repetition" + regex: 'func \w*(\w+)(<.+>)?\((?i)\1' + message: "The parameter name is actually used in the function name. Use _ instead." severity: error # Rx From f03660eb7992d294aa727bdd8a70f6c5b295ce4f Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 5 Jun 2020 12:38:47 +0300 Subject: [PATCH 13/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 7a89f38..e97739b 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -247,7 +247,7 @@ custom_rules: parameter_repetition: name: "Parameter repetition" - regex: 'func \w*(\w+)(<.+>)?\((?i)\1' + regex: 'func \w*([A-Z]\w+) *(<.+>)? *\( *(?i)\1' message: "The parameter name is actually used in the function name. Use _ instead." severity: error From 08481ba0d33b71d7f14671a45de55f71269e8395 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 5 Jun 2020 12:44:11 +0300 Subject: [PATCH 14/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index e97739b..5ffd1da 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -247,7 +247,7 @@ custom_rules: parameter_repetition: name: "Parameter repetition" - regex: 'func \w*([A-Z]\w+) *(<.+>)? *\( *(?i)\1' + regex: 'func ((\w+[A-Z])?\w+) *(<.+>)? *\( *(?i)\1:' message: "The parameter name is actually used in the function name. Use _ instead." severity: error From a8c20aa760aef39c55a59740e335b72555a91a8e Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 5 Jun 2020 12:48:35 +0300 Subject: [PATCH 15/30] Update rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 5ffd1da..6acd37c 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -247,7 +247,7 @@ custom_rules: parameter_repetition: name: "Parameter repetition" - regex: 'func ((\w+[A-Z])?\w+) *(<.+>)? *\( *(?i)\1:' + regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<.+>)? *\( *(?i)(\3|\4):' message: "The parameter name is actually used in the function name. Use _ instead." severity: error From 4c3aea94a227a6a5df1590086f5aa0d4ed361158 Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Fri, 5 Jun 2020 14:14:25 +0300 Subject: [PATCH 16/30] Add comments to build badge description creation --- xcode/commonFastfile | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 34bf137..ec84766 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -87,10 +87,10 @@ end private_lane :addShield do |options| buildNumber = options[:buildNumber] - buildDescription = options[:xcconfig_name] - .split(/(?=[A-Z])/) - .map { |v| v.gsub(/[[:lower:]]+/, "") }[1..2] - .join + buildDescription = options[:xcconfig_name] # EnterpriseCustomerDev1WithoutSSLPinningRelease + .split(/(?=[A-Z])/) # -> ["Enterprise", "Customer", "Dev1", "Without", "S", "S", "L", "Pinning", "Release"] + .map { |v| v.gsub(/[[:lower:]]+/, "") }[1..2] # -> ["E", "C", "D1", "W", "S", "S", "L", "P", "R"] -> ["C", "D1"] + .join # -> "CD1" begin add_badge( From 0cfb8001e8e44628a430a051fce56121826ee7d7 Mon Sep 17 00:00:00 2001 From: Vlad Date: Fri, 5 Jun 2020 15:16:38 +0300 Subject: [PATCH 17/30] Fix rule --- xcode/.swiftlint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/.swiftlint.yml b/xcode/.swiftlint.yml index 6acd37c..d502145 100644 --- a/xcode/.swiftlint.yml +++ b/xcode/.swiftlint.yml @@ -247,7 +247,7 @@ custom_rules: parameter_repetition: name: "Parameter repetition" - regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<.+>)? *\( *(?i)(\3|\4):' + regex: 'func ((\w+([A-Z]\w+))|(\w+)) *(<[^>]+>)? *\( *(?i)(\3|\4):' message: "The parameter name is actually used in the function name. Use _ instead." severity: error From 3a46d7bba835976113ea4835de7836ce76be1037 Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Fri, 5 Jun 2020 18:47:00 +0300 Subject: [PATCH 18/30] Add ability for render_configs.rb to source custom configs and automatically fetch team id --- xcode/config_generator/render_xcconfigs.rb | 46 +++++++++++++++++----- 1 file changed, 36 insertions(+), 10 deletions(-) mode change 100644 => 100755 xcode/config_generator/render_xcconfigs.rb diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb old mode 100644 new mode 100755 index 6278cbf..47f1495 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -1,25 +1,41 @@ require 'json' require 'mustache' +require 'yaml' + +# Usage: render_xcconfigs.rb +# +# Result: Adds .xcconfig files to $configs_folder_name directory. +# Files are only being added and changed, not removed! +# It is recommended to remove old .xcconfig files before running this script. + # Constants $configs_folder_name = "TargetConfigurations" -$standard_dev_team = "D4HA43V467" -$enterprise_dev_team = "228J5MMU7S" $standard_bundle_prefix = "ru.touchin." $enterprise_bundle_prefix = "com.touchin." $bundle_id_key = "PRODUCT_BUNDLE_IDENTIFIER" +class String + def in_current_dir + "#{__dir__}/#{self}" + end +end + +custom_settings_path = ARGV[0] +configurations_yaml_file = ARGV[1] +temp_configs_data_file = "configs_data.json".in_current_dir + # create config directory if needed Dir.mkdir($configs_folder_name) unless Dir.exist?($configs_folder_name) # call python script and generate configs to config file -system("python gen_configurations.py > configs_data.json") +system("python #{"gen_configurations.py".in_current_dir} > #{temp_configs_data_file}") -# open settings + template file -settings = JSON.load(File.open("custom_settings.json")) -target_xcconfig_tempate = File.read("target_xcconfig.mustache") - +# open settings, configurations and template files +settings = JSON.load(File.open(custom_settings_path)) +target_xcconfig_tempate = File.read("target_xcconfig.mustache".in_current_dir) +$configurations = YAML.load(File.open(configurations_yaml_file)) # set global property targets = settings["targets"] @@ -31,7 +47,17 @@ end # return empty array or generated dev team hash def generate_development_team(development_team_key, account_type) - team_value = account_type == "Standard" ? $standard_dev_team : $enterprise_dev_team + current_config = case account_type + when "Standard" + $configurations["development"] + when "Enterprise" + $configurations["enterprise"] + when "AppStore" + $configurations["appstore"] + else + raise "Error: Unsupported distribution type #{account_type}" + end + team_value = current_config["team_id"] return config_option(development_team_key, team_value) end @@ -99,7 +125,7 @@ end targets.each do |target| # need open everytime, because script make some changes only for this target - configs = JSON.load(File.open("configs_data.json"))["configurations"] + configs = JSON.load(File.open(temp_configs_data_file))["configurations"] # run through all configs configs.each do |config| @@ -132,4 +158,4 @@ targets.each do |target| end # remove config file, it's trash -File.delete("configs_data.json") if File.exist?("configs_data.json") +File.delete(temp_configs_data_file) if File.exist?(temp_configs_data_file) From 068fdc2105b7c700e4185eefd034e72631ac5caa Mon Sep 17 00:00:00 2001 From: alex Date: Mon, 8 Jun 2020 11:04:53 +0300 Subject: [PATCH 19/30] remove non existent rule, add LockedOrientationActivity --- lint/lint.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lint/lint.xml b/lint/lint.xml index c834f09..57a80e9 100644 --- a/lint/lint.xml +++ b/lint/lint.xml @@ -8,12 +8,13 @@ - - + + + From f7ef221e4fdc9161a636ac9e9c52d1d1ad40adc2 Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Tue, 9 Jun 2020 15:51:13 +0300 Subject: [PATCH 20/30] Unify build custom config and configurations.yaml --- xcode/config_generator/render_xcconfigs.rb | 158 +++++++++--------- xcode/fastlane/touchlane/lib/configuration.rb | 18 +- 2 files changed, 90 insertions(+), 86 deletions(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 47f1495..dd041d8 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -2,7 +2,7 @@ require 'json' require 'mustache' require 'yaml' -# Usage: render_xcconfigs.rb +# Usage: render_xcconfigs.rb # # Result: Adds .xcconfig files to $configs_folder_name directory. # Files are only being added and changed, not removed! @@ -11,9 +11,6 @@ require 'yaml' # Constants $configs_folder_name = "TargetConfigurations" -$standard_bundle_prefix = "ru.touchin." -$enterprise_bundle_prefix = "com.touchin." -$bundle_id_key = "PRODUCT_BUNDLE_IDENTIFIER" class String def in_current_dir @@ -21,135 +18,134 @@ class String end end -custom_settings_path = ARGV[0] -configurations_yaml_file = ARGV[1] -temp_configs_data_file = "configs_data.json".in_current_dir +# Input files paths +configurations_file_path = ARGV[0] +temp_configs_data_file_path = "configs_data.json".in_current_dir +generator_path = "gen_configurations.py".in_current_dir +template_path = "target_xcconfig.mustache".in_current_dir -# create config directory if needed +# Create config directory if needed Dir.mkdir($configs_folder_name) unless Dir.exist?($configs_folder_name) -# call python script and generate configs to config file -system("python #{"gen_configurations.py".in_current_dir} > #{temp_configs_data_file}") +# Call python script and generate configs to config file +system("python #{generator_path} > #{temp_configs_data_file_path}") +# Open settings, configurations and template files +target_xcconfig_tempate = File.read(template_path) +$configurations = YAML.load(File.open(configurations_file_path)) +$config_types = $configurations["types"] -# open settings, configurations and template files -settings = JSON.load(File.open(custom_settings_path)) -target_xcconfig_tempate = File.read("target_xcconfig.mustache".in_current_dir) -$configurations = YAML.load(File.open(configurations_yaml_file)) +# Set global property +targets = $configurations["targets"] -# set global property -targets = settings["targets"] - -# make tuple of key and value become mustache template element +# Make tuple of key and value become mustache template element def config_option(key, value) return { "key" => key, "value" => value } end -# return empty array or generated dev team hash -def generate_development_team(development_team_key, account_type) - current_config = case account_type - when "Standard" - $configurations["development"] - when "Enterprise" - $configurations["enterprise"] - when "AppStore" - $configurations["appstore"] - else - raise "Error: Unsupported distribution type #{account_type}" - end +# Maps lane prefix to distribution type +def distribution_type_of(account_type) + case account_type + when "Standard" + "development" + when "Enterprise" + "enterprise" + when "AppStore" + "appstore" + else + raise "Error: Unsupported distribution type #{account_type}" + end +end + +# Fetch development team from build configuration +def fetch_development_team(development_team_key, distribution_type) + current_config = $config_types[distribution_type] team_value = current_config["team_id"] return config_option(development_team_key, team_value) end -# return empty array or generated provisioning profile hash -def generate_provisioning_profile(provisioning_key, bundle_id, account_type) - if account_type == "AppStore" - app_store_profiile = "match AppStore " + bundle_id - return config_option(provisioning_key, app_store_profiile) - else - return config_option(provisioning_key, bundle_id) - end +# Return empty array or generated provisioning profile hash +def generate_provisioning_profile(provisioning_key, bundle_id, distribution_type) + case distribution_type + when "appstore" + app_store_profile = "match AppStore " + bundle_id + config_option(provisioning_key, app_store_profile) + else + config_option(provisioning_key, bundle_id) + end end -def generate_bundle_id(target_name, account_type) - bundle_id_prefix = account_type == "Standard" ? $standard_bundle_prefix : $enterprise_bundle_prefix - bundle_id = bundle_id_prefix + target_name - return config_option($bundle_id_key, bundle_id) -end - -def generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type) +def generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type) google_service_info_plist_path = target_name + "/Resources/" - if account_type == "AppStore" - google_service_info_plist_path += "AppStore-GoogleService-Info.plist" - elsif account_type == "Enterprise" - google_service_info_plist_path += "Enterprise-GoogleService-Info.plist" - else - google_service_info_plist_path += "Standard-GoogleService-Info.plist" - end + path_suffix = case distribution_type + when "development" + "Standard-GoogleService-Info.plist" + when "enterprise" + "Enterprise-GoogleService-Info.plist" + else + "AppStore-GoogleService-Info.plist" + end - return config_option(google_service_info_plist_key, google_service_info_plist_path) + return config_option(google_service_info_plist_key, google_service_info_plist_path + path_suffix) end -# generate missing properties if needed -def generate_missing_properties(target_name, properties, account_type) +# Generate missing properties if needed +def generate_missing_properties(target_name, properties, distribution_type) result = [] development_team_key = "DEVELOPMENT_TEAM" provisioning_key = "PROVISIONING_PROFILE_SPECIFIER" google_service_info_plist_key = "GOOGLE_SERVICE_INFO_PLIST_PATH" + bundle_id_key = "PRODUCT_BUNDLE_IDENTIFIER" - unless properties.key?($bundle_id_key) - bundle_id_config = generate_bundle_id(target_name, account_type) - bundle_id = bundle_id_config["value"] - result.append(bundle_id_config) - else - bundle_id = properties[$bundle_id_key] + # Bundle_id_key should be among the properties (required by fastlane) + unless properties.key?(bundle_id_key) + raise "#{target_name}: Could not find #{bundle_id_key} for #{distribution_type}" end unless properties.key?(development_team_key) - result.append(generate_development_team(development_team_key, account_type)) + result.append(fetch_development_team(development_team_key, distribution_type)) end unless properties.key?(provisioning_key) - result.append(generate_provisioning_profile(provisioning_key, bundle_id, account_type)) + result.append(generate_provisioning_profile(provisioning_key, bundle_id, distribution_type)) end unless properties.key?(google_service_info_plist_key) - result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, account_type)) + result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type)) end return result end -# run through all target in project -targets.each do |target| +# Run through all target in project +targets.each do |target_name, target| - # need open everytime, because script make some changes only for this target - configs = JSON.load(File.open(temp_configs_data_file))["configurations"] + # Need open everytime, because script make some changes only for this target + configs = JSON.load(File.open(temp_configs_data_file_path))["configurations"] - # run through all configs + # Run through all configs configs.each do |config| + + # Take default values + distribution_type = distribution_type_of(config["account_type"]) + properties = target[distribution_type] - # take default values - account_type = config["account_type"] - target_name = target.keys.first - properties = target[target_name][account_type] - - # add properties from settings file + # Add properties from settings file properties.each do |key, value| config["xcconfig_options"].append(config_option(key, value)) end - # add missing properties if needed - config["xcconfig_options"].concat(generate_missing_properties(target_name, properties, account_type)) + # Add missing properties if needed + config["xcconfig_options"].concat(generate_missing_properties(target_name, properties, distribution_type)) - # create settings pack + # Create settings pack config_data = { "target_name": target_name, "configuration": config } - # create file for every setting in loop + # Create file for every setting in loop File.open($configs_folder_name + "/" + target_name + config["name"] + ".xcconfig", 'w') { |file| file.puts(Mustache.render(target_xcconfig_tempate, config_data)) } @@ -157,5 +153,5 @@ targets.each do |target| end -# remove config file, it's trash -File.delete(temp_configs_data_file) if File.exist?(temp_configs_data_file) +# Remove config file, it's trash +File.delete(temp_configs_data_file_path) if File.exist?(temp_configs_data_file_path) diff --git a/xcode/fastlane/touchlane/lib/configuration.rb b/xcode/fastlane/touchlane/lib/configuration.rb index a12c764..02cc4d3 100644 --- a/xcode/fastlane/touchlane/lib/configuration.rb +++ b/xcode/fastlane/touchlane/lib/configuration.rb @@ -13,18 +13,19 @@ module Touchlane attr_reader :type, :app_identifier, :apple_id, :team_id, :itc_team_id def self.from_file(path, type) - hash_of_types = load_hash_of_types_from_file(path) - attrs_hash = hash_of_types[type] + configuration_hash = load_configuration_from_file(path) + attrs_hash = configuration_hash["types"][type] + identifiers = get_app_identifiers_from_configuration_hash(configuration_hash, type) unless attrs_hash raise "There is no configuration with type #{type}. Available types: #{attrs_hash.keys}" else config_type = Touchlane::ConfigurationType.from_type(type) - new(config_type, attrs_hash["app_identifier"], attrs_hash["apple_id"], attrs_hash["team_id"], attrs_hash["itc_team_id"]) + new(config_type, identifiers, attrs_hash["apple_id"], attrs_hash["team_id"], attrs_hash["itc_team_id"]) end end - def self.load_hash_of_types_from_file(path) + def self.load_configuration_from_file(path) unless File.exists? path raise "Unable to load configurations from file at #{path}" else @@ -32,7 +33,14 @@ module Touchlane end end - private_class_method :new, :load_hash_of_types_from_file + def self.get_app_identifiers_from_configuration_hash(configuration_hash, type) + identifier_key = "PRODUCT_BUNDLE_IDENTIFIER" + configuration_hash["targets"].collect do |target, types| + types[type][identifier_key] or raise "#{target}: There is no #{identifier_key} field in #{type}" + end + end + + private_class_method :new, :load_configuration_from_file, :get_app_identifiers_from_configuration_hash def to_options { From ad099aa9c9c8aef47121213e3cea063531242aa9 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Thu, 11 Jun 2020 10:49:12 +0300 Subject: [PATCH 21/30] remove private lane syncCodeSigning, use public SyncCodeSigning instead --- xcode/commonFastfile | 54 ++++++++++++++++++++++++++------------------ 1 file changed, 32 insertions(+), 22 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index ec84766..673a17b 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -111,11 +111,7 @@ private_lane :buildConfiguration do |options| options[:xcconfig_name] = lane_name configuration_type = Touchlane::ConfigurationType.from_lane_name(lane_name) - configuration = get_configuration_for_type(configuration_type.type) - - options = configuration.to_options - .merge(get_keychain_options(options)) - .merge(options) + options = fill_up_options_using_configuration_type(options, configuration_type) openKeychain(options) @@ -209,23 +205,11 @@ lane :createPushCertificate do |options| ) end -lane :syncCodeSigning do |options| - match( - app_identifier: options[:app_identifier], - username: options[:username] || options[:apple_id], - team_id: options[:team_id], - type: options[:type], - readonly: options[:readonly].nil? ? true : options[:readonly], - storage_mode: "git", - git_url: options[:git_url], - git_branch: "fastlane_certificates", - shallow_clone: true, - clone_branch_directly: true, - keychain_name: options[:keychain_name], - keychain_password: options[:keychain_password], - skip_docs: true, - platform: "ios" - ) +lane :SyncCodeSigning do |options| + configuration_type = Touchlane::ConfigurationType.from_type(options[:type]) + options = fill_up_options_using_configuration_type(options, configuration_type) + + sync_code_signing_using_options(options) end lane :SyncSymbols do |options| @@ -349,6 +333,32 @@ lane :ManuallyUpdateCodeSigning do |options| end +def sync_code_signing_using_options(options) + match( + app_identifier: options[:app_identifier], + username: options[:username] || options[:apple_id], + team_id: options[:team_id], + type: options[:type], + readonly: options[:readonly].nil? ? true : options[:readonly], + storage_mode: "git", + git_url: options[:git_url], + git_branch: "fastlane_certificates", + shallow_clone: true, + clone_branch_directly: true, + keychain_name: options[:keychain_name], + keychain_password: options[:keychain_password], + skip_docs: true, + platform: "ios" + ) +end + +def fill_up_options_using_configuration_type(options, configuration_type) + configuration = get_configuration_for_type(configuration_type.type) + + configuration.to_options + .merge(get_keychain_options(options)) + .merge(options) +end def get_keychain_options(options) keychain_name = options[:keychain_name] From b45ac60a2a593e5e951c8978d8b504752edff693 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Thu, 11 Jun 2020 16:44:14 +0300 Subject: [PATCH 22/30] add configs generation based on build options --- .../build_options_helper/.gitignore | 129 +++++++++++ .../build_options_helper/LICENSE | 201 ++++++++++++++++++ .../build_options_helper/README.md | 2 + .../build_options_helper/argument_parser.py | 25 +++ .../build_options_helper/core/__init__.py | 3 + .../core/models/__init__.py | 9 + .../core/models/build_parameters.py | 27 +++ .../core/models/parameter.py | 25 +++ .../core/models/parameters_set.py | 77 +++++++ .../core/models/restriction.py | 24 +++ .../core/models/selector.py | 23 ++ .../build_options_helper/helper.py | 51 +++++ .../ios_build_settings_renderer/__init__.py | 6 + .../ios_build_settings_renderer/models.py | 120 +++++++++++ .../ios_build_settings_renderer/raw_models.py | 17 ++ .../xcconfigs_renderer.py | 19 ++ .../build_options_helper/requirements.pip | 1 + .../test_data/build_parameters.yaml | 97 +++++++++ .../web_parameters_renderer/__init__.py | 6 + .../web_parameters_renderer/models.py | 13 ++ .../parameter_renderer.py | 20 ++ .../web_parameters_renderer/raw_models.py | 12 ++ xcode/config_generator/custom_settings.json | 25 --- xcode/config_generator/example_settings.yaml | 27 +++ xcode/config_generator/gen_configurations.py | 94 -------- xcode/config_generator/render_xcconfigs.rb | 21 +- 26 files changed, 945 insertions(+), 129 deletions(-) create mode 100644 xcode/config_generator/build_options_helper/.gitignore create mode 100644 xcode/config_generator/build_options_helper/LICENSE create mode 100644 xcode/config_generator/build_options_helper/README.md create mode 100644 xcode/config_generator/build_options_helper/argument_parser.py create mode 100644 xcode/config_generator/build_options_helper/core/__init__.py create mode 100644 xcode/config_generator/build_options_helper/core/models/__init__.py create mode 100644 xcode/config_generator/build_options_helper/core/models/build_parameters.py create mode 100644 xcode/config_generator/build_options_helper/core/models/parameter.py create mode 100644 xcode/config_generator/build_options_helper/core/models/parameters_set.py create mode 100644 xcode/config_generator/build_options_helper/core/models/restriction.py create mode 100644 xcode/config_generator/build_options_helper/core/models/selector.py create mode 100755 xcode/config_generator/build_options_helper/helper.py create mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py create mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py create mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py create mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py create mode 100644 xcode/config_generator/build_options_helper/requirements.pip create mode 100644 xcode/config_generator/build_options_helper/test_data/build_parameters.yaml create mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py create mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/models.py create mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py create mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py delete mode 100644 xcode/config_generator/custom_settings.json create mode 100644 xcode/config_generator/example_settings.yaml delete mode 100644 xcode/config_generator/gen_configurations.py diff --git a/xcode/config_generator/build_options_helper/.gitignore b/xcode/config_generator/build_options_helper/.gitignore new file mode 100644 index 0000000..b6e4761 --- /dev/null +++ b/xcode/config_generator/build_options_helper/.gitignore @@ -0,0 +1,129 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ diff --git a/xcode/config_generator/build_options_helper/LICENSE b/xcode/config_generator/build_options_helper/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/xcode/config_generator/build_options_helper/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/xcode/config_generator/build_options_helper/README.md b/xcode/config_generator/build_options_helper/README.md new file mode 100644 index 0000000..78a5670 --- /dev/null +++ b/xcode/config_generator/build_options_helper/README.md @@ -0,0 +1,2 @@ +# build_options_helper +An utility to work with build options diff --git a/xcode/config_generator/build_options_helper/argument_parser.py b/xcode/config_generator/build_options_helper/argument_parser.py new file mode 100644 index 0000000..d56499f --- /dev/null +++ b/xcode/config_generator/build_options_helper/argument_parser.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +import argparse +import os +import tempfile + +class writeable_dir(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + prospective_dir = values + + if not os.path.isdir(prospective_dir): + raise argparse.ArgumentTypeError("writeable_dir:{0} is not a valid path".format(prospective_dir)) + if os.access(prospective_dir, os.W_OK): + setattr(namespace, self.dest, prospective_dir) + else: + raise argparse.ArgumentTypeError("writeable_dir:{0} is not a writeable dir".format(prospective_dir)) + +class ArgumentParser(argparse.ArgumentParser): + def configure(self): + self.add_argument('--build-parameters-path', '-bp', default="build_parameters.yaml", type=open, required=True) + self.add_argument('--output-folder', '-o', action=writeable_dir, default=tempfile.mkdtemp(), required=True) + self.add_argument('--render', '-r', choices=['ios_build_settings', 'team_city_web_parameters'], type=str, required=True) + self.add_argument('--platform', '-p', choices=['ios', 'android'], type=str, required=True) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/__init__.py b/xcode/config_generator/build_options_helper/core/__init__.py new file mode 100644 index 0000000..85f54f0 --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/__init__.py @@ -0,0 +1,3 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/__init__.py b/xcode/config_generator/build_options_helper/core/models/__init__.py new file mode 100644 index 0000000..28ba362 --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/__init__.py @@ -0,0 +1,9 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from .selector import Selector +from .restriction import Restriction +from .parameter import Parameter +from .build_parameters import BuildParameters +from .parameters_set import ParametersSet diff --git a/xcode/config_generator/build_options_helper/core/models/build_parameters.py b/xcode/config_generator/build_options_helper/core/models/build_parameters.py new file mode 100644 index 0000000..128ee8f --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/build_parameters.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +from .restriction import Restriction +from .parameter import Parameter + +BuildParametersTuple = namedtuple('BuildParametersTuple', [ + 'all_parameters', + 'project_restrictions', + 'ci_parameters', + 'ios_parameters', + 'android_parameters', +]) + +class BuildParameters(BuildParametersTuple): + @staticmethod + def from_dict(dict_obj): + return BuildParameters( + all_parameters=list(map(Parameter.from_dict, dict_obj["all_parameters"])), + project_restrictions=list(map(Restriction.from_dict, dict_obj["project_restrictions"])), + ci_parameters=list(map(Parameter.from_dict, dict_obj["ci_parameters"])), + ios_parameters=list(map(Parameter.from_dict, dict_obj["ios_parameters"])), + android_parameters=list(map(Parameter.from_dict, dict_obj["android_parameters"])) + ) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/parameter.py b/xcode/config_generator/build_options_helper/core/models/parameter.py new file mode 100644 index 0000000..38e780d --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/parameter.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +from .selector import Selector + +ParameterTuple = namedtuple('ParameterTuple', [ + 'key', + 'values', + 'default_value', +]) + +class Parameter(ParameterTuple): + @staticmethod + def from_dict(dict_obj): + return Parameter( + key=dict_obj["key"], + values=dict_obj["values"], + default_value=dict_obj.get("default_value") + ) + + def values_selectors(self): + return [Selector(key=self.key, value=value) for value in self.values] \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/parameters_set.py b/xcode/config_generator/build_options_helper/core/models/parameters_set.py new file mode 100644 index 0000000..034023d --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/parameters_set.py @@ -0,0 +1,77 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +from .selector import Selector + +ParametersSetTuple = namedtuple('ParametersSetTuple', [ + 'active_parameters', +]) + +class ParametersSet(ParametersSetTuple): + def filter_using_restrictions_and_selectors(self, restrictions, selectors): + new_parameters = ParametersSet.__filter_parameters_using_restrictions_and_selectors(self.active_parameters, restrictions, selectors) + + return ParametersSet(active_parameters=new_parameters) + + def update_parameters(self, parameters): + parameters_dict = { p.key : p for p in parameters } + parameters_dict_keys = parameters_dict.keys() + + # update & keep ordering + new_active_parameters = [parameters_dict[p.key] if p.key in parameters_dict_keys else p for p in self.active_parameters] + + return ParametersSet(active_parameters=new_active_parameters) + + @staticmethod + def __filter_parameters_using_restrictions_and_selectors(parameters, restrictions, selectors): + active_restrictions = filter(lambda r: r.is_active_for_selectors(selectors), restrictions) + + parameters_keys = list(map(lambda p: p.key, parameters)) + + parameters_from_restrictions = { parameter.key : parameter for restriction in active_restrictions for parameter in restriction.set if parameter.key in parameters_keys } + + # replace with restriction parameters and keep original ordering + return [parameters_from_restrictions.get(p.key, p) for p in parameters] + + @staticmethod + def __difference_for_parameters(parameters, active_parameters): + parameters_keys = list(map(lambda p: p.key, parameters)) + + return list(filter(lambda p: p.key not in parameters_keys, active_parameters)) + + def as_selectors(self, project_restrictions): + non_empty_active_parameters = list(filter(lambda p: len(p.values) > 0, self.active_parameters)) + + if len(non_empty_active_parameters) > 0: + return list(ParametersSet.__as_selectors_recursive([], non_empty_active_parameters[0], non_empty_active_parameters[1:], non_empty_active_parameters, project_restrictions)) + else: + return [] + + @staticmethod + def __as_selectors_recursive(head_selectors, current_parameter, tail_parameters, all_parameters, project_restrictions): + if len(tail_parameters) == 0: + for parameter_value in current_parameter.values: + current_selector = Selector(key=current_parameter.key, value=parameter_value) + new_head_selectors = head_selectors + [current_selector] + + all_parameters_filtered = ParametersSet.__filter_parameters_using_restrictions_and_selectors(all_parameters, project_restrictions, new_head_selectors) + + parameters_selectors = { selector for parameter in all_parameters_filtered for selector in parameter.values_selectors() } + + if set(new_head_selectors).issubset(parameters_selectors): + yield new_head_selectors + + return + + for current_parameter_value in current_parameter.values: + current_selector = Selector(key=current_parameter.key, value=current_parameter_value) + new_head_selectors = head_selectors + [current_selector] + + new_tail_parameters = ParametersSet.__filter_parameters_using_restrictions_and_selectors(tail_parameters[1:], project_restrictions, new_head_selectors) + + for selectors in ParametersSet.__as_selectors_recursive(new_head_selectors, tail_parameters[0], new_tail_parameters, all_parameters, project_restrictions): + yield selectors + diff --git a/xcode/config_generator/build_options_helper/core/models/restriction.py b/xcode/config_generator/build_options_helper/core/models/restriction.py new file mode 100644 index 0000000..b0f12de --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/restriction.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +from .selector import Selector +from .parameter import Parameter + +RestrictionTuple = namedtuple('RestrictionTuple', [ + 'when', + 'set', +]) + +class Restriction(RestrictionTuple): + @staticmethod + def from_dict(dict_obj): + return Restriction( + when=frozenset(map(Selector.from_dict, dict_obj["when"])), + set=list(map(Parameter.from_dict, dict_obj["set"])), + ) + + def is_active_for_selectors(self, selectors): + return not frozenset(selectors).isdisjoint(self.when) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/selector.py b/xcode/config_generator/build_options_helper/core/models/selector.py new file mode 100644 index 0000000..fcf5a8f --- /dev/null +++ b/xcode/config_generator/build_options_helper/core/models/selector.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +SelectorTuple = namedtuple('SelectorTuple', [ + 'key', + 'value', +]) + +class Selector(SelectorTuple): + @staticmethod + def from_dict(dict_obj): + return Selector(**dict_obj) + + def __eq__(self, obj): + return isinstance(obj, Selector) and \ + obj.key == self.key and \ + obj.value == self.value + + def __hash__(self): + return hash((self.key, self.value)) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/helper.py b/xcode/config_generator/build_options_helper/helper.py new file mode 100755 index 0000000..f33b1c9 --- /dev/null +++ b/xcode/config_generator/build_options_helper/helper.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from argument_parser import ArgumentParser + +import yaml + +from web_parameters_renderer import ParameterRenderer, Option +from ios_build_settings_renderer import XCConfigsRenderer, XCConfig + +from core.models import BuildParameters, ParametersSet + +import os + +parser = ArgumentParser() +parser.configure() + +args = parser.parse_args() + +output_folder = os.path.abspath(os.path.expanduser(args.output_folder)) + +build_parameters = BuildParameters.from_dict(yaml.safe_load(args.build_parameters_path)) + +parameters_set = ParametersSet(active_parameters=build_parameters.all_parameters) + +if args.platform == 'ios': + parameters_set = parameters_set.update_parameters(build_parameters.ios_parameters) +elif args.platform == 'android': + parameters_set = parameters_set.update_parameters(build_parameters.android_parameters) +else: + raise ValueError("Unknown platform {}".format(args.platform)) + +if args.render == "ios_build_settings": + xcconfigs = map(XCConfig.from_selectors, parameters_set.as_selectors(build_parameters.project_restrictions)) + XCConfigsRenderer("configs_data", xcconfigs).render_json_to_file_in_dir(output_folder) +elif args.render == "team_city_web_parameters": + parameters_set = parameters_set.update_parameters(build_parameters.ci_parameters) + active_parameters = parameters_set.active_parameters + + options_from_parameter = lambda p: [Option(key=value, value=value, enabled=True, default=p.default_value == value) for value in p.values] + + renderers = [ParameterRenderer(parameter.key, options_from_parameter(parameter)) for parameter in active_parameters] + + for r in renderers: + r.render_json_to_file_in_dir(output_folder) +else: + raise ValueError("Unknown render command {}".format(args.render)) + +print("Perameters renderer to {}".format(output_folder)) diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py new file mode 100644 index 0000000..b5faf44 --- /dev/null +++ b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from .xcconfigs_renderer import XCConfigsRenderer +from .models import XCConfig \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py new file mode 100644 index 0000000..62a5451 --- /dev/null +++ b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py @@ -0,0 +1,120 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from .raw_models import * +from core.models import Selector + +class XCConfig(XCConfigTuple): + + DISTIBUTION_TYPE_KEY = "DISTRIBUTION_TYPE" + BUILD_TYPE_KEY = "BUILD_TYPE" + + @staticmethod + def from_selectors(selectors): + selectors_dict = XCConfig.__make_dict_from_selectors(selectors) + + distibution_type_value = selectors_dict.get(XCConfig.DISTIBUTION_TYPE_KEY, None) + + is_app_store_config = distibution_type_value.lower() == "AppStore".lower() + build_type_value = selectors_dict.get(XCConfig.BUILD_TYPE_KEY, None) + build_type = distibution_type_value.lower() if is_app_store_config else build_type_value.lower() + + compatability_selectors = map(XCConfig.__modify_selector_if_needed, selectors) + + return XCConfig( + name="".join(map(lambda s: s.value, compatability_selectors)), + account_type=distibution_type_value, + build_type=build_type, + xcconfig_options=map(lambda f: f(selectors_dict), [ + XCConfigOption.swift_active_compilation_conditions, + XCConfigOption.debug_information_format, + XCConfigOption.validate_product, + XCConfigOption.enable_testability, + XCConfigOption.code_sign_identity, + XCConfigOption.gcc_optimization_level, + XCConfigOption.swift_optimization_level, + XCConfigOption.swift_compilation_mode + ]) + ) + + @staticmethod + def __make_dict_from_selectors(selectors): + # compatibility mode + return { s.key : (XCConfig.__account_type_from_distribution_type(s.value) if s.key == XCConfig.DISTIBUTION_TYPE_KEY else s.value) for s in selectors } + + # normal mode + # return { s.key : s.value for s in selectors } + + @staticmethod + def __modify_selector_if_needed(selector): + # compatibility mode + if selector.key == XCConfig.DISTIBUTION_TYPE_KEY: + return Selector(key=selector.key, value=XCConfig.__account_type_from_distribution_type(selector.value)) + else: + return selector + + # normal mode + # return selector + + @staticmethod + def __account_type_from_distribution_type(distibution_type): + if distibution_type == "Local": + return "Standard" + elif distibution_type == "Firebase": + return "Enterprise" + elif distibution_type == "Store": + return "AppStore" + + def _asdict(self): + return { + 'name': self.name, + 'account_type': self.account_type, + 'build_type': self.build_type, + 'xcconfig_options': [o._asdict() for o in self.xcconfig_options] + } + + +class XCConfigOption(XCConfigOptionTuple): + @staticmethod + def swift_active_compilation_conditions(selectors_dict): + return XCConfigOption( + key="SWIFT_ACTIVE_COMPILATION_CONDITIONS", + value=" ".join(map(lambda sv: sv.upper(), selectors_dict.values())) + ) + + @staticmethod + def debug_information_format(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("DEBUG_INFORMATION_FORMAT", "dwarf", "dwarf-with-dsym", selectors_dict) + + @staticmethod + def validate_product(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("VALIDATE_PRODUCT", "NO", "YES", selectors_dict) + + @staticmethod + def enable_testability(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("ENABLE_TESTABILITY", "YES", "NO", selectors_dict) + + @staticmethod + def code_sign_identity(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("CODE_SIGN_IDENTITY", "iPhone Developer", "iPhone Distribution", selectors_dict, "Standard") + + @staticmethod + def gcc_optimization_level(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("GCC_OPTIMIZATION_LEVEL", "0", "s", selectors_dict) + + @staticmethod + def swift_optimization_level(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("SWIFT_OPTIMIZATION_LEVEL", "-Onone", "-O", selectors_dict) + + @staticmethod + def swift_compilation_mode(selectors_dict): + return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("SWIFT_COMPILATION_MODE", "singlefile", "wholemodule", selectors_dict) + + @staticmethod + def __from_key_and_value_based_on_value_in_selectors(key, value_if_contains, otherwise_value, + selectors_dict, expected_value="Debug"): + return XCConfigOption( + key=key, + value=value_if_contains if expected_value.upper() in map(lambda sv: sv.upper(), selectors_dict.values()) else otherwise_value + ) diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py new file mode 100644 index 0000000..fe922f2 --- /dev/null +++ b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py @@ -0,0 +1,17 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +XCConfigOptionTuple = namedtuple('XCConfigOptionTuple', [ + 'key', + 'value' +]) + +XCConfigTuple = namedtuple('XCConfigTuple', [ + 'name', + 'account_type', + 'build_type', + 'xcconfig_options' +]) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py new file mode 100644 index 0000000..28c4927 --- /dev/null +++ b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +import json +import os + +class XCConfigsRenderer: + def __init__(self, name, xcconfigs): + self.name = name + self.xcconfig_dicts = [xcconfig._asdict() for xcconfig in xcconfigs] + + def render_to_json(self): + return json.dumps(self.xcconfig_dicts, indent=4) + + def render_json_to_file_in_dir(self, dir_path): + file_name = "{}.json".format(self.name) + file_path = os.path.join(dir_path, file_name) + return json.dump(self.xcconfig_dicts, open(file_path, 'w'), indent=4) diff --git a/xcode/config_generator/build_options_helper/requirements.pip b/xcode/config_generator/build_options_helper/requirements.pip new file mode 100644 index 0000000..dbfc709 --- /dev/null +++ b/xcode/config_generator/build_options_helper/requirements.pip @@ -0,0 +1 @@ +PyYAML \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml b/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml new file mode 100644 index 0000000..013d09a --- /dev/null +++ b/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml @@ -0,0 +1,97 @@ +all_parameters: + - key: DISTRIBUTION_TYPE + values: [Firebase, Store, Local] + default_value: Firebase + + - key: OBFUSCATE + values: [Obfuscate, NoObfuscate] + default_value: Obfuscate + + - key: SERVER_TYPE + values: [Mock, Touchin, Customer] + default_value: Mock + + - key: SERVER_ENVIRONMENT + values: [Dev, Test, Stage, Prod] + default_value: Test + + - key: SSL_PINNING + values: [WithSSLPinning, WithoutSSLPinning] + default_value: WithoutSSLPinning + + - key: TEST_PANEL + values: [WithTestPanel, WithoutTestPanel] + default_value: WithoutTestPanel + + - key: BUILD_TYPE + values: [Debug, Release] + default_value: Release + +project_restrictions: + # Mock -> Dev|Stage + - when: + - key: SERVER_TYPE + value: Mock + set: + - key: SERVER_ENVIRONMENT + values: [Dev, Stage] + default_value: Dev + + # Touchin -> Dev|Test|Stage + - when: + - key: SERVER_TYPE + value: Touchin + set: + - key: SERVER_ENVIRONMENT + values: [Dev, Test, Stage] + default_value: Test + + # Customer -> Prod + - when: + - key: SERVER_TYPE + value: Customer + set: + - key: SERVER_ENVIRONMENT + values: [Prod] + + # Store -> ObfuscateWithSSLPinningWithoutTestPanelReleaseCustomerProd + - when: + - key: DISTRIBUTION_TYPE + value: Store + set: + - key: OBFUSCATE + values: [Obfuscate] + - key: SSL_PINNING + values: [WithSSLPinning] + - key: TEST_PANEL + values: [WithoutTestPanel] + - key: BUILD_TYPE + values: [Release] + - key: SERVER_TYPE + values: [Customer] + - key: SERVER_ENVIRONMENT + values: [Prod] + + # Firebase -> Release + - when: + - key: DISTRIBUTION_TYPE + value: Firebase + set: + - key: BUILD_TYPE + values: [Release] + +ci_parameters: + - key: DISTRIBUTION_TYPE + values: [Firebase, Store] + default_value: Firebase + +ios_parameters: + # Not available + - key: OBFUSCATE + values: [] + + # Not available + - key: TEST_PANEL + values: [] + +android_parameters: [] diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py new file mode 100644 index 0000000..e449d47 --- /dev/null +++ b/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from .parameter_renderer import ParameterRenderer +from .models import Option \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py new file mode 100644 index 0000000..0ad3103 --- /dev/null +++ b/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py @@ -0,0 +1,13 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from .raw_models import * + +class Option(OptionTuple): + def _asdict(self): + original_dict = super(Option, self)._asdict() + # remove records with None values + return {k: v for k, v in original_dict.items() if v is not None} + + diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py new file mode 100644 index 0000000..189e38f --- /dev/null +++ b/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +import json +import os + +class ParameterRenderer: + def __init__(self, name, options): + self.name = name + self.options_dict = {"options": [option._asdict() for option in options]} + + def render_to_json(self): + return json.dumps(self.options_dict, indent=4) + + def render_json_to_file_in_dir(self, dir_path): + file_name = "{}.json".format(self.name) + file_path = os.path.join(dir_path, file_name) + return json.dump(self.options_dict, open(file_path, 'w'), indent=4) + diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py new file mode 100644 index 0000000..3d973cb --- /dev/null +++ b/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py @@ -0,0 +1,12 @@ +# -*- coding: utf-8 -*- + +from __future__ import unicode_literals # python 2/3 support + +from collections import namedtuple + +OptionTuple = namedtuple('OptionTuple', [ + 'key', + 'value', + 'enabled', + 'default' +]) \ No newline at end of file diff --git a/xcode/config_generator/custom_settings.json b/xcode/config_generator/custom_settings.json deleted file mode 100644 index a190324..0000000 --- a/xcode/config_generator/custom_settings.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "targets": [ - { - "YOUR_TARGET_NAME": { - "Standard": { - "PROVISIONING_PROFILE_SPECIFIER": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - }, - - "Enterprise": { - "PROVISIONING_PROFILE_SPECIFIER": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - }, - - "AppStore": { - "DEVELOPMENT_TEAM": "", - "PRODUCT_BUNDLE_IDENTIFIER": "", - "CODE_SIGN_ENTITLEMENTS": "" - } - } - } - ] -} diff --git a/xcode/config_generator/example_settings.yaml b/xcode/config_generator/example_settings.yaml new file mode 100644 index 0000000..608981a --- /dev/null +++ b/xcode/config_generator/example_settings.yaml @@ -0,0 +1,27 @@ +targets: + TestProject: + development: + PRODUCT_BUNDLE_IDENTIFIER: "ru.touchin.testproject" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectDev" + CODE_SIGN_ENTITLEMENTS: "TestProject/Standard.entitlements" + enterprise: + PRODUCT_BUNDLE_IDENTIFIER: "com.touchin.testproject" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectEnterprise" + CODE_SIGN_ENTITLEMENTS: "TestProject/Enterprise.entitlements" + appstore: + PRODUCT_BUNDLE_IDENTIFIER: "ru.customer.domain" + PROVISIONING_PROFILE_SPECIFIER: "TestProjectAppStore" + CODE_SIGN_ENTITLEMENTS: "TestProject/Production.entitlements" + +types: + development: + apple_id: "apple@touchin.ru" + team_id: "**********" + itc_team_id: "**********" + enterprise: + apple_id: "enterpriseapple@touchin.ru" + team_id: "**********" + appstore: + apple_id: "apple@touchin.ru" + team_id: "**********" + itc_team_id: "**********" \ No newline at end of file diff --git a/xcode/config_generator/gen_configurations.py b/xcode/config_generator/gen_configurations.py deleted file mode 100644 index 22845ed..0000000 --- a/xcode/config_generator/gen_configurations.py +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from itertools import chain -import json - -distribution_options = ["Enterprise", "Standard"] -server_type_options = ["Mock", "Touchin", "Customer"] -server_environment_options = ["Dev", "Test", "Stage", "Prod"] -ssl_pinning_options = ["WithSSLPinning", "WithoutSSLPinning"] -build_type_options = ["Debug", "Release"] - -all_options = [ - distribution_options, - server_type_options, - server_environment_options, - ssl_pinning_options, - build_type_options -] - -def combine_string_with_options(all_options, string="", applied_options=[]): - if len(all_options) == 0: - yield string, applied_options - return - - for current_option in chain.from_iterable(all_options[:1]): - for result_tuple in combine_string_with_options(all_options[1:], string + current_option, applied_options + [current_option]): - yield result_tuple - - yield ("AppStoreRelease", ['AppStore', 'Customer', 'Prod', 'WithSSLPinning', 'Release']) - -def make_config_dict(args): - config_name, applied_options = args - - if "Enterprise" in applied_options: - account_type = "Enterprise" - elif "Standard" in applied_options: - account_type = "Standard" - else: - account_type = "AppStore" - - if "Debug" in applied_options: - build_type = "debug" - elif "AppStore" in applied_options: - build_type = "appstore" - else: - build_type = "release" - - return { - "name": config_name, - "build_type": build_type, - "account_type": account_type, - "xcconfig_options": [ - { - "key": "SWIFT_ACTIVE_COMPILATION_CONDITIONS", - "value": " ".join(map(lambda option: option.upper(), applied_options)) - }, - { - "key": "DEBUG_INFORMATION_FORMAT", - "value": "dwarf" if "Debug" in applied_options else "dwarf-with-dsym" - }, - { - "key": "VALIDATE_PRODUCT", - "value": "NO" if "Debug" in applied_options else "YES" - }, - { - "key": "ENABLE_TESTABILITY", - "value": "YES" if "Debug" in applied_options else "NO" - }, - { - "key": "CODE_SIGN_IDENTITY", - "value": "iPhone Developer" if account_type == "Standard" else "iPhone Distribution" - }, - { - "key": "GCC_OPTIMIZATION_LEVEL", - "value": "0" if "Debug" in applied_options else "s" - }, - { - "key": "SWIFT_OPTIMIZATION_LEVEL", - "value": "-Onone" if "Debug" in applied_options else "-O" - }, - { - "key": "SWIFT_COMPILATION_MODE", - "value": "singlefile" if "Debug" in applied_options else "wholemodule" - } - ] - } - - -config_dicts = map(make_config_dict, combine_string_with_options(all_options)) - -print(json.dumps({"configurations": config_dicts}, indent=4)) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index dd041d8..197c382 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -4,7 +4,7 @@ require 'yaml' # Usage: render_xcconfigs.rb # -# Result: Adds .xcconfig files to $configs_folder_name directory. +# Result: Adds .xcconfig files to $configs_folder_name directory. # Files are only being added and changed, not removed! # It is recommended to remove old .xcconfig files before running this script. @@ -21,14 +21,15 @@ end # Input files paths configurations_file_path = ARGV[0] temp_configs_data_file_path = "configs_data.json".in_current_dir -generator_path = "gen_configurations.py".in_current_dir +generator_path = "build_options_helper/helper.py".in_current_dir template_path = "target_xcconfig.mustache".in_current_dir +build_parameters_path = ARGV[1] || "build_parameters.yaml".in_current_dir # Create config directory if needed Dir.mkdir($configs_folder_name) unless Dir.exist?($configs_folder_name) # Call python script and generate configs to config file -system("python #{generator_path} > #{temp_configs_data_file_path}") +system("python #{generator_path} -bp #{build_parameters_path} -o . -r ios_build_settings -p ios") # Open settings, configurations and template files target_xcconfig_tempate = File.read(template_path) @@ -53,7 +54,7 @@ def distribution_type_of(account_type) when "AppStore" "appstore" else - raise "Error: Unsupported distribution type #{account_type}" + raise "Error: Unsupported distribution type #{account_type}" end end @@ -77,16 +78,16 @@ end def generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type) google_service_info_plist_path = target_name + "/Resources/" - + path_suffix = case distribution_type when "development" "Standard-GoogleService-Info.plist" when "enterprise" "Enterprise-GoogleService-Info.plist" - else + else "AppStore-GoogleService-Info.plist" end - + return config_option(google_service_info_plist_key, google_service_info_plist_path + path_suffix) end @@ -110,7 +111,7 @@ def generate_missing_properties(target_name, properties, distribution_type) unless properties.key?(provisioning_key) result.append(generate_provisioning_profile(provisioning_key, bundle_id, distribution_type)) end - + unless properties.key?(google_service_info_plist_key) result.append(generate_google_service_info_plist_path(google_service_info_plist_key, target_name, distribution_type)) end @@ -122,11 +123,11 @@ end targets.each do |target_name, target| # Need open everytime, because script make some changes only for this target - configs = JSON.load(File.open(temp_configs_data_file_path))["configurations"] + configs = JSON.load(File.open(temp_configs_data_file_path)) # Run through all configs configs.each do |config| - + # Take default values distribution_type = distribution_type_of(config["account_type"]) properties = target[distribution_type] From 8711d20e721618ad1a76305d8c5896b5eddced33 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Mon, 15 Jun 2020 13:05:06 +0300 Subject: [PATCH 23/30] Replace build_options_helper with submodule --- .gitmodules | 3 + xcode/config_generator/build_options_helper | 1 + .../build_options_helper/.gitignore | 129 ----------- .../build_options_helper/LICENSE | 201 ------------------ .../build_options_helper/README.md | 2 - .../build_options_helper/argument_parser.py | 25 --- .../build_options_helper/core/__init__.py | 3 - .../core/models/__init__.py | 9 - .../core/models/build_parameters.py | 27 --- .../core/models/parameter.py | 25 --- .../core/models/parameters_set.py | 77 ------- .../core/models/restriction.py | 24 --- .../core/models/selector.py | 23 -- .../build_options_helper/helper.py | 51 ----- .../ios_build_settings_renderer/__init__.py | 6 - .../ios_build_settings_renderer/models.py | 120 ----------- .../ios_build_settings_renderer/raw_models.py | 17 -- .../xcconfigs_renderer.py | 19 -- .../build_options_helper/requirements.pip | 1 - .../test_data/build_parameters.yaml | 97 --------- .../web_parameters_renderer/__init__.py | 6 - .../web_parameters_renderer/models.py | 13 -- .../parameter_renderer.py | 20 -- .../web_parameters_renderer/raw_models.py | 12 -- 24 files changed, 4 insertions(+), 907 deletions(-) create mode 100644 .gitmodules create mode 160000 xcode/config_generator/build_options_helper delete mode 100644 xcode/config_generator/build_options_helper/.gitignore delete mode 100644 xcode/config_generator/build_options_helper/LICENSE delete mode 100644 xcode/config_generator/build_options_helper/README.md delete mode 100644 xcode/config_generator/build_options_helper/argument_parser.py delete mode 100644 xcode/config_generator/build_options_helper/core/__init__.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/__init__.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/build_parameters.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/parameter.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/parameters_set.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/restriction.py delete mode 100644 xcode/config_generator/build_options_helper/core/models/selector.py delete mode 100755 xcode/config_generator/build_options_helper/helper.py delete mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py delete mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py delete mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py delete mode 100644 xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py delete mode 100644 xcode/config_generator/build_options_helper/requirements.pip delete mode 100644 xcode/config_generator/build_options_helper/test_data/build_parameters.yaml delete mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py delete mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/models.py delete mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py delete mode 100644 xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..48fee14 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "build_options_helper"] + path = xcode/config_generator/build_options_helper + url = https://github.com/petropavel13/build_options_helper diff --git a/xcode/config_generator/build_options_helper b/xcode/config_generator/build_options_helper new file mode 160000 index 0000000..957fb64 --- /dev/null +++ b/xcode/config_generator/build_options_helper @@ -0,0 +1 @@ +Subproject commit 957fb642a4348923377a625b521d1812620384ba diff --git a/xcode/config_generator/build_options_helper/.gitignore b/xcode/config_generator/build_options_helper/.gitignore deleted file mode 100644 index b6e4761..0000000 --- a/xcode/config_generator/build_options_helper/.gitignore +++ /dev/null @@ -1,129 +0,0 @@ -# Byte-compiled / optimized / DLL files -__pycache__/ -*.py[cod] -*$py.class - -# C extensions -*.so - -# Distribution / packaging -.Python -build/ -develop-eggs/ -dist/ -downloads/ -eggs/ -.eggs/ -lib/ -lib64/ -parts/ -sdist/ -var/ -wheels/ -pip-wheel-metadata/ -share/python-wheels/ -*.egg-info/ -.installed.cfg -*.egg -MANIFEST - -# PyInstaller -# Usually these files are written by a python script from a template -# before PyInstaller builds the exe, so as to inject date/other infos into it. -*.manifest -*.spec - -# Installer logs -pip-log.txt -pip-delete-this-directory.txt - -# Unit test / coverage reports -htmlcov/ -.tox/ -.nox/ -.coverage -.coverage.* -.cache -nosetests.xml -coverage.xml -*.cover -*.py,cover -.hypothesis/ -.pytest_cache/ - -# Translations -*.mo -*.pot - -# Django stuff: -*.log -local_settings.py -db.sqlite3 -db.sqlite3-journal - -# Flask stuff: -instance/ -.webassets-cache - -# Scrapy stuff: -.scrapy - -# Sphinx documentation -docs/_build/ - -# PyBuilder -target/ - -# Jupyter Notebook -.ipynb_checkpoints - -# IPython -profile_default/ -ipython_config.py - -# pyenv -.python-version - -# pipenv -# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. -# However, in case of collaboration, if having platform-specific dependencies or dependencies -# having no cross-platform support, pipenv may install dependencies that don't work, or not -# install all needed dependencies. -#Pipfile.lock - -# PEP 582; used by e.g. github.com/David-OConnor/pyflow -__pypackages__/ - -# Celery stuff -celerybeat-schedule -celerybeat.pid - -# SageMath parsed files -*.sage.py - -# Environments -.env -.venv -env/ -venv/ -ENV/ -env.bak/ -venv.bak/ - -# Spyder project settings -.spyderproject -.spyproject - -# Rope project settings -.ropeproject - -# mkdocs documentation -/site - -# mypy -.mypy_cache/ -.dmypy.json -dmypy.json - -# Pyre type checker -.pyre/ diff --git a/xcode/config_generator/build_options_helper/LICENSE b/xcode/config_generator/build_options_helper/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/xcode/config_generator/build_options_helper/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/xcode/config_generator/build_options_helper/README.md b/xcode/config_generator/build_options_helper/README.md deleted file mode 100644 index 78a5670..0000000 --- a/xcode/config_generator/build_options_helper/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# build_options_helper -An utility to work with build options diff --git a/xcode/config_generator/build_options_helper/argument_parser.py b/xcode/config_generator/build_options_helper/argument_parser.py deleted file mode 100644 index d56499f..0000000 --- a/xcode/config_generator/build_options_helper/argument_parser.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -import argparse -import os -import tempfile - -class writeable_dir(argparse.Action): - def __call__(self, parser, namespace, values, option_string=None): - prospective_dir = values - - if not os.path.isdir(prospective_dir): - raise argparse.ArgumentTypeError("writeable_dir:{0} is not a valid path".format(prospective_dir)) - if os.access(prospective_dir, os.W_OK): - setattr(namespace, self.dest, prospective_dir) - else: - raise argparse.ArgumentTypeError("writeable_dir:{0} is not a writeable dir".format(prospective_dir)) - -class ArgumentParser(argparse.ArgumentParser): - def configure(self): - self.add_argument('--build-parameters-path', '-bp', default="build_parameters.yaml", type=open, required=True) - self.add_argument('--output-folder', '-o', action=writeable_dir, default=tempfile.mkdtemp(), required=True) - self.add_argument('--render', '-r', choices=['ios_build_settings', 'team_city_web_parameters'], type=str, required=True) - self.add_argument('--platform', '-p', choices=['ios', 'android'], type=str, required=True) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/__init__.py b/xcode/config_generator/build_options_helper/core/__init__.py deleted file mode 100644 index 85f54f0..0000000 --- a/xcode/config_generator/build_options_helper/core/__init__.py +++ /dev/null @@ -1,3 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/__init__.py b/xcode/config_generator/build_options_helper/core/models/__init__.py deleted file mode 100644 index 28ba362..0000000 --- a/xcode/config_generator/build_options_helper/core/models/__init__.py +++ /dev/null @@ -1,9 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from .selector import Selector -from .restriction import Restriction -from .parameter import Parameter -from .build_parameters import BuildParameters -from .parameters_set import ParametersSet diff --git a/xcode/config_generator/build_options_helper/core/models/build_parameters.py b/xcode/config_generator/build_options_helper/core/models/build_parameters.py deleted file mode 100644 index 128ee8f..0000000 --- a/xcode/config_generator/build_options_helper/core/models/build_parameters.py +++ /dev/null @@ -1,27 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -from .restriction import Restriction -from .parameter import Parameter - -BuildParametersTuple = namedtuple('BuildParametersTuple', [ - 'all_parameters', - 'project_restrictions', - 'ci_parameters', - 'ios_parameters', - 'android_parameters', -]) - -class BuildParameters(BuildParametersTuple): - @staticmethod - def from_dict(dict_obj): - return BuildParameters( - all_parameters=list(map(Parameter.from_dict, dict_obj["all_parameters"])), - project_restrictions=list(map(Restriction.from_dict, dict_obj["project_restrictions"])), - ci_parameters=list(map(Parameter.from_dict, dict_obj["ci_parameters"])), - ios_parameters=list(map(Parameter.from_dict, dict_obj["ios_parameters"])), - android_parameters=list(map(Parameter.from_dict, dict_obj["android_parameters"])) - ) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/parameter.py b/xcode/config_generator/build_options_helper/core/models/parameter.py deleted file mode 100644 index 38e780d..0000000 --- a/xcode/config_generator/build_options_helper/core/models/parameter.py +++ /dev/null @@ -1,25 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -from .selector import Selector - -ParameterTuple = namedtuple('ParameterTuple', [ - 'key', - 'values', - 'default_value', -]) - -class Parameter(ParameterTuple): - @staticmethod - def from_dict(dict_obj): - return Parameter( - key=dict_obj["key"], - values=dict_obj["values"], - default_value=dict_obj.get("default_value") - ) - - def values_selectors(self): - return [Selector(key=self.key, value=value) for value in self.values] \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/parameters_set.py b/xcode/config_generator/build_options_helper/core/models/parameters_set.py deleted file mode 100644 index 034023d..0000000 --- a/xcode/config_generator/build_options_helper/core/models/parameters_set.py +++ /dev/null @@ -1,77 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -from .selector import Selector - -ParametersSetTuple = namedtuple('ParametersSetTuple', [ - 'active_parameters', -]) - -class ParametersSet(ParametersSetTuple): - def filter_using_restrictions_and_selectors(self, restrictions, selectors): - new_parameters = ParametersSet.__filter_parameters_using_restrictions_and_selectors(self.active_parameters, restrictions, selectors) - - return ParametersSet(active_parameters=new_parameters) - - def update_parameters(self, parameters): - parameters_dict = { p.key : p for p in parameters } - parameters_dict_keys = parameters_dict.keys() - - # update & keep ordering - new_active_parameters = [parameters_dict[p.key] if p.key in parameters_dict_keys else p for p in self.active_parameters] - - return ParametersSet(active_parameters=new_active_parameters) - - @staticmethod - def __filter_parameters_using_restrictions_and_selectors(parameters, restrictions, selectors): - active_restrictions = filter(lambda r: r.is_active_for_selectors(selectors), restrictions) - - parameters_keys = list(map(lambda p: p.key, parameters)) - - parameters_from_restrictions = { parameter.key : parameter for restriction in active_restrictions for parameter in restriction.set if parameter.key in parameters_keys } - - # replace with restriction parameters and keep original ordering - return [parameters_from_restrictions.get(p.key, p) for p in parameters] - - @staticmethod - def __difference_for_parameters(parameters, active_parameters): - parameters_keys = list(map(lambda p: p.key, parameters)) - - return list(filter(lambda p: p.key not in parameters_keys, active_parameters)) - - def as_selectors(self, project_restrictions): - non_empty_active_parameters = list(filter(lambda p: len(p.values) > 0, self.active_parameters)) - - if len(non_empty_active_parameters) > 0: - return list(ParametersSet.__as_selectors_recursive([], non_empty_active_parameters[0], non_empty_active_parameters[1:], non_empty_active_parameters, project_restrictions)) - else: - return [] - - @staticmethod - def __as_selectors_recursive(head_selectors, current_parameter, tail_parameters, all_parameters, project_restrictions): - if len(tail_parameters) == 0: - for parameter_value in current_parameter.values: - current_selector = Selector(key=current_parameter.key, value=parameter_value) - new_head_selectors = head_selectors + [current_selector] - - all_parameters_filtered = ParametersSet.__filter_parameters_using_restrictions_and_selectors(all_parameters, project_restrictions, new_head_selectors) - - parameters_selectors = { selector for parameter in all_parameters_filtered for selector in parameter.values_selectors() } - - if set(new_head_selectors).issubset(parameters_selectors): - yield new_head_selectors - - return - - for current_parameter_value in current_parameter.values: - current_selector = Selector(key=current_parameter.key, value=current_parameter_value) - new_head_selectors = head_selectors + [current_selector] - - new_tail_parameters = ParametersSet.__filter_parameters_using_restrictions_and_selectors(tail_parameters[1:], project_restrictions, new_head_selectors) - - for selectors in ParametersSet.__as_selectors_recursive(new_head_selectors, tail_parameters[0], new_tail_parameters, all_parameters, project_restrictions): - yield selectors - diff --git a/xcode/config_generator/build_options_helper/core/models/restriction.py b/xcode/config_generator/build_options_helper/core/models/restriction.py deleted file mode 100644 index b0f12de..0000000 --- a/xcode/config_generator/build_options_helper/core/models/restriction.py +++ /dev/null @@ -1,24 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -from .selector import Selector -from .parameter import Parameter - -RestrictionTuple = namedtuple('RestrictionTuple', [ - 'when', - 'set', -]) - -class Restriction(RestrictionTuple): - @staticmethod - def from_dict(dict_obj): - return Restriction( - when=frozenset(map(Selector.from_dict, dict_obj["when"])), - set=list(map(Parameter.from_dict, dict_obj["set"])), - ) - - def is_active_for_selectors(self, selectors): - return not frozenset(selectors).isdisjoint(self.when) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/core/models/selector.py b/xcode/config_generator/build_options_helper/core/models/selector.py deleted file mode 100644 index fcf5a8f..0000000 --- a/xcode/config_generator/build_options_helper/core/models/selector.py +++ /dev/null @@ -1,23 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -SelectorTuple = namedtuple('SelectorTuple', [ - 'key', - 'value', -]) - -class Selector(SelectorTuple): - @staticmethod - def from_dict(dict_obj): - return Selector(**dict_obj) - - def __eq__(self, obj): - return isinstance(obj, Selector) and \ - obj.key == self.key and \ - obj.value == self.value - - def __hash__(self): - return hash((self.key, self.value)) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/helper.py b/xcode/config_generator/build_options_helper/helper.py deleted file mode 100755 index f33b1c9..0000000 --- a/xcode/config_generator/build_options_helper/helper.py +++ /dev/null @@ -1,51 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from argument_parser import ArgumentParser - -import yaml - -from web_parameters_renderer import ParameterRenderer, Option -from ios_build_settings_renderer import XCConfigsRenderer, XCConfig - -from core.models import BuildParameters, ParametersSet - -import os - -parser = ArgumentParser() -parser.configure() - -args = parser.parse_args() - -output_folder = os.path.abspath(os.path.expanduser(args.output_folder)) - -build_parameters = BuildParameters.from_dict(yaml.safe_load(args.build_parameters_path)) - -parameters_set = ParametersSet(active_parameters=build_parameters.all_parameters) - -if args.platform == 'ios': - parameters_set = parameters_set.update_parameters(build_parameters.ios_parameters) -elif args.platform == 'android': - parameters_set = parameters_set.update_parameters(build_parameters.android_parameters) -else: - raise ValueError("Unknown platform {}".format(args.platform)) - -if args.render == "ios_build_settings": - xcconfigs = map(XCConfig.from_selectors, parameters_set.as_selectors(build_parameters.project_restrictions)) - XCConfigsRenderer("configs_data", xcconfigs).render_json_to_file_in_dir(output_folder) -elif args.render == "team_city_web_parameters": - parameters_set = parameters_set.update_parameters(build_parameters.ci_parameters) - active_parameters = parameters_set.active_parameters - - options_from_parameter = lambda p: [Option(key=value, value=value, enabled=True, default=p.default_value == value) for value in p.values] - - renderers = [ParameterRenderer(parameter.key, options_from_parameter(parameter)) for parameter in active_parameters] - - for r in renderers: - r.render_json_to_file_in_dir(output_folder) -else: - raise ValueError("Unknown render command {}".format(args.render)) - -print("Perameters renderer to {}".format(output_folder)) diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py deleted file mode 100644 index b5faf44..0000000 --- a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from .xcconfigs_renderer import XCConfigsRenderer -from .models import XCConfig \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py deleted file mode 100644 index 62a5451..0000000 --- a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/models.py +++ /dev/null @@ -1,120 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from .raw_models import * -from core.models import Selector - -class XCConfig(XCConfigTuple): - - DISTIBUTION_TYPE_KEY = "DISTRIBUTION_TYPE" - BUILD_TYPE_KEY = "BUILD_TYPE" - - @staticmethod - def from_selectors(selectors): - selectors_dict = XCConfig.__make_dict_from_selectors(selectors) - - distibution_type_value = selectors_dict.get(XCConfig.DISTIBUTION_TYPE_KEY, None) - - is_app_store_config = distibution_type_value.lower() == "AppStore".lower() - build_type_value = selectors_dict.get(XCConfig.BUILD_TYPE_KEY, None) - build_type = distibution_type_value.lower() if is_app_store_config else build_type_value.lower() - - compatability_selectors = map(XCConfig.__modify_selector_if_needed, selectors) - - return XCConfig( - name="".join(map(lambda s: s.value, compatability_selectors)), - account_type=distibution_type_value, - build_type=build_type, - xcconfig_options=map(lambda f: f(selectors_dict), [ - XCConfigOption.swift_active_compilation_conditions, - XCConfigOption.debug_information_format, - XCConfigOption.validate_product, - XCConfigOption.enable_testability, - XCConfigOption.code_sign_identity, - XCConfigOption.gcc_optimization_level, - XCConfigOption.swift_optimization_level, - XCConfigOption.swift_compilation_mode - ]) - ) - - @staticmethod - def __make_dict_from_selectors(selectors): - # compatibility mode - return { s.key : (XCConfig.__account_type_from_distribution_type(s.value) if s.key == XCConfig.DISTIBUTION_TYPE_KEY else s.value) for s in selectors } - - # normal mode - # return { s.key : s.value for s in selectors } - - @staticmethod - def __modify_selector_if_needed(selector): - # compatibility mode - if selector.key == XCConfig.DISTIBUTION_TYPE_KEY: - return Selector(key=selector.key, value=XCConfig.__account_type_from_distribution_type(selector.value)) - else: - return selector - - # normal mode - # return selector - - @staticmethod - def __account_type_from_distribution_type(distibution_type): - if distibution_type == "Local": - return "Standard" - elif distibution_type == "Firebase": - return "Enterprise" - elif distibution_type == "Store": - return "AppStore" - - def _asdict(self): - return { - 'name': self.name, - 'account_type': self.account_type, - 'build_type': self.build_type, - 'xcconfig_options': [o._asdict() for o in self.xcconfig_options] - } - - -class XCConfigOption(XCConfigOptionTuple): - @staticmethod - def swift_active_compilation_conditions(selectors_dict): - return XCConfigOption( - key="SWIFT_ACTIVE_COMPILATION_CONDITIONS", - value=" ".join(map(lambda sv: sv.upper(), selectors_dict.values())) - ) - - @staticmethod - def debug_information_format(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("DEBUG_INFORMATION_FORMAT", "dwarf", "dwarf-with-dsym", selectors_dict) - - @staticmethod - def validate_product(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("VALIDATE_PRODUCT", "NO", "YES", selectors_dict) - - @staticmethod - def enable_testability(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("ENABLE_TESTABILITY", "YES", "NO", selectors_dict) - - @staticmethod - def code_sign_identity(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("CODE_SIGN_IDENTITY", "iPhone Developer", "iPhone Distribution", selectors_dict, "Standard") - - @staticmethod - def gcc_optimization_level(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("GCC_OPTIMIZATION_LEVEL", "0", "s", selectors_dict) - - @staticmethod - def swift_optimization_level(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("SWIFT_OPTIMIZATION_LEVEL", "-Onone", "-O", selectors_dict) - - @staticmethod - def swift_compilation_mode(selectors_dict): - return XCConfigOption.__from_key_and_value_based_on_value_in_selectors("SWIFT_COMPILATION_MODE", "singlefile", "wholemodule", selectors_dict) - - @staticmethod - def __from_key_and_value_based_on_value_in_selectors(key, value_if_contains, otherwise_value, - selectors_dict, expected_value="Debug"): - return XCConfigOption( - key=key, - value=value_if_contains if expected_value.upper() in map(lambda sv: sv.upper(), selectors_dict.values()) else otherwise_value - ) diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py deleted file mode 100644 index fe922f2..0000000 --- a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/raw_models.py +++ /dev/null @@ -1,17 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -XCConfigOptionTuple = namedtuple('XCConfigOptionTuple', [ - 'key', - 'value' -]) - -XCConfigTuple = namedtuple('XCConfigTuple', [ - 'name', - 'account_type', - 'build_type', - 'xcconfig_options' -]) \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py b/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py deleted file mode 100644 index 28c4927..0000000 --- a/xcode/config_generator/build_options_helper/ios_build_settings_renderer/xcconfigs_renderer.py +++ /dev/null @@ -1,19 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -import json -import os - -class XCConfigsRenderer: - def __init__(self, name, xcconfigs): - self.name = name - self.xcconfig_dicts = [xcconfig._asdict() for xcconfig in xcconfigs] - - def render_to_json(self): - return json.dumps(self.xcconfig_dicts, indent=4) - - def render_json_to_file_in_dir(self, dir_path): - file_name = "{}.json".format(self.name) - file_path = os.path.join(dir_path, file_name) - return json.dump(self.xcconfig_dicts, open(file_path, 'w'), indent=4) diff --git a/xcode/config_generator/build_options_helper/requirements.pip b/xcode/config_generator/build_options_helper/requirements.pip deleted file mode 100644 index dbfc709..0000000 --- a/xcode/config_generator/build_options_helper/requirements.pip +++ /dev/null @@ -1 +0,0 @@ -PyYAML \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml b/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml deleted file mode 100644 index 013d09a..0000000 --- a/xcode/config_generator/build_options_helper/test_data/build_parameters.yaml +++ /dev/null @@ -1,97 +0,0 @@ -all_parameters: - - key: DISTRIBUTION_TYPE - values: [Firebase, Store, Local] - default_value: Firebase - - - key: OBFUSCATE - values: [Obfuscate, NoObfuscate] - default_value: Obfuscate - - - key: SERVER_TYPE - values: [Mock, Touchin, Customer] - default_value: Mock - - - key: SERVER_ENVIRONMENT - values: [Dev, Test, Stage, Prod] - default_value: Test - - - key: SSL_PINNING - values: [WithSSLPinning, WithoutSSLPinning] - default_value: WithoutSSLPinning - - - key: TEST_PANEL - values: [WithTestPanel, WithoutTestPanel] - default_value: WithoutTestPanel - - - key: BUILD_TYPE - values: [Debug, Release] - default_value: Release - -project_restrictions: - # Mock -> Dev|Stage - - when: - - key: SERVER_TYPE - value: Mock - set: - - key: SERVER_ENVIRONMENT - values: [Dev, Stage] - default_value: Dev - - # Touchin -> Dev|Test|Stage - - when: - - key: SERVER_TYPE - value: Touchin - set: - - key: SERVER_ENVIRONMENT - values: [Dev, Test, Stage] - default_value: Test - - # Customer -> Prod - - when: - - key: SERVER_TYPE - value: Customer - set: - - key: SERVER_ENVIRONMENT - values: [Prod] - - # Store -> ObfuscateWithSSLPinningWithoutTestPanelReleaseCustomerProd - - when: - - key: DISTRIBUTION_TYPE - value: Store - set: - - key: OBFUSCATE - values: [Obfuscate] - - key: SSL_PINNING - values: [WithSSLPinning] - - key: TEST_PANEL - values: [WithoutTestPanel] - - key: BUILD_TYPE - values: [Release] - - key: SERVER_TYPE - values: [Customer] - - key: SERVER_ENVIRONMENT - values: [Prod] - - # Firebase -> Release - - when: - - key: DISTRIBUTION_TYPE - value: Firebase - set: - - key: BUILD_TYPE - values: [Release] - -ci_parameters: - - key: DISTRIBUTION_TYPE - values: [Firebase, Store] - default_value: Firebase - -ios_parameters: - # Not available - - key: OBFUSCATE - values: [] - - # Not available - - key: TEST_PANEL - values: [] - -android_parameters: [] diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py deleted file mode 100644 index e449d47..0000000 --- a/xcode/config_generator/build_options_helper/web_parameters_renderer/__init__.py +++ /dev/null @@ -1,6 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from .parameter_renderer import ParameterRenderer -from .models import Option \ No newline at end of file diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py deleted file mode 100644 index 0ad3103..0000000 --- a/xcode/config_generator/build_options_helper/web_parameters_renderer/models.py +++ /dev/null @@ -1,13 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from .raw_models import * - -class Option(OptionTuple): - def _asdict(self): - original_dict = super(Option, self)._asdict() - # remove records with None values - return {k: v for k, v in original_dict.items() if v is not None} - - diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py deleted file mode 100644 index 189e38f..0000000 --- a/xcode/config_generator/build_options_helper/web_parameters_renderer/parameter_renderer.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -import json -import os - -class ParameterRenderer: - def __init__(self, name, options): - self.name = name - self.options_dict = {"options": [option._asdict() for option in options]} - - def render_to_json(self): - return json.dumps(self.options_dict, indent=4) - - def render_json_to_file_in_dir(self, dir_path): - file_name = "{}.json".format(self.name) - file_path = os.path.join(dir_path, file_name) - return json.dump(self.options_dict, open(file_path, 'w'), indent=4) - diff --git a/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py b/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py deleted file mode 100644 index 3d973cb..0000000 --- a/xcode/config_generator/build_options_helper/web_parameters_renderer/raw_models.py +++ /dev/null @@ -1,12 +0,0 @@ -# -*- coding: utf-8 -*- - -from __future__ import unicode_literals # python 2/3 support - -from collections import namedtuple - -OptionTuple = namedtuple('OptionTuple', [ - 'key', - 'value', - 'enabled', - 'default' -]) \ No newline at end of file From 1c6abf0146495c7ea2d60da5e63b381195cd1966 Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Wed, 17 Jun 2020 15:35:33 +0300 Subject: [PATCH 24/30] Place config rendering temp data to renderer current directory --- xcode/config_generator/render_xcconfigs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 197c382..2575184 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -29,7 +29,7 @@ build_parameters_path = ARGV[1] || "build_parameters.yaml".in_current_dir Dir.mkdir($configs_folder_name) unless Dir.exist?($configs_folder_name) # Call python script and generate configs to config file -system("python #{generator_path} -bp #{build_parameters_path} -o . -r ios_build_settings -p ios") +system("python #{generator_path} -bp #{build_parameters_path} -o #{__dir__} -r ios_build_settings -p ios") # Open settings, configurations and template files target_xcconfig_tempate = File.read(template_path) From 799a23adcac2914bf5cdddab98511dea507a7fcf Mon Sep 17 00:00:00 2001 From: Vitaliy Salnikov Date: Thu, 18 Jun 2020 17:01:22 +0300 Subject: [PATCH 25/30] Update build options helper submodule --- xcode/config_generator/build_options_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/config_generator/build_options_helper b/xcode/config_generator/build_options_helper index 957fb64..3f81529 160000 --- a/xcode/config_generator/build_options_helper +++ b/xcode/config_generator/build_options_helper @@ -1 +1 @@ -Subproject commit 957fb642a4348923377a625b521d1812620384ba +Subproject commit 3f81529c1425a74f43fe84fe8befffd81a442cc7 From 343567c1c873ea624ad4dda6f9a17b0f89bee5da Mon Sep 17 00:00:00 2001 From: Vlad Date: Mon, 15 Jun 2020 23:57:16 +0300 Subject: [PATCH 26/30] Add missing bundle id --- xcode/config_generator/render_xcconfigs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 2575184..1cce43b 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -109,7 +109,7 @@ def generate_missing_properties(target_name, properties, distribution_type) end unless properties.key?(provisioning_key) - result.append(generate_provisioning_profile(provisioning_key, bundle_id, distribution_type)) + result.append(generate_provisioning_profile(provisioning_key, properties[$bundle_id_key], distribution_type)) end unless properties.key?(google_service_info_plist_key) From a33f97b2270cfa2e7afb633b3f7ff0ff0a7f6f08 Mon Sep 17 00:00:00 2001 From: Ivan Smolin Date: Fri, 19 Jun 2020 16:03:21 +0300 Subject: [PATCH 27/30] fix ruby syntax --- xcode/config_generator/render_xcconfigs.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcode/config_generator/render_xcconfigs.rb b/xcode/config_generator/render_xcconfigs.rb index 1cce43b..64d6b8e 100755 --- a/xcode/config_generator/render_xcconfigs.rb +++ b/xcode/config_generator/render_xcconfigs.rb @@ -109,7 +109,7 @@ def generate_missing_properties(target_name, properties, distribution_type) end unless properties.key?(provisioning_key) - result.append(generate_provisioning_profile(provisioning_key, properties[$bundle_id_key], distribution_type)) + result.append(generate_provisioning_profile(provisioning_key, properties[bundle_id_key], distribution_type)) end unless properties.key?(google_service_info_plist_key) From 0f0c2c5c1b260f52ba3d4c5db19100fe43b6048c Mon Sep 17 00:00:00 2001 From: Boyko Mihail Date: Fri, 19 Jun 2020 17:41:09 +0300 Subject: [PATCH 28/30] replace syncCodeSigning -> sync_code_signing_using_options in commonFastfile --- xcode/commonFastfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/xcode/commonFastfile b/xcode/commonFastfile index 673a17b..d903469 100644 --- a/xcode/commonFastfile +++ b/xcode/commonFastfile @@ -135,13 +135,13 @@ private_lane :buildConfiguration do |options| if !(options[:uploadToFabric] || options[:uploadToAppStore]) options[:skip_package_ipa] = true - syncCodeSigning(options) + sync_code_signing_using_options(options) buildArchive(options) # check build failures and static analysis end if options[:uploadToFabric] - syncCodeSigning(options) + sync_code_signing_using_options(options) addShield(options) buildArchive(options) @@ -152,7 +152,7 @@ private_lane :buildConfiguration do |options| options[:compileBitcode] = options[:compileBitcode].nil? ? true : options[:compileBitcode] options[:include_symbols] = options[:include_symbols].nil? ? true : options[:include_symbols] - syncCodeSigning(options) + sync_code_signing_using_options(options) buildArchive(options) uploadToAppStore(options) From 8e40c0a53f6de6b2de3c6a27b6ddc36a1e7b621d Mon Sep 17 00:00:00 2001 From: Maxim Bachinsky Date: Tue, 23 Jun 2020 17:43:59 +0300 Subject: [PATCH 29/30] remove old git hooks script --- android_hooks/pre-push | 20 -------------------- gradle/installGitHooks.gradle | 7 ------- 2 files changed, 27 deletions(-) delete mode 100755 android_hooks/pre-push delete mode 100644 gradle/installGitHooks.gradle diff --git a/android_hooks/pre-push b/android_hooks/pre-push deleted file mode 100755 index cc5cdce..0000000 --- a/android_hooks/pre-push +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/sh - -echo "Pre push static analysis" - -output=$(./gradlew staticAnalysis --daemon 2>&1) - -status=$? - -if [ "$status" = 0 ] ; then - exit 0 -else - build_date=$(date +'%Y-%m-%d_%T') - file_name="build_$build_date" - folder_name="./build_log/" - file_path="${folder_name}${file_name}" - mkdir -p "$folder_name" - echo "$output" >> "$file_path" - echo "Pre push static failed. Full log path: ${file_path}" - exit 1 -fi diff --git a/gradle/installGitHooks.gradle b/gradle/installGitHooks.gradle deleted file mode 100644 index 8f1ebc4..0000000 --- a/gradle/installGitHooks.gradle +++ /dev/null @@ -1,7 +0,0 @@ -task installGitHooks(type: Copy) { - from new File(buildScriptsDir, 'android_hooks') - into { new File(rootProject.rootDir, '.git/hooks') } - fileMode 0777 -} - -tasks.getByPath(':app:preBuild').dependsOn installGitHooks From 8b4b3878d3ec461e76d4dc0a4a751e83ba7e01f2 Mon Sep 17 00:00:00 2001 From: alex Date: Fri, 26 Jun 2020 18:34:42 +0300 Subject: [PATCH 30/30] new package name for proguard rule --- proguard/rules/components.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/proguard/rules/components.pro b/proguard/rules/components.pro index 830b721..5bf7020 100644 --- a/proguard/rules/components.pro +++ b/proguard/rules/components.pro @@ -1,2 +1,2 @@ # View controllers are created through reflection. --keep class ** extends ru.touchin.roboswag.components.navigation.viewcontrollers.ViewController { *; } +-keep class ** extends ru.touchin.roboswag.navigation_viewcontroller.viewcontrollers.ViewController { *; }