mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-09-17 08:01:27 +00:00
Moved BlendKit to new build system.
Reviewd by me.
This commit is contained in:
@@ -1,42 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>BlendKit</string>
|
||||
<key>Targets</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>BlendKit</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>Configurations</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Debug</string>
|
||||
<key>Flags</key>
|
||||
<string>-DDEBUG -DPLATFORM_DOM -g</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Release</string>
|
||||
<key>Flags</key>
|
||||
<string>-DPLATFORM_DOM -O</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Debug-Rhino</string>
|
||||
<key>Flags</key>
|
||||
<string>-DDEBUG -g</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>Name</key>
|
||||
<string>Release-Rhino</string>
|
||||
<key>Flags</key>
|
||||
<string>-O</string>
|
||||
</dict>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,33 +0,0 @@
|
||||
<?xml version = "1.0"?>
|
||||
<project name = "BlendKit" default = "build" basedir = "." >
|
||||
|
||||
<import file = "../../../common.xml" />
|
||||
<import file = "${env.OBJJ_LIB}/steam/steam.xml" />
|
||||
|
||||
<target name = "clean" depends = "steam-uptodate">
|
||||
|
||||
<steam-build>
|
||||
<arg line = "-f BlendKit.steam -c ${Configuration} clean" />
|
||||
</steam-build>
|
||||
|
||||
<steam-build>
|
||||
<arg line = "-f BlendKit.steam -c ${Configuration}-Rhino clean" />
|
||||
</steam-build>
|
||||
|
||||
</target>
|
||||
|
||||
<target name = "build" depends = "steam-uptodate">
|
||||
|
||||
<steam-build>
|
||||
<arg line = "-f BlendKit.steam -c ${Configuration}" />
|
||||
</steam-build>
|
||||
|
||||
<steam-build>
|
||||
<arg line = "-f BlendKit.steam -c ${Configuration}-Rhino" />
|
||||
</steam-build>
|
||||
|
||||
<!-- <copy file = "../LICENSE" todir = "${Build}/${Configuration}/AppKit" />-->
|
||||
|
||||
</target>
|
||||
|
||||
</project>
|
||||
@@ -3,52 +3,29 @@
|
||||
require 'rake'
|
||||
require '../../../common'
|
||||
require 'objective-j'
|
||||
require 'objective-j/bundle'
|
||||
require 'objective-j/bundletask'
|
||||
|
||||
|
||||
$PRODUCT = 'BlendKit' + $CONFIGURATION
|
||||
$ENVIRONMENT_PRODUCT = File.join($ENVIRONMENT_FRAMEWORKS_DIR, 'BlendKit')
|
||||
$BUILD_PATH = File.join($BUILD_DIR, $CONFIGURATION, 'BlendKit')
|
||||
|
||||
task :build => [$PRODUCT, $ENVIRONMENT_PRODUCT]
|
||||
task :build => [:BlendKit, $ENVIRONMENT_PRODUCT]
|
||||
|
||||
Specs = {}
|
||||
|
||||
# Debug Framework
|
||||
Specs[:BlendKitDebug] = ObjectiveJ::BundleSpecification.new do |s|
|
||||
s.name = 'BlendKit'
|
||||
s.identifier = 'com.280n.BlendKit'
|
||||
s.version = '0.6.5'
|
||||
s.author = '280 North, Inc.'
|
||||
s.email = 'feedback @nospam@ 280north.com'
|
||||
s.summary = 'BlendKit classes for Cappuccino'
|
||||
s.sources = FileList['**/*.j']
|
||||
s.resources = FileList['Resources/*']
|
||||
s.license = ObjectiveJ::License::LGPL_v2_1
|
||||
s.build_path = File.join($BUILD_DIR, 'Debug', 'BlendKit')
|
||||
s.intermediates_path = File.join($BUILD_DIR, 'BlendKit.build', 'Debug')
|
||||
s.flag = 'DEBUG'
|
||||
ObjectiveJ::BundleTask.new(:BlendKit) do |t|
|
||||
t.name = 'BlendKit'
|
||||
t.identifier = 'com.280n.BlendKit'
|
||||
t.version = '0.6.5'
|
||||
t.author = '280 North, Inc.'
|
||||
t.email = 'feedback @nospam@ 280north.com'
|
||||
t.summary = 'BlendKit classes for Cappuccino'
|
||||
t.sources = FileList['*.j']
|
||||
t.resources = FileList['Resources/*'].to_a
|
||||
t.license = ObjectiveJ::License::LGPL_v2_1
|
||||
t.build_path = $BUILD_PATH
|
||||
t.flag = 'DEBUG' if $CONFIGURATION == 'Debug'
|
||||
end
|
||||
|
||||
bundle Specs[:BlendKitDebug], :BlendKitDebug
|
||||
|
||||
# Release Framework
|
||||
Specs[:BlendKitRelease] = ObjectiveJ::BundleSpecification.new do |s|
|
||||
s.name = 'BlendKit'
|
||||
s.identifier = 'com.280n.BlendKit'
|
||||
s.version = '0.6.5'
|
||||
s.author = '280 North, Inc.'
|
||||
s.email = 'feedback @nospam@ 280north.com'
|
||||
s.summary = 'BlendKit classes for Cappuccino'
|
||||
s.sources = FileList['**/*.j']
|
||||
s.resources = FileList['Resources/*']
|
||||
s.license = ObjectiveJ::License::LGPL_v2_1
|
||||
s.build_path = File.join($BUILD_DIR, 'Release', 'BlendKit')
|
||||
s.intermediates_path = File.join($BUILD_DIR, 'BlendKit.build', 'Release')
|
||||
end
|
||||
|
||||
bundle Specs[:BlendKitRelease], :BlendKitRelease
|
||||
|
||||
#Framework in environment directory
|
||||
file_d $ENVIRONMENT_PRODUCT => [$PRODUCT] do
|
||||
cp_r(Specs[$PRODUCT.to_sym].build_path, $ENVIRONMENT_PRODUCT)
|
||||
file_d $ENVIRONMENT_PRODUCT => [:BlendKit] do
|
||||
cp_r($BUILD_PATH, $ENVIRONMENT_PRODUCT)
|
||||
end
|
||||
|
||||
@@ -38,7 +38,10 @@ file_d $BROWSER_FILE => Files do |t|
|
||||
end
|
||||
|
||||
file_d $RHINO_FILE => Files do |t|
|
||||
build_product(t.name, platform_flags(ObjectiveJ::Platform::Rhino, ObjectiveJ::Platform::ObjJ))
|
||||
flags = platform_flags(ObjectiveJ::Platform::Rhino, ObjectiveJ::Platform::ObjJ)
|
||||
flags['RHINO'] = ''
|
||||
|
||||
build_product(t.name, flags)
|
||||
end
|
||||
|
||||
#Framework in environment directory
|
||||
|
||||
+22
-491
@@ -13,497 +13,33 @@ module ObjectiveJ
|
||||
BrowserDesktop = 'browser-desktop'
|
||||
BrowserIPhone = 'browser-iphone'
|
||||
BrowseriPhone = 'browser-iphone'
|
||||
end
|
||||
|
||||
##
|
||||
# == ObjectiveJ::BundleSpecification
|
||||
#
|
||||
# The Specification class contains the metadata for a Framework. Typically defined in a
|
||||
# Rakefile, and looks like this:
|
||||
#
|
||||
# spec = ObjJ::BundleSpecification.new do |s|
|
||||
# s.name = 'NewKit'
|
||||
# s.version = '1.0'
|
||||
# s.summary = 'Example framework specification'
|
||||
# ...
|
||||
# end
|
||||
#
|
||||
# There are many <em>framework attributes</em>, and the best place to learn about them in
|
||||
# the "Framework Reference" linked from the Cappuccino wiki.
|
||||
#
|
||||
|
||||
class BundleSpecification
|
||||
|
||||
# ------------------------- Specification version contstants.
|
||||
|
||||
# The specification version applied to any new Specification instances created. This
|
||||
# should be bumped whenever something in the spec format changes.
|
||||
CURRENT_SPECIFICATION_VERSION = 1
|
||||
|
||||
# An informal list of changes to the specification. The highest-valued key should be
|
||||
# equal to the CURRENT_SPECIFICATION_VERSION.
|
||||
SPECIFICATION_VERSION_HISTORY = {
|
||||
-1 => ['(RubyGems versions up to and including 0.7 did not have versioned specifications)'],
|
||||
1 => [
|
||||
'First Specification'
|
||||
]
|
||||
PLATFORM_DIRECTORIES =
|
||||
{
|
||||
Platform::ObjJ => 'objj.platform',
|
||||
Platform::Rhino => 'rhino.platform',
|
||||
Platform::Browser => 'browser.platform',
|
||||
Platform::BrowserDesktop => 'browser-desktop.platform',
|
||||
Platform::BrowserIPhone => 'browser-iphone.platform'
|
||||
}
|
||||
|
||||
# ------------------------- Class variables.
|
||||
|
||||
# List of Specification instances.
|
||||
@@list = []
|
||||
|
||||
# Optional block used to gather newly defined instances.
|
||||
@@gather = nil
|
||||
|
||||
# List of attribute names: [:name, :version, ...]
|
||||
@@required_attributes = []
|
||||
|
||||
# List of _all_ attributes and default values: [[:name, nil], [:bindir, 'bin'], ...]
|
||||
@@attributes = []
|
||||
|
||||
# List of array attributes
|
||||
@@array_attributes = []
|
||||
|
||||
# Map of attribute names to default values.
|
||||
@@default_value = {}
|
||||
|
||||
# ------------------------- Convenience class methods.
|
||||
|
||||
def self.attribute_names
|
||||
@@attributes.map { |name, default| name }
|
||||
end
|
||||
|
||||
def self.attribute_defaults
|
||||
@@attributes.dup
|
||||
end
|
||||
|
||||
def self.default_value(name)
|
||||
@@default_value[name]
|
||||
end
|
||||
|
||||
def self.required_attributes
|
||||
@@required_attributes.dup
|
||||
end
|
||||
|
||||
def self.required_attribute?(name)
|
||||
@@required_attributes.include? name.to_sym
|
||||
end
|
||||
|
||||
def self.array_attributes
|
||||
@@array_attributes.dup
|
||||
|
||||
PLATFORM_FLAGS =
|
||||
{
|
||||
Platform::ObjJ => [],
|
||||
Platform::Rhino => ['PLATFORM_RHINO'],
|
||||
Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'],
|
||||
Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'],
|
||||
Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE']
|
||||
}
|
||||
|
||||
def Platform.directory(aPlatform)
|
||||
return PLATFORM_DIRECTORIES[aPlatform]
|
||||
end
|
||||
|
||||
# ------------------------- Infrastructure class methods.
|
||||
|
||||
# A list of Specification instances that have been defined in this Ruby instance.
|
||||
def self.list
|
||||
@@list
|
||||
end
|
||||
|
||||
##
|
||||
# Used to specify the name and default value of a specification attribute. The side
|
||||
# effects are:
|
||||
# * the name and default value are added to the @@attributes list and
|
||||
# @@default_value map
|
||||
# * a standard _writer_ method (<tt>attribute=</tt>) is created
|
||||
# * a non-standard _reader method (<tt>attribute</tt>) is created
|
||||
#
|
||||
# The reader method behaves like this:
|
||||
# def attribute
|
||||
# @attribute ||= (copy of default value)
|
||||
# end
|
||||
#
|
||||
# This allows lazy initialization of attributes to their default values.
|
||||
#
|
||||
def self.attribute(name, default=nil)
|
||||
@@attributes << [name, default]
|
||||
@@default_value[name] = default
|
||||
attr_accessor(name)
|
||||
end
|
||||
|
||||
# Same as :attribute, but ensures that values assigned to the
|
||||
# attribute are array values by applying :to_a to the value.
|
||||
def self.array_attribute(name)
|
||||
@@array_attributes << name
|
||||
@@attributes << [name, []]
|
||||
@@default_value[name] = []
|
||||
module_eval %{
|
||||
def #{name}
|
||||
@#{name} ||= []
|
||||
end
|
||||
def #{name}=(value)
|
||||
@#{name} = value.to_a
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
# Same as attribute above, but also records this attribute as mandatory.
|
||||
def self.required_attribute(*args)
|
||||
@@required_attributes << args.first
|
||||
attribute(*args)
|
||||
end
|
||||
|
||||
# Sometimes we don't want the world to use a setter method for a particular attribute.
|
||||
# +read_only+ makes it private so we can still use it internally.
|
||||
def self.read_only(*names)
|
||||
names.each do |name|
|
||||
private "#{name}="
|
||||
end
|
||||
end
|
||||
|
||||
# Shortcut for creating several attributes at once (each with a default value of
|
||||
# +nil+).
|
||||
def self.attributes(*args)
|
||||
args.each do |arg|
|
||||
attribute(arg, nil)
|
||||
end
|
||||
end
|
||||
|
||||
# Some attributes require special behaviour when they are accessed. This allows for
|
||||
# that.
|
||||
def self.overwrite_accessor(name, &block)
|
||||
remove_method name
|
||||
define_method(name, &block)
|
||||
end
|
||||
|
||||
##
|
||||
# Defines a _singular_ version of an existing _plural_ attribute (i.e. one whose value
|
||||
# is expected to be an array). This means just creating a helper method that takes a
|
||||
# single value and appends it to the array. These are created for convenience, so
|
||||
# that in a spec, one can write
|
||||
#
|
||||
# s.require_path = 'mylib'
|
||||
#
|
||||
# instead of
|
||||
#
|
||||
# s.require_paths = ['mylib']
|
||||
#
|
||||
# That above convenience is available courtesy of
|
||||
#
|
||||
# attribute_alias_singular :require_path, :require_paths
|
||||
#
|
||||
def self.attribute_alias_singular(singular, plural)
|
||||
define_method("#{singular}=") { |val|
|
||||
send("#{plural}=", [val])
|
||||
}
|
||||
define_method("#{singular}") {
|
||||
val = send("#{plural}")
|
||||
val.nil? ? nil : val.first
|
||||
}
|
||||
end
|
||||
|
||||
# ------------------------- REQUIRED framework attributes.
|
||||
|
||||
required_attribute :specification_version, CURRENT_SPECIFICATION_VERSION
|
||||
required_attribute :name
|
||||
required_attribute :version
|
||||
#required_attribute :date
|
||||
attribute :date
|
||||
required_attribute :summary
|
||||
required_attribute :identifier
|
||||
required_attribute :platforms, [Platform::ObjJ]
|
||||
|
||||
read_only :specification_version
|
||||
|
||||
# ------------------------- OPTIONAL gemspec attributes.
|
||||
|
||||
attributes :email, :homepage, :github_project, :description, :license_file, :license
|
||||
attributes :build_path, :intermediates_path
|
||||
# attributes :autorequire, :default_executable
|
||||
# attribute :platform, Gem::Platform::RUBY
|
||||
|
||||
array_attribute :authors
|
||||
array_attribute :sources
|
||||
array_attribute :resources
|
||||
array_attribute :flags
|
||||
# array_attribute :test_files
|
||||
# array_attribute :executables
|
||||
# array_attribute :extensions
|
||||
# array_attribute :requirements
|
||||
# array_attribute :dependencies
|
||||
|
||||
#read_only :dependencies
|
||||
|
||||
# ------------------------- ALIASED gemspec attributes.
|
||||
|
||||
# attribute_alias_singular :executable, :executables
|
||||
attribute_alias_singular :author, :authors
|
||||
attribute_alias_singular :flag, :flags
|
||||
attribute_alias_singular :platform, :platforms
|
||||
# attribute_alias_singular :require_path, :require_paths
|
||||
# attribute_alias_singular :test_file, :test_files
|
||||
|
||||
# ------------------------- RUNTIME attributes (not persisted).
|
||||
|
||||
attr_writer :loaded
|
||||
attr_accessor :loaded_from
|
||||
|
||||
# ------------------------- Special accessor behaviours (overwriting default).
|
||||
|
||||
# overwrite_accessor :version= do |version|
|
||||
# @version = Version.create(version)
|
||||
# end
|
||||
|
||||
overwrite_accessor :date= do |date|
|
||||
# We want to end up with a Time object with one-day resolution. This is
|
||||
# the cleanest, most-readable, faster-than-using-Date way to do it.
|
||||
case date
|
||||
when String then
|
||||
@date = Time.parse date
|
||||
when Time then
|
||||
@date = Time.parse date.strftime("%Y-%m-%d")
|
||||
when Date then
|
||||
@date = Time.parse date.to_s
|
||||
else
|
||||
@date = Time.today
|
||||
end
|
||||
end
|
||||
|
||||
overwrite_accessor :date do
|
||||
self.date = nil if @date.nil? # HACK Sets the default value for date
|
||||
@date
|
||||
end
|
||||
|
||||
overwrite_accessor :summary= do |str|
|
||||
if str
|
||||
@summary = str.strip.gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ")
|
||||
end
|
||||
end
|
||||
|
||||
overwrite_accessor :description= do |str|
|
||||
if str
|
||||
@description = str.strip.gsub(/(\w-)\n[ \t]*(\w)/, '\1\2').gsub(/\n[ \t]*/, " ")
|
||||
end
|
||||
end
|
||||
|
||||
def files
|
||||
(@sources || []) | (@resources || []) | (@license_file ? [@license_file] : [])
|
||||
end
|
||||
|
||||
overwrite_accessor :intermediates_path do
|
||||
return @intermediates_path || name + '.build'
|
||||
end
|
||||
|
||||
overwrite_accessor :build_path do
|
||||
return @build_path || './' + name
|
||||
end
|
||||
=begin
|
||||
overwrite_accessor :test_files do
|
||||
# Handle the possibility that we have @test_suite_file but not @test_files. This will
|
||||
# happen when an old gem is loaded via YAML.
|
||||
if @test_suite_file
|
||||
@test_files = [@test_suite_file].flatten
|
||||
@test_suite_file = nil
|
||||
end
|
||||
@test_files ||= []
|
||||
end
|
||||
=end
|
||||
|
||||
# ------------------------- Predicates.
|
||||
|
||||
def loaded?; @loaded ? true : false ; end
|
||||
# def has_unit_tests?; not test_files.empty?; end
|
||||
|
||||
# ------------------------- Constructors.
|
||||
|
||||
##
|
||||
# Specification constructor. Assigns the default values to the
|
||||
# attributes, adds this spec to the list of loaded specs (see
|
||||
# Specification.list), and yields itself for further initialization.
|
||||
#
|
||||
def initialize
|
||||
# Each attribute has a default value (possibly nil). Here, we
|
||||
# initialize all attributes to their default value. This is done
|
||||
# through the accessor methods, so special behaviours will be honored.
|
||||
# Furthermore, we take a _copy_ of the default so each specification
|
||||
# instance has its own empty
|
||||
# arrays, etc.
|
||||
@@attributes.each do |name, default|
|
||||
self.send "#{name}=", copy_of(default)
|
||||
end
|
||||
@loaded = false
|
||||
@@list << self
|
||||
yield self if block_given?
|
||||
@@gather.call(self) if @@gather
|
||||
end
|
||||
=begin
|
||||
##
|
||||
# Special loader for YAML files. When a Specification object is loaded from a YAML file,
|
||||
# it bypasses the normal Ruby object initialization routine (#initialize). This method
|
||||
# makes up for that and deals with gems of different ages.
|
||||
#
|
||||
# 'input' can be anything that YAML.load() accepts: String or IO.
|
||||
#
|
||||
def Specification.from_yaml(input)
|
||||
spec = YAML.load(input)
|
||||
if(spec.class == FalseClass) then
|
||||
raise Gem::EndOfYAMLException
|
||||
end
|
||||
unless Specification === spec
|
||||
raise Gem::Exception, "YAML data doesn't evaluate to gem specification"
|
||||
end
|
||||
unless spec.instance_variable_get :@specification_version
|
||||
spec.instance_variable_set :@specification_version, NONEXISTENT_SPECIFICATION_VERSION
|
||||
end
|
||||
spec
|
||||
end
|
||||
=end
|
||||
|
||||
def BundleSpecification.load(filename)
|
||||
gemspec = nil
|
||||
fail "NESTED Specification.load calls not allowed!" if @@gather
|
||||
@@gather = proc { |gs| gemspec = gs }
|
||||
data = File.read(filename)
|
||||
eval(data)
|
||||
gemspec
|
||||
ensure
|
||||
@@gather = nil
|
||||
end
|
||||
|
||||
# ------------------------- Instance methods.
|
||||
|
||||
##
|
||||
# Returns the full name (name-version) of this Framework.
|
||||
#
|
||||
def full_name
|
||||
@name
|
||||
end
|
||||
|
||||
# ------------------------- Comparison methods.
|
||||
|
||||
##
|
||||
# Compare specs (name then version).
|
||||
#
|
||||
def <=>(other)
|
||||
[@name, @version] <=> [other.name, other.version]
|
||||
end
|
||||
|
||||
# Tests specs for equality (across all attributes).
|
||||
def ==(other)
|
||||
@@attributes.each do |name, default|
|
||||
return false unless self.send(name) == other.send(name)
|
||||
end
|
||||
true
|
||||
end
|
||||
=begin
|
||||
# ------------------------- Export methods (YAML and Ruby code).
|
||||
|
||||
# Returns an array of attribute names to be used when generating a YAML
|
||||
# representation of this object. If an attribute still has its default
|
||||
# value, it is omitted.
|
||||
def to_yaml_properties
|
||||
mark_version
|
||||
@@attributes.map { |name, default| "@#{name}" }
|
||||
end
|
||||
|
||||
# Returns a Ruby code representation of this specification, such that it
|
||||
# can be eval'ed and reconstruct the same specification later. Attributes
|
||||
# that still have their default values are omitted.
|
||||
def to_ruby
|
||||
mark_version
|
||||
result = "Gem::Specification.new do |s|\n"
|
||||
@@attributes.each do |name, default|
|
||||
# TODO better implementation of next line (read_only_attribute? ... something like that)
|
||||
next if name == :dependencies or name == :specification_version
|
||||
current_value = self.send(name)
|
||||
result << " s.#{name} = #{ruby_code(current_value)}\n" unless current_value == default
|
||||
end
|
||||
dependencies.each do |dep|
|
||||
version_reqs_param = dep.requirements_list.inspect
|
||||
result << " s.add_dependency(%q<#{dep.name}>, #{version_reqs_param})\n"
|
||||
end
|
||||
result << "end\n"
|
||||
end
|
||||
=end
|
||||
# ------------------------- Validation and normalization methods.
|
||||
|
||||
##
|
||||
# Checks that the specification contains all required fields, and
|
||||
# does a very basic sanity check.
|
||||
#
|
||||
# Raises InvalidSpecificationException if the spec does not pass
|
||||
# the checks..
|
||||
def validate
|
||||
=begin
|
||||
normalize
|
||||
if rubygems_version != RubyGemsVersion
|
||||
raise InvalidSpecificationException.new(%[
|
||||
Expected RubyGems Version #{RubyGemsVersion}, was #{rubygems_version}
|
||||
].strip)
|
||||
end
|
||||
=end
|
||||
@@required_attributes.each do |symbol|
|
||||
unless self.send(symbol)
|
||||
raise InvalidSpecificationException.new("Missing value for attribute #{symbol}")
|
||||
def Platform.flags(aPlatform)
|
||||
return PLATFORM_FLAGS[aPlatform]
|
||||
end
|
||||
end
|
||||
=begin
|
||||
if require_paths.empty?
|
||||
raise InvalidSpecificationException.new("Framework spec needs to have at least one require_path")
|
||||
end
|
||||
=end
|
||||
end
|
||||
|
||||
##
|
||||
# Normalize the list of files so that:
|
||||
# * All file lists have redundancies removed.
|
||||
# * Files referenced in the extra_rdoc_files are included in the package file list.
|
||||
#
|
||||
# Also, the summary and description are converted to a normal format.
|
||||
def normalize
|
||||
=begin
|
||||
if @extra_rdoc_files
|
||||
@extra_rdoc_files.uniq!
|
||||
@files ||= []
|
||||
@files.concat(@extra_rdoc_files)
|
||||
end
|
||||
=end
|
||||
@files.uniq! if @files
|
||||
end
|
||||
|
||||
def to_s
|
||||
"#<Framework::Specification name=#{@name} version=#{@version}>"
|
||||
end
|
||||
|
||||
def info_plist
|
||||
return { 'CPBundleName' => name, 'CPBundleIdentifier' => identifier, 'CPBundleInfoDictionaryVersion' => 6.0, 'CPBundleVersion' => version }
|
||||
end
|
||||
|
||||
private
|
||||
=begin
|
||||
def find_all_satisfiers(dep)
|
||||
Gem.source_index.each do |name,gem|
|
||||
if(gem.satisfies_requirement?(dep)) then
|
||||
yield gem
|
||||
end
|
||||
end
|
||||
end
|
||||
=end
|
||||
# Duplicate an object unless it's an immediate value.
|
||||
def copy_of(obj)
|
||||
case obj
|
||||
when Numeric, Symbol, true, false, nil then obj
|
||||
else obj.dup
|
||||
end
|
||||
end
|
||||
|
||||
# Return a string containing a Ruby code representation of the given object.
|
||||
def ruby_code(obj)
|
||||
case obj
|
||||
when String then '%q{' + obj + '}'
|
||||
when Array then obj.inspect
|
||||
when Gem::Version then obj.to_s.inspect
|
||||
when Date, Time then '%q{' + obj.strftime('%Y-%m-%d') + '}'
|
||||
when Numeric then obj.inspect
|
||||
when true, false, nil then obj.inspect
|
||||
when Gem::Version::Requirement then "Gem::Version::Requirement.new(#{obj.to_s.inspect})"
|
||||
else raise Exception, "ruby_code case not handled: #{obj.class}"
|
||||
end
|
||||
end
|
||||
|
||||
end # class BundleSpecification
|
||||
|
||||
end # module ObjectiveJ
|
||||
|
||||
@@ -525,17 +61,12 @@ def file_d(*args, &block)
|
||||
file fileTask.name => fileDirectory
|
||||
end
|
||||
|
||||
def bundle(spec, *args, &block)
|
||||
task = ObjectiveJ::BundleTask.define_task(*args, &block)
|
||||
task.bundle_spec = spec
|
||||
end
|
||||
|
||||
def resolve_flags(flags)
|
||||
|
||||
case flags
|
||||
when nil then ''
|
||||
when String then '-D' + flags
|
||||
when Array then flags.map { |flag| '-D' + flag }.join(' ')
|
||||
when Hash then flags.map { |flag, value| '-D' + flag + '=' + value }.join(' ')
|
||||
when Hash then flags.map { |flag, value| '-D' + flag + (value != '' ? '=' + value : '') }.join(' ')
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,176 +0,0 @@
|
||||
require 'rake'
|
||||
|
||||
|
||||
|
||||
module ObjectiveJ
|
||||
|
||||
class BundleTask < Rake::Task
|
||||
|
||||
PLATFORM_DIRECTORIES =
|
||||
{
|
||||
Platform::ObjJ => 'objj.platform',
|
||||
Platform::Rhino => 'rhino.platform',
|
||||
Platform::Browser => 'browser.platform',
|
||||
Platform::BrowserDesktop => 'browser-desktop.platform',
|
||||
Platform::BrowserIPhone => 'browser-iphone.platform'
|
||||
}
|
||||
|
||||
PLATFORM_FLAGS =
|
||||
{
|
||||
Platform::ObjJ => [],
|
||||
Platform::Rhino => ['PLATFORM_RHINO'],
|
||||
Platform::Browser => ['PLATFORM_BROWSER', 'PLATFORM_DOM'],
|
||||
Platform::BrowserDesktop => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_DESKTOP'],
|
||||
Platform::BrowserIPhone => ['PLATFORM_BROWSER', 'PLATFORM_DOM', 'PLATFORM_IPHONE', 'PLATFORM_MOBILE']
|
||||
}
|
||||
|
||||
# Objective-J Bundle spec containing the metadata for this bundle.
|
||||
attr_accessor :bundle_spec
|
||||
|
||||
def self.overwrite_accessor(name, &block)
|
||||
remove_method name
|
||||
define_method(name, &block)
|
||||
end
|
||||
|
||||
overwrite_accessor :bundle_spec= do |spec|
|
||||
|
||||
@bundle_spec = spec
|
||||
|
||||
@bundle_spec.validate
|
||||
|
||||
resources_path = File.join(@bundle_spec.build_path, 'Resources')
|
||||
copied_resources = []
|
||||
|
||||
# create file tasks for copied resources
|
||||
@bundle_spec.resources.each do |resource|
|
||||
|
||||
copied_resource = File.join(resources_path, File.basename(resource))
|
||||
|
||||
file_d copied_resource => [resource] do
|
||||
cp_r(resource, resources_path)
|
||||
end
|
||||
|
||||
copied_resources << copied_resource
|
||||
end
|
||||
|
||||
info_plist_path = @bundle_spec.build_path + '/Info.plist'
|
||||
info_plist = @bundle_spec.info_plist
|
||||
|
||||
info_plist['CPBundlePlatforms'] = @bundle_spec.platforms;
|
||||
|
||||
file_d info_plist_path do
|
||||
File.open(info_plist_path, 'w') do |file|
|
||||
file.puts info_plist.to_plist
|
||||
end
|
||||
end
|
||||
|
||||
preprocessed_files = []
|
||||
|
||||
# create file tasks for object files
|
||||
@bundle_spec.platforms.uniq.each do |platform|
|
||||
|
||||
executable_path = File.join(@bundle_spec.build_path, PLATFORM_DIRECTORIES[platform], @bundle_spec.name + '.sj')
|
||||
enhance([executable_path])
|
||||
|
||||
file_d executable_path do
|
||||
BundleTask.compact(@bundle_spec.build_path)
|
||||
end
|
||||
|
||||
# Yes its unfortunate that we need to regenerate the whole executable if the Info.plist changes. Oh well.
|
||||
file_d executable_path => info_plist_path
|
||||
|
||||
@bundle_spec.sources.each do |source|
|
||||
|
||||
preprocessed_file = File.join(@bundle_spec.build_path, PLATFORM_DIRECTORIES[platform], File.basename(source))
|
||||
|
||||
file_d preprocessed_file => source do
|
||||
IO.popen("objjc #{resolve_flags(@bundle_spec.flags)} #{resolve_flags(PLATFORM_FLAGS[platform])} #{source} -o #{preprocessed_file}") do |objjc|
|
||||
puts objjc.read
|
||||
end
|
||||
end
|
||||
|
||||
preprocessed_files << preprocessed_file
|
||||
|
||||
file_d executable_path => preprocessed_file
|
||||
end
|
||||
end
|
||||
|
||||
# copy license file
|
||||
license_path = nil
|
||||
|
||||
# check if a license type has been specified
|
||||
if @bundle_spec.license != nil
|
||||
|
||||
copied_license = @bundle_spec.build_path + '/LICENSE'
|
||||
|
||||
case @bundle_spec.license
|
||||
when License::LGPL_v2_1
|
||||
license_path = File.expand_path(File.join(File.dirname(__FILE__), '../LGPL-v2.1'))
|
||||
else
|
||||
license_path = license
|
||||
end
|
||||
|
||||
file_d copied_license => license_path do
|
||||
cp(license_path, copied_license)
|
||||
end
|
||||
end
|
||||
|
||||
enhance(preprocessed_files + copied_resources + [info_plist_path])
|
||||
end
|
||||
|
||||
def BundleTask.compact(path, *patterns)
|
||||
|
||||
puts 'Compacting ' + path
|
||||
|
||||
info_plist_path = File.join(path, 'Info.plist')
|
||||
info_plist = Plist::parse_xml(info_plist_path)
|
||||
|
||||
absolute_path = File.expand_path(path) + '/'
|
||||
|
||||
patterns = patterns.map { |pattern| "#{path}/#{pattern}" }
|
||||
|
||||
bundle_name = info_plist['CPBundleName']
|
||||
replaced_files = []
|
||||
|
||||
FileList.new(File.join(path, '**', '*.platform')).each do |platform|
|
||||
|
||||
FileList.new(File.join(platform, '*.j')) do |list|
|
||||
|
||||
list.include(*patterns)
|
||||
|
||||
executable_path = File.join(platform, bundle_name) + '.sj'
|
||||
platform_absolute_path = File.expand_path(platform) + '/'
|
||||
|
||||
File.open(executable_path, 'w+') do |executable|
|
||||
|
||||
executable.write '@STATIC;1.0;'
|
||||
|
||||
list.each do |fileName|
|
||||
|
||||
File.open(fileName) do |file|
|
||||
|
||||
if fileName.index(platform_absolute_path) == 0
|
||||
fileName = File.expand_path(fileName)[platform_absolute_path.length..-1]
|
||||
else
|
||||
fileName = File.expand_path(fileName)[absolute_path.length..-1]
|
||||
end
|
||||
|
||||
executable.write "p;#{fileName.length};#{fileName}#{file.read}"
|
||||
|
||||
replaced_files << fileName
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
info_plist['CPBundleReplacedFiles'] = replaced_files.uniq
|
||||
info_plist['CPBundleExecutable'] = bundle_name + '.sj'
|
||||
|
||||
File.open(info_plist_path, 'w') do |file|
|
||||
file.puts info_plist.to_plist
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user