mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-23 20:31:17 +08:00
support for 3rd-party android libraries: the build system will vendor all .jar files that are inside the ‘vendor’ sub-directory, and also generate .bridgesupport metadata for them
This commit is contained in:
@@ -34,10 +34,11 @@ require 'motion/project/template/android/config'
|
||||
desc "Create an application package file (.apk)"
|
||||
task :build do
|
||||
# Compile Ruby files.
|
||||
ruby = File.join(App.config.motiondir, 'bin/ruby')
|
||||
ruby = App.config.bin_exec('ruby')
|
||||
init_func_n = 0
|
||||
ruby_objs = []
|
||||
bs_files = Dir.glob(File.join(App.config.versioned_datadir, 'BridgeSupport/*.bridgesupport'))
|
||||
bs_files += App.config.vendored_bs_files
|
||||
ruby_bs_flags = bs_files.map { |x| "--uses-bs \"#{x}\"" }.join(' ')
|
||||
objs_build_dir = File.join(App.config.build_dir, 'obj', 'local', App.config.armeabi_directory_name)
|
||||
kernel_bc = File.join(App.config.versioned_arch_datadir, "kernel-#{App.config.arch}.bc")
|
||||
|
||||
@@ -28,7 +28,7 @@ module Motion; module Project;
|
||||
register :android
|
||||
|
||||
variable :sdk_path, :ndk_path, :avd_config, :package, :main_activity,
|
||||
:sub_activities, :api_version, :arch, :vendored_jars
|
||||
:sub_activities, :api_version, :arch
|
||||
|
||||
def initialize(project_dir, build_mode)
|
||||
super
|
||||
@@ -36,7 +36,6 @@ module Motion; module Project;
|
||||
@main_activity = 'MainActivity'
|
||||
@sub_activities = []
|
||||
@arch = 'armv5te'
|
||||
@vendored_jars = []
|
||||
end
|
||||
|
||||
def validate
|
||||
@@ -147,5 +146,26 @@ module Motion; module Project;
|
||||
raise "Invalid arch `#{arch}'"
|
||||
end
|
||||
end
|
||||
|
||||
def bin_exec(name)
|
||||
File.join(App.config.motiondir, 'bin', name)
|
||||
end
|
||||
|
||||
def vendored_jars
|
||||
@vendored_jars = Dir.glob('vendor/*.jar')
|
||||
end
|
||||
|
||||
def vendored_bs_files
|
||||
@vendored_bs_files ||= begin
|
||||
vendored_jars.map do |jar_file|
|
||||
bs_file = File.join(File.dirname(jar_file), File.basename(jar_file) + '.bridgesupport')
|
||||
if !File.exist?(bs_file) or File.mtime(jar_file) > File.mtime(bs_file)
|
||||
App.info 'Create', bs_file
|
||||
sh "#{bin_exec('android/gen_bridge_metadata')} \"#{jar_file}\" \"#{bs_file}\""
|
||||
end
|
||||
bs_file
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end; end
|
||||
|
||||
Reference in New Issue
Block a user