Added support for loading target frameworks in extensions

This commit is contained in:
Mark Villacampa
2014-08-27 03:52:57 +02:00
committed by Eloy Durán
parent bf594af9d0
commit b94afc9d38
4 changed files with 24 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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)