Sha256: 1a57980d2b5d125efb6df9f71b8556a46b7bc6f8a41a75fecb58f7b745e62398

Contents?: true

Size: 1.39 KB

Versions: 2

Compression:

Stored size: 1.39 KB

Contents

require "rubygems"
require "rake"
require "rake/testtask"

task :default => :test

Rake::TestTask.new do |t|
  t.libs << "test" << "test/bundles"
  t.test_files = FileList['test/test*.rb']
  t.verbose = true
end

namespace :objc do
  desc "Compiles all Objective-C bundles for testing"
  task :compile
end

task :compile => "objc:compile"

task :test => :compile

namespace :objc do
  # look for Classes/*.m files containing a line "void Init_ClassName"
  # These are the primary classes for bundles; make a bundle for each
  model_file_paths = `find Classes/*.m -exec grep -l "^void Init_" {} \\;`.split("\n")
  model_file_paths.each do |path|
    path =~ /Classes\/(.*)\.m/
    model_name = $1

    task :compile => model_name do
      if Dir.glob("**/#{model_name}.bundle").length == 0
        STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        STDERR.puts "Bundle actually failed to build."
        STDERR.puts "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
        exit(1)
      end
    end

    task model_name.to_sym => "build/bundles/#{model_name}.bundle"

    file "build/bundles/#{model_name}.bundle" => ["Classes/#{model_name}.m", "Classes/#{model_name}.h"] do |t|
      FileUtils.mkdir_p "build/bundles"
      FileUtils.rm Dir["build/bundles/#{model_name}.bundle"]
      sh "gcc -o build/bundles/#{model_name}.bundle -bundle -framework Foundation Classes/#{model_name}.m"
    end
  end

end

Version data entries

2 entries across 2 versions & 2 rubygems

Version Path
iphoneruby-0.1.2 app_generators/iphoneruby/templates/Rakefile
rbiphonetest-0.2.0 app_generators/rbiphonetest/templates/Rakefile