-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AAB build and sign support for Android, compile constants support and other improvements #41
base: master
Are you sure you want to change the base?
Changes from 16 commits
3bd6061
3fa3928
771c0cb
9baee4d
5b5c6d2
7123e42
c4bc7b4
1a2de2f
1b403ff
19771c5
51b599f
2f0c4e0
f81d752
790ce9b
d2663f8
f8a0cfd
a0db094
d9efc23
e5cf1d1
fa8c0d9
2b8d700
59712a4
1147922
4bf1f3e
90b7706
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,8 @@ def self.set_additional_default_values | |
detect_build_tools | ||
detect_info_plist | ||
detect_assembly_name doc_csproj # we can only do that for android *after* we detected the android manitfest | ||
detect_compile_constants doc_csproj # all platforms | ||
detect_android_package_format doc_csproj | ||
|
||
return config | ||
end | ||
|
@@ -75,7 +77,14 @@ def self.detect_output_path(doc_csproj) | |
def self.detect_manifest(doc_csproj) | ||
return if Souyuz.config[:manifest_path] or Souyuz.config[:platform] != Platform::ANDROID | ||
|
||
doc_node = doc_csproj.css('PropertyGroup > AndroidManifest') | ||
configuration = Souyuz.config[:build_configuration] | ||
platform = Souyuz.config[:build_platform] | ||
|
||
doc_node = doc_csproj.xpath("/*[local-name()='Project']/*[local-name()='PropertyGroup'][translate(@*[local-name() = 'Condition'],'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = \" '$(configuration)|$(platform)' == '#{configuration.downcase}|#{platform.downcase}' \"]/*[local-name()='AndroidManifest']/text()") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can this be cleaned up a bit? |
||
|
||
# For AAB builds: "<AndroidManifest> tag might be missed, so falling back to first available value" | ||
doc_node = doc_csproj.css('PropertyGroup > AndroidManifest').first if doc_node.empty? | ||
|
||
Souyuz.config[:manifest_path] = abs_project_path doc_node.text | ||
end | ||
|
||
|
@@ -155,5 +164,23 @@ def self.abs_path(path) | |
path = File.expand_path(path) # absolute dir | ||
path | ||
end | ||
|
||
def self.detect_compile_constants(doc_csproj) | ||
configuration = Souyuz.config[:build_configuration] | ||
platform = Souyuz.config[:build_platform] | ||
|
||
compile_constants_node = doc_csproj.xpath("/*[local-name()='Project']/*[local-name()='PropertyGroup'][translate(@*[local-name() = 'Condition'],'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = \" '$(configuration)|$(platform)' == '#{configuration.downcase}|#{platform.downcase}' \"]/*[local-name()='DefineConstants']/text()") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
Souyuz.cache[:compile_constants] = compile_constants_node.text.gsub(";", " ") | ||
compile_constants_node.text | ||
end | ||
|
||
def self.detect_android_package_format(doc_csproj) | ||
configuration = Souyuz.config[:build_configuration] | ||
platform = Souyuz.config[:build_platform] | ||
|
||
android_package_format_node = doc_csproj.xpath("/*[local-name()='Project']/*[local-name()='PropertyGroup'][translate(@*[local-name() = 'Condition'],'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = \" '$(configuration)|$(platform)' == '#{configuration.downcase}|#{platform.downcase}' \"]/*[local-name()='AndroidPackageFormat']/text()") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same as above |
||
Souyuz.cache[:android_package_format] = android_package_format_node.text | ||
android_package_format_node.text | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
module Souyuz | ||
# Responsible for building the aabsigner command | ||
class AabSignCommandGenerator | ||
class << self | ||
def generate | ||
android_package_path = Souyuz.cache[:build_android_package_path] | ||
android_package_dir = File.dirname(android_package_path) | ||
android_package_filename_with_extension = "#{File.basename(android_package_path, ".*")}-signed#{File.extname(android_package_path)}" | ||
Souyuz.cache[:signed_android_package_path] = "#{File.join("#{android_package_dir}", "#{android_package_filename_with_extension}")}" | ||
|
||
parts = prefix | ||
parts += options | ||
parts += pipe | ||
|
||
parts | ||
end | ||
|
||
def prefix | ||
[""] | ||
end | ||
|
||
def options | ||
options = [] | ||
options << "jarsigner" | ||
options << "--verbose" if $verbose | ||
options << "-keystore \"#{Souyuz.config[:keystore_path]}\"" | ||
options << "-storepass \"#{Souyuz.config[:keystore_password]}\"" | ||
options << "-keypass \"#{Souyuz.config[:key_password]}\"" | ||
options << "-digestalg \"SHA-256\"" | ||
options << "-sigalg \"SHA256withRSA\"" | ||
options << "-signedjar \"#{Souyuz.cache[:signed_android_package_path]}\" \"#{Souyuz.cache[:build_android_package_path]}\"" | ||
options << "\"#{Souyuz.config[:keystore_alias]}\"" | ||
|
||
options | ||
end | ||
|
||
def pipe | ||
pipe = [] | ||
|
||
pipe | ||
end | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,7 @@ def options | |
options << "-p:Configuration=#{config[:build_configuration]}" if config[:build_configuration] | ||
options << "-p:Platform=#{config[:build_platform]}" if Souyuz.project.ios? and config[:build_platform] | ||
options << "-p:BuildIpa=true" if Souyuz.project.ios? | ||
options << "-p:DefineConstants=\"#{Souyuz.cache[:compile_constants]}\"" if Souyuz.cache[:compile_constants] | ||
if config[:solution_path] | ||
solution_dir = File.dirname(config[:solution_path]) | ||
options << "-p:SolutionDir=\"#{solution_dir}/\"" | ||
|
@@ -44,7 +45,8 @@ def build_targets | |
def targets | ||
targets = [] | ||
targets += build_targets | ||
targets << "-t:SignAndroidPackage" if Souyuz.project.android? | ||
targets << "-t:SignAndroidPackage" if Souyuz.project.android? and !Souyuz.config[:keystore_path] and !Souyuz.config[:keystore_alias] and !Souyuz.config[:keystore_password] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you group those conditions to a helper method for better readability, please? |
||
targets << "-t:Package" if Souyuz.project.android? and Souyuz.config[:keystore_path] and Souyuz.config[:keystore_alias] and Souyuz.config[:keystore_password] | ||
|
||
targets | ||
end | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,10 @@ | |
|
||
module Souyuz | ||
class Options | ||
|
||
PROVISION_FILES_DEFAULT_LOCATION = "#{Dir.home}/Library/MobileDevice/Provisioning\ Profiles/".freeze | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think of this: Allow the user not to specify a provisioning profile UUID but the whole path to it. You give the user more flexibility if the profile is downloaded to the project folder for example. |
||
BUILD_PLATFORMS = %w(iPhone iPhoneSimulator AnyCPU).freeze | ||
|
||
def self.available_options | ||
[ | ||
FastlaneCore::ConfigItem.new(key: :silent, | ||
|
@@ -20,7 +24,11 @@ def self.available_options | |
FastlaneCore::ConfigItem.new(key: :build_platform, | ||
env_name: "SOUYUZ_BUILD_PLATFORM", | ||
description: "Build platform value", | ||
default_value: 'iPhone'), | ||
default_value: 'iPhone', | ||
is_string: true, | ||
verify_block: proc do |value| | ||
UI.user_error!("Unsupported build platform, use one of #{BUILD_PLATFORMS}") unless BUILD_PLATFORMS.include? value | ||
end), | ||
FastlaneCore::ConfigItem.new(key: :build_target, | ||
env_name: "SOUYUZ_BUILD_TARGET", | ||
description: "Build targets to build", | ||
|
@@ -78,11 +86,32 @@ def self.available_options | |
env_name: "SOUYUZ_ANDROID_KEYSTORE_PASSWORD", | ||
description: "Password of the keystore", | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :key_password, | ||
env_name: "SOUYUZ_ANDROID_KEY_PASSWORD", | ||
description: "Password of the key", | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :keystore_tsa, | ||
default_value: 'http://timestamp.digicert.com', | ||
env_name: "SOUYUZ_ANDROID_KEYSTORE_TSA", | ||
description: "TSA for apksigner", | ||
optional: true) | ||
optional: true), | ||
FastlaneCore::ConfigItem.new(key: :provision_profile_uuid, | ||
env_name: "SOUYUZ_IOS_PP_UUID", | ||
description: "UUID of provision profile in default dir", | ||
is_string: true, | ||
optional: true, | ||
verify_block: proc do |uuid| | ||
file = File.join PROVISION_FILES_DEFAULT_LOCATION, "#{uuid}.mobileprovision" | ||
UI.user_error!('Empty input') if file.nil? | ||
UI.user_error!("#{file} does not exist") unless File.exist? file | ||
UI.user_error!("#{file} is not a file") unless File.file? file | ||
# check if newer PP exist | ||
end), | ||
FastlaneCore::ConfigItem.new(key: :archive_app, | ||
env_name: "SOUYUZ_CREATE_ARCHIVE", | ||
description: "Create *.xcarchive file, only for iOS", | ||
default_value: false, | ||
is_string: false), | ||
] | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please extract this portion to a CHANGELOG.md file?