-
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 all 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 |
---|---|---|
|
@@ -24,9 +24,11 @@ def self.set_additional_default_values | |
|
||
detect_output_path doc_csproj | ||
detect_manifest doc_csproj | ||
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_min_max_sdk 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 | ||
|
@@ -63,34 +65,26 @@ def self.detect_output_path(doc_csproj) | |
return if Souyuz.config[:output_path] | ||
|
||
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()='OutputPath']/text()") | ||
output_path = doc_node.text | ||
UI.user_error! 'Not able to find output path automatically, try to specify it via `output_path` parameter.' unless output_path | ||
target_framework_node = doc_csproj.css('PropertyGroup > TargetFramework') | ||
target_framework = target_framework_node.text | ||
|
||
output_path = File.join("bin", "#{configuration}", "#{target_framework}") | ||
Souyuz.config[:output_path] = abs_project_path output_path | ||
end | ||
|
||
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') | ||
Souyuz.config[:manifest_path] = abs_project_path doc_node.text | ||
end | ||
|
||
def self.detect_build_tools | ||
return if Souyuz.config[:buildtools_path] | ||
|
||
UI.user_error! "Please ensure that the Android SDK is installed and the ANDROID_HOME variable is set correctly" unless ENV['ANDROID_HOME'] | ||
configuration = Souyuz.config[:build_configuration] | ||
platform = "AnyCPU" | ||
|
||
# determine latest buildtool version | ||
buildtools = File.join(ENV['ANDROID_HOME'], 'build-tools') | ||
version = Dir.entries(buildtools).sort.last | ||
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? |
||
|
||
UI.success "Using Buildtools Version: #{version}..." | ||
# 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[:buildtools_path] = File.join(buildtools, version) | ||
Souyuz.config[:manifest_path] = abs_project_path doc_node.text | ||
end | ||
|
||
def self.detect_info_plist | ||
|
@@ -113,6 +107,14 @@ def self.detect_assembly_name(doc_csproj) | |
end | ||
end | ||
|
||
def self.detect_min_max_sdk(doc_csproj) | ||
if Souyuz.config[:platform] == Platform::ANDROID | ||
doc = get_parser_handle Souyuz.config[:manifest_path] # explicitly for this call, no cache needed | ||
Souyuz.cache[:android_min_sdk_version] = doc.xpath('string(//manifest/uses-sdk/@android:minSdkVersion)') | ||
Souyuz.cache[:android_target_sdk_version] = doc.xpath('string(//manifest/uses-sdk/@android:targetSdkVersion)') | ||
end | ||
end | ||
|
||
private_class_method | ||
|
||
def self.find_file(query, depth) | ||
|
@@ -155,5 +157,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 = "AnyCPU" | ||
|
||
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 = "AnyCPU" | ||
|
||
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,61 @@ | ||
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 << detect_jarsigner_executable | ||
parts += options | ||
parts += pipe | ||
|
||
parts | ||
end | ||
|
||
def detect_jarsigner_executable | ||
java_parent_folder = "/Library/Java/JavaVirtualMachines" | ||
version = Dir.entries(java_parent_folder).sort.last | ||
jarsigner = "#{File.join(java_parent_folder, version, 'Contents/Home/bin/jarsigner')}" | ||
jarsigner | ||
end | ||
|
||
def prefix | ||
[""] | ||
end | ||
|
||
def options | ||
options = [] | ||
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 | ||
|
||
# VS does that | ||
# /Library/Java/JavaVirtualMachines/microsoft-11.jdk/Contents/Home/bin/jarsigner | ||
# -keystore "debug.keystore" | ||
# -storepass android | ||
# -keypass android | ||
# -digestalg SHA-256 | ||
# -sigalg SHA256withRSA | ||
# -signedjar com.vald.dynamo.aab | ||
# androiddebugkey | ||
end | ||
end | ||
end |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,9 +26,10 @@ def options | |
|
||
options = [] | ||
options << config[:extra_build_options] if config[:extra_build_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 << "-c #{config[:build_configuration]}" if config[:build_configuration] | ||
options << "-p:RuntimeIdentifier=#{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 | ||
|
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?