Merge pull request #204 from TouchInstinct/feature/build_options_for_configs_generation
add configs generation based on build options
This commit is contained in:
commit
0b5f8ba670
|
|
@ -0,0 +1,3 @@
|
|||
[submodule "build_options_helper"]
|
||||
path = xcode/config_generator/build_options_helper
|
||||
url = https://github.com/petropavel13/build_options_helper
|
||||
|
|
@ -0,0 +1 @@
|
|||
Subproject commit 957fb642a4348923377a625b521d1812620384ba
|
||||
|
|
@ -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": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -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: "**********"
|
||||
|
|
@ -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))
|
||||
|
|
@ -4,7 +4,7 @@ require 'yaml'
|
|||
|
||||
# Usage: render_xcconfigs.rb <CONFIGURATIONS.YAML PATH>
|
||||
#
|
||||
# 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]
|
||||
|
|
|
|||
Loading…
Reference in New Issue