mirror of
https://github.com/zhigang1992/RubyMotion.git
synced 2026-04-05 17:40:51 +08:00
Added support for loading target frameworks in extensions
This commit is contained in:
committed by
Eloy Durán
parent
bf594af9d0
commit
b94afc9d38
@@ -96,7 +96,7 @@ module Motion; module Project;
|
||||
|
||||
# Prepare target frameworks
|
||||
target_frameworks = []
|
||||
config.targets.select { |t| t.type == :framework }.each do |target|
|
||||
config.targets.select { |t| t.type == :framework && t.load? }.each do |target|
|
||||
target_frameworks << target.framework_name
|
||||
end
|
||||
end
|
||||
|
||||
@@ -136,5 +136,10 @@ PLIST
|
||||
File.basename(framework_path)
|
||||
end
|
||||
|
||||
# Indicates wether to load the framework at runtime or not
|
||||
def load?
|
||||
@opts[:load]
|
||||
end
|
||||
|
||||
end
|
||||
end;end
|
||||
@@ -171,6 +171,13 @@ PLIST
|
||||
embedded_frameworks = external_frameworks = []
|
||||
end
|
||||
|
||||
# Prepare target frameworks
|
||||
target_frameworks = []
|
||||
config.targets.select { |t| t.type == :framework && t.load? }.each do |target|
|
||||
target.build(platform)
|
||||
target_frameworks << target.framework_name
|
||||
end
|
||||
|
||||
# Build object files.
|
||||
objs_build_dir = File.join(build_dir, 'objs')
|
||||
FileUtils.mkdir_p(objs_build_dir)
|
||||
@@ -264,6 +271,8 @@ PLIST
|
||||
|
||||
# Generate init file.
|
||||
init_txt = <<EOS
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
extern "C" {
|
||||
void ruby_sysinit(int *, char ***);
|
||||
void ruby_init(void);
|
||||
@@ -302,6 +311,14 @@ RubyMotionInit(int argc, char **argv)
|
||||
void *self = rb_vm_top_self();
|
||||
EOS
|
||||
init_txt << config.define_global_env_txt
|
||||
|
||||
unless target_frameworks.empty?
|
||||
init_txt << "NSString *frameworks_path = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent: @\"../../Frameworks\"];\n"
|
||||
target_frameworks.each do |framework|
|
||||
init_txt << "[[NSBundle bundleWithPath: [frameworks_path stringByAppendingPathComponent: @\"#{framework}\"]] load];\n"
|
||||
end
|
||||
end
|
||||
|
||||
app_objs.each do |_, init_func|
|
||||
init_txt << "#{init_func}(self, 0);\n"
|
||||
end
|
||||
|
||||
@@ -463,6 +463,7 @@ EOS
|
||||
def target(path, type, opts={})
|
||||
case type
|
||||
when :framework
|
||||
opts[:load] = true unless opts[:load] == false
|
||||
@targets << Motion::Project::FrameworkTarget.new(path, type, self, opts)
|
||||
when :extension
|
||||
@targets << Motion::Project::ExtensionTarget.new(path, type, self, opts)
|
||||
|
||||
Reference in New Issue
Block a user