filament 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. data/CHANGES +96 -0
  2. data/README +2 -2
  3. data/lib/filament.rb +1 -1
  4. data/lib/filament/block_object.rb +11 -0
  5. data/lib/filament/os.rb +0 -3
  6. data/lib/filament/platform.rb +16 -0
  7. data/lib/filament/resolver.rb +2 -1
  8. data/lib/filament/target.rb +118 -10
  9. data/lib/filament/util/filelist2.rb +1 -1
  10. data/lib/filament/util/lazy_list.rb +9 -9
  11. data/plugins/00util/lib/filament/plugins/util.rb +18 -0
  12. data/plugins/01java/lib/filament/java/library.rb +88 -0
  13. data/plugins/{02javame/lib/filament/javame → 01java/lib/filament/java}/tasks/library_task.rb +86 -63
  14. data/plugins/01java/lib/filament/java/tools.rb +1 -0
  15. data/plugins/01java/lib/filament/java/tools/compile.rb +2 -2
  16. data/plugins/01java/lib/filament/java/tools/execute.rb +16 -9
  17. data/plugins/01java/lib/filament/java/tools/jar.rb +1 -1
  18. data/plugins/01java/lib/filament/java/tools/javadoc.rb +22 -0
  19. data/plugins/01java/lib/filament/java/tools/proguard.rb +1 -0
  20. data/plugins/{02javame → 01java}/lib/filament/javame/suite.rb +20 -22
  21. data/plugins/{02javame → 01java}/lib/filament/javame/tasks.rb +0 -1
  22. data/plugins/{02javame → 01java}/lib/filament/javame/tools.rb +0 -1
  23. data/plugins/{02javame → 01java}/lib/filament/javame/tools/descriptor.rb +19 -7
  24. data/plugins/{02javame → 01java}/lib/filament/javame/tools/emulator.rb +0 -1
  25. data/plugins/{02javame → 01java}/lib/filament/javame/tools/external/mpp_sdk.rb +0 -0
  26. data/plugins/{02javame → 01java}/lib/filament/javame/tools/external/wtk.rb +0 -0
  27. data/plugins/{02javame → 01java}/lib/filament/javame/tools/preverifier.rb +0 -2
  28. data/plugins/01java/lib/filament/javase/application.rb +43 -0
  29. data/plugins/01java/lib/filament/javase/tasks.rb +1 -0
  30. data/plugins/01java/lib/init.rb +16 -0
  31. data/plugins/04spin/lib/filament/spin/sji.rb +17 -19
  32. data/plugins/04spin/lib/filament/spin/tasks/sji_task.rb +11 -10
  33. data/plugins/04spin/lib/spin/sji.rb +371 -170
  34. data/plugins/05push/lib/filament/plugins/push.rb +6 -9
  35. data/plugins/05push/lib/filament/push.rb +1 -1
  36. data/plugins/05push/lib/filament/push/conduits/filter_conduit.rb +1 -1
  37. metadata +74 -64
  38. data/CHANGELOG +0 -81
  39. data/plugins/02javame/lib/filament/javame/library.rb +0 -79
  40. data/plugins/02javame/lib/filament/javame/tools/platform.rb +0 -50
  41. data/plugins/02javame/lib/init.rb +0 -14
data/CHANGES ADDED
@@ -0,0 +1,96 @@
1
+ 0.4.0:
2
+ Filament:
3
+ * LazyList accepts multiple arguments, instead of requiring an array
4
+ * [FIXED] BUILDING message is now accurate
5
+ * Added task command to execute a rake task, after invoking the given targets
6
+ * Added on_define method to Target, its instances, and all subclasses
7
+ * Added tag.tag_name support for conditional definitions
8
+ * Added options hash to all targets
9
+ * Added src_dir function
10
+ * Moved all platform code to Filament, out of JavaME Plugin
11
+ * [FIXED] FileList2 bug with 'include' on Arrays
12
+ Spin Plugin:
13
+ * java_method accepts a trailing hash, for cleaner files
14
+ * java_member now implemented
15
+ * added java_class to complement spin_prototype
16
+
17
+ 0.3.0:
18
+ Filament:
19
+ * Updated Target#output to optionally take a block as output value
20
+ * Renamed Scm => SCM
21
+ * Created CompoundSCM to manage many SCMs
22
+ * Moved Filament::Platform module to Filament::OS
23
+ * Created Platform class, to manage platforms * use Platform.import(<yaml>)
24
+ * Replaced Artifact with Target
25
+ * FileList2 now has a tag attribute, allowing to set the tag it uses to resolve targets
26
+ * Added dependence on mechanize gem
27
+ * [FIXED] create scms with realpath, not package
28
+ HTTP Plugin:
29
+ * Uses mechanize to crawl a page for links
30
+ * Added plugin to manage pulling stuff from the web
31
+ * Future support may include pushing stuff to the web (over webdav)
32
+ Spin Plugin:
33
+ * Added libs for generating sji (both java and spin) interfaces
34
+ * creates a target with :java and :spin source outputs
35
+ * outputs a jad_proc to add entries for interpreter startup
36
+ Java Plugin:
37
+ * Dropped use of JAVAC, JAR, etc. to just use java_bin('javac'), etc.
38
+ JavaME Plugin:
39
+ * Merged Library and Suite functionality into a single rake tasklib
40
+ * Simplified Library and Suite artifacts
41
+
42
+ 0.2.3:
43
+ SVN Plugin:
44
+ * Fixed an svn include problem
45
+ * Fixed the svn commands to work with new package.scm
46
+
47
+ 0.2.2:
48
+ Filament:
49
+ * Fixed handling for scm actions for packages without scm
50
+
51
+ 0.2.1:
52
+ Filament:
53
+ * Added ability to create workspace, package
54
+ * Added ability to checkout (and create) a package
55
+ * Can now execute the filament command outside a workspace
56
+ * Moved svn parts to PackageScm
57
+ * Supports in place to work with other forms of version control
58
+
59
+ 0.2.0:
60
+ Filament:
61
+ * removed old tests
62
+ * Using cmdparse gem; One action per command
63
+ * added dependency on memoize gem
64
+ * general cleanup
65
+ All Plugins:
66
+ * Plugins now extend Filament::Plugin where necessary
67
+ JavaME Plugin:
68
+ * Moved vendor-specific stuff to tasks.rb in //vendor/libraries/javame
69
+ SVN Plugin:
70
+ * Created svn plugin, should make it easier to support other version control schemes in the future
71
+
72
+ 0.1.2:
73
+ JavaME Plugin:
74
+ * Changed the default for obfuscating JavaME::Suite targets to false.
75
+
76
+ 0.1.1:
77
+ Filament:
78
+ * Packages can't be hidden directories now
79
+ * Doesn't force working_dir and output_dir creation
80
+ * Package descriptor is now /package.rb instead of rakefile.rb
81
+ * package.rb is now evaluated within the scope of the Package object.
82
+ * targets are now defined by target(name, class, &block)
83
+ * future cleanups code cleanups will benefit from the two above items.
84
+ All Plugins:
85
+ * Updated external path references (Wtk, MppSdk, Proguard classes) to only use ENV
86
+ * Added ENV support for WTK_HOME, MPP_SDK_HOME, PROGUARD_HOME
87
+ Java Plugin:
88
+ * Added support for Proguard obfuscation
89
+ * Targets can output a 1-argument-block tagged :proguard and configure the obfuscator for dependencies
90
+ JavaME Plugin:
91
+ * Suite now takes itself into account when traversing deps for :jad_config outputs
92
+ * Obfuscation is available if you set obfuscate to true -- will auto-detect in the future
93
+
94
+ 0.1.0:
95
+ Filament:
96
+ * Initial Release
data/README CHANGED
@@ -1,7 +1,7 @@
1
- Filament is a new spin on an old idea. Combine dependency-resolution, lazy-binding and rake (a ruby-based make alternative) and you get filament. Filament workspaces are a simple, cross-platform approach to managing complex build needs.
1
+ Combine dependency-resolution, lazy-binding and rake (a ruby-based make alternative) and you get filament. Filament workspaces are a simple, cross-platform approach to managing complex build needs.
2
2
 
3
3
  I created it satisfy my needs as a mobile application developer.
4
4
 
5
- I am currently managing 20 inter-dependent libraries for a suite of JavaME platforms using only filament, its stock plugins, and minor dependencies.
5
+ I am currently managing a number of inter-dependent libraries for a suite of JavaME platforms using only filament, its stock plugins, and minor dependencies.
6
6
 
7
7
  This tool has been developed and tested on Ruby 1.8.4, Rake 0.7, Cygwin (XP sp2), OS X 10.4.5, and Gentoo Linux.
@@ -92,7 +92,7 @@ module Filament
92
92
  def initialize
93
93
  @cmd = CmdParse::CommandParser.new(true)
94
94
  @cmd.program_name = "filament"
95
- @cmd.program_version = [0, 3, 0]
95
+ @cmd.program_version = [0, 4, 0]
96
96
  @cmd.add_command(CmdParse::HelpCommand.new)
97
97
  @cmd.add_command(CmdParse::VersionCommand.new)
98
98
  @cmd.options = CmdParse::OptionParserWrapper.new do |opt|
@@ -0,0 +1,11 @@
1
+ module Filament
2
+ class BlockObject
3
+ def initialize(&p)
4
+ @proc = p
5
+ end
6
+
7
+ def method_missing(sym, *args, &p)
8
+ @proc.call(sym, args, p)
9
+ end
10
+ end
11
+ end
@@ -1,6 +1,4 @@
1
1
  module Filament::OS
2
- TARGET_PLATFORMS = {}
3
-
4
2
  def darwin?
5
3
  return ! PLATFORM.index("darwin").nil?
6
4
  end
@@ -38,7 +36,6 @@ module Filament::OS
38
36
  def to_windows_path(path)
39
37
  return nil if path.nil?
40
38
  if path.index('cygdrive').nil?
41
- puts "#{path}\n"
42
39
  return path
43
40
  end
44
41
 
@@ -1,6 +1,8 @@
1
1
  require 'yaml'
2
2
 
3
3
  module Filament
4
+ TAGS = {}
5
+
4
6
  class Platform
5
7
  def self.property(*attrs)
6
8
  attrs.each do |a|
@@ -69,6 +71,20 @@ module Filament
69
71
  return @prototypes.collect {|p| Platform.find(:name => p)}
70
72
  end
71
73
 
74
+ def classpath
75
+ base_classpath = @attributes[:classpath]
76
+
77
+ classpath = []
78
+ classpath += base_classpath unless base_classpath.nil?
79
+
80
+ tags.each do |tag|
81
+ tag_classpath = TAGS[tag]
82
+ classpath += tag_classpath unless tag_classpath.nil?
83
+ end
84
+
85
+ return classpath
86
+ end
87
+
72
88
  private
73
89
  def initialize(name, prototypes, attributes)
74
90
  @name = name
@@ -48,9 +48,10 @@ module Filament
48
48
  @package_resolver = @package.package_resolver
49
49
  end
50
50
 
51
- def valid_uri?(path)
51
+ def valid?(path)
52
52
  return FULL_REGEX === path || TARGET_REGEX === path || PACKAGE_REGEX === path
53
53
  end
54
+ alias :valid_uri? :valid?
54
55
 
55
56
  def resolve(uri)
56
57
  package_path = nil
@@ -1,4 +1,5 @@
1
1
  require 'filament/util/lazy_list'
2
+ require 'set'
2
3
 
3
4
  module Filament
4
5
  class TargetList < LazyList
@@ -8,8 +9,44 @@ module Filament
8
9
  end
9
10
  end
10
11
 
12
+ module SrcUtil
13
+ def files(h)
14
+ tags = h[:tags]
15
+ suffix = h[:suffix] || '.*'
16
+ dir = h[:dir] || "#{h[:base_dir]}/#{h[:sub_dir]}"
17
+ wildcard = h[:wildcard] || "**/*#{suffix}"
18
+
19
+ list = []
20
+ p = Pathname.new(dir)
21
+ if p.exist?
22
+ p.children.each do |child|
23
+ if tags.include?(child.basename.to_s.to_sym)
24
+ list += FileList[child + wildcard].to_a
25
+ end
26
+ end
27
+ end
28
+
29
+ return list
30
+ end
31
+
32
+ def src_files(h)
33
+ h[:base_dir] ||= 'src'
34
+ h[:tags] ||= platform.tags + [:all]
35
+ return files(h)
36
+ end
37
+
38
+ def res_files(h)
39
+ h[:sub_dir] ||= 'res'
40
+ return src_files(h)
41
+ end
42
+
43
+ def src_dir(dir)
44
+ return src_files(:dir => dir)
45
+ end
46
+ end
47
+
11
48
  class Target
12
- attr_reader :name, :package, :weak_deps, :deps, :deployables
49
+ attr_reader :name, :package, :weak_deps, :deps, :deployables, :platform, :tag
13
50
 
14
51
  def initialize(args, &block)
15
52
  if args.is_a? Hash
@@ -30,28 +67,92 @@ module Filament
30
67
  @invoked = false
31
68
  @proc = Proc.new {}
32
69
  @outputs = {}
33
- @deployables = []
34
-
70
+ @options = {}
71
+ @deployables = Set.new
72
+ @on_define_procs = []
73
+ @on_init_procs = []
74
+
75
+ @platform = Filament::Platform.find(:name => $target_platform)
76
+ @tag = Filament::BlockObject.new do |sym, a, p|
77
+ tags = @platform.tags
78
+ if tags.member?(sym)
79
+ p.call unless p.nil?
80
+ end
81
+
82
+ tags.member?(sym)
83
+ end
84
+
35
85
  raise 'targets must have a name' if @name.nil?
36
86
  raise 'targets must have a package' if @package.nil?
37
87
 
38
- @package << self
39
-
88
+ @package << self
40
89
  init
41
90
 
42
91
  @proc = Proc.new do
43
92
  instance_eval(&block)
44
- define
93
+ on_init
94
+ on_define
95
+ end
96
+ end
97
+
98
+ def assert_tag(*tags)
99
+ tags -= platform.tags
100
+ raise "target #{uri} requires platform tags: #{tags.join(', ')}" unless tags.empty?
101
+ end
102
+
103
+ def options(h=nil)
104
+ return @options if h.nil?
105
+ @options.merge!(h)
106
+ end
107
+
108
+ def on_define(&block)
109
+ unless block.nil?
110
+ @on_define_procs << block
111
+ else
112
+ @on_define_procs.each { |p| p.call(self) }
113
+ self.class.on_define(self)
45
114
  end
46
115
  end
47
116
 
48
- def init; end
117
+ def self.on_define(target=nil, &block)
118
+ @@on_define_procs ||= {}
119
+ @@on_define_procs[self] ||= []
120
+
121
+ unless block.nil?
122
+ raise "if a block is given, target cannot be specified" unless target.nil?
123
+ @@on_define_procs[self] << block
124
+ else
125
+ raise "if a block is not given, target cannot be nil" if target.nil?
126
+ superclass.on_define(target) if superclass.respond_to?(:on_define)
127
+ @@on_define_procs[self].each{ |p| p.call(target) }
128
+ end
129
+ end
49
130
 
50
- def define; end
131
+ def on_init(&block)
132
+ unless block.nil?
133
+ @on_init_procs << block
134
+ else
135
+ @on_init_procs.each { |p| p.call(self) }
136
+ self.class.on_init(self)
137
+ end
138
+ end
139
+
140
+ def self.on_init(target=nil, &block)
141
+ @@on_init_procs ||= {}
142
+ @@on_init_procs[self] ||= []
51
143
 
144
+ unless block.nil?
145
+ raise "if a block is given, target cannot be specified" unless target.nil?
146
+ @@on_init_procs[self] << block
147
+ else
148
+ raise "if a block is not given, target cannot be nil" if target.nil?
149
+ superclass.on_init(target) if superclass.respond_to?(:on_init)
150
+ @@on_init_procs[self].each{ |p| p.call(target) }
151
+ end
152
+ end
153
+
52
154
  def working_dir(subdir=nil)
53
155
  base = "#{$context[:working_dir]}/#{package.path}/#{name}"
54
-
55
156
  return subdir.nil? ? base : "#{base}/#{subdir.to_s}"
56
157
  end
57
158
 
@@ -85,6 +186,13 @@ module Filament
85
186
  return fd
86
187
  end
87
188
 
189
+ def collect_outputs(tag)
190
+ o = flattened_deps.collect{|dep| dep[tag]}
191
+ o << self[tag]
192
+ o.compact!
193
+ return o
194
+ end
195
+
88
196
  # adds some :output to the given :tag
89
197
  # if a block is given, assume that's the output
90
198
  # if :deployable is true, also adds :output to deployables
@@ -139,9 +247,9 @@ module Filament
139
247
  @weak_deps.each {|t| t.invoke}
140
248
  @deps.each {|t| t.invoke}
141
249
 
142
- puts ">>> BUILDING #{uri} (#{@package.pathname}, #{self})"
143
250
  instance_eval(&@proc)
144
251
 
252
+ puts ">>> BUILDING #{uri} (#{@package.pathname}, #{self})"
145
253
  @outputs.values.select{|h| h.key?(:tasks)}.collect{|h| h[:tasks]}.each do |tasks|
146
254
  tasks.each do |t|
147
255
  t.invoke
@@ -16,7 +16,7 @@ module Filament
16
16
  files = []
17
17
  entries.each do |entry|
18
18
  if entry.respond_to? :to_ary
19
- resolve_filament_uris(*entry.to_ary)
19
+ files += resolve_filament_uris(*entry.to_ary)
20
20
  else
21
21
  if @target_resolver.valid_uri?(entry)
22
22
  target = @target_resolver.resolve(entry)
@@ -12,16 +12,16 @@ class LazyList
12
12
  end
13
13
  end
14
14
 
15
- def include(entry_name)
16
- if entry_name.respond_to?(:to_ary)
17
- entry_name.to_ary.each do |t|
18
- include(t)
19
- end
20
- else
21
- if entry_resolved?(entry_name)
22
- @resolved << entry_name
15
+ def include(*entry_names)
16
+ entry_names.each do |entry_name|
17
+ if entry_name.respond_to?(:to_ary)
18
+ self.include(*entry_name.to_ary)
23
19
  else
24
- @unresolved << entry_name
20
+ if entry_resolved?(entry_name)
21
+ @resolved << entry_name
22
+ else
23
+ @unresolved << entry_name
24
+ end
25
25
  end
26
26
  end
27
27
  return self
@@ -1,9 +1,26 @@
1
+ require 'rake'
1
2
  require 'cmdparse'
2
3
  require 'filament/plugin'
3
4
 
4
5
  module Filament::Plugins
5
6
  class Util < Filament::Plugin
6
7
  def initialize(app)
8
+ app.subcommand('task', "Executes the given task") do |args|
9
+ resolver = $context[:target_resolver]
10
+ targets, tasks = args.partition { |arg| resolver.valid?(arg) }
11
+
12
+ targets = Filament::TargetList.new(targets)
13
+
14
+ targets.each do |target|
15
+ target.build do
16
+ target.invoke
17
+ end
18
+ end
19
+
20
+ tasks.collect! { |task| Rake::Task[task] }
21
+ tasks.each { |task| task.invoke }
22
+ end
23
+
7
24
  app.subcommand('build', "Build the given targets") do |args|
8
25
  targets = Filament::TargetList.new(*args)
9
26
  targets.each { |target| target.build }
@@ -24,6 +41,7 @@ module Filament::Plugins
24
41
  end
25
42
  end
26
43
 
44
+
27
45
  app.subcommand('targets', "Shows targets of given package") do |args|
28
46
  packages = Filament::PackageList.new(*args)
29
47
  packages.each do |package|
@@ -0,0 +1,88 @@
1
+ require 'filament/block_object'
2
+ require 'filament/java/mixins/classpath'
3
+ require 'filament/java/tasks/library_task'
4
+
5
+ module Filament::Java
6
+ class Library < Filament::Target
7
+ include Filament::Java::Mixins::Classpath
8
+ include Filament::SrcUtil
9
+
10
+ attr_accessor2 :obfuscate, :jvm_source_version, :jvm_target_version
11
+
12
+ attr_writer :should_package_deps
13
+ attr_reader :srcs, :resources
14
+
15
+ def custom_entries(h)
16
+ @custom_entries.merge!(h)
17
+ end
18
+
19
+ def append_entries(h)
20
+ h.keys.each do |key|
21
+ @append_entries[key] ||= []
22
+ entry = h[key]
23
+ if entry.is_a?(Array)
24
+ @append_entries[key] += entry
25
+ else
26
+ @append_entries[key] << entry
27
+ end
28
+ end
29
+ end
30
+
31
+ def init
32
+ @append_entries = {}
33
+ @custom_entries = {}
34
+
35
+ @srcs = Filament::FileList2.new
36
+ @srcs.tag = :java
37
+
38
+ @resources = Filament::FileList2.new
39
+ @should_package_deps = false
40
+
41
+ @bootclasspath = @platform.classpath || []
42
+ @custom_classpath = []
43
+
44
+ if tag.javame
45
+ @jvm_source_version = 1.2
46
+ @jvm_target_version = 1.2
47
+ @cldc_version = platform.javame_configuration_version
48
+ raise "cldc_version not defined for platform: #{platform.name}" if @cldc_version.nil?
49
+ end
50
+
51
+ on_define do
52
+ @library = Filament::Java::Tasks::LibraryTask.new do |l|
53
+ define_library(l)
54
+ end
55
+
56
+ task :build => @library.tasks
57
+
58
+ output :tag => [:default, :jar],
59
+ :output => @library.jar_path,
60
+ :deployable => true,
61
+ :tasks => @library.tasks
62
+
63
+ output :tag => :append_entries,
64
+ :output => @append_entries
65
+ output :tag => :custom_entries,
66
+ :output => @custom_entries
67
+ end
68
+ end
69
+
70
+ def define_library(l)
71
+ l.working_dir = working_dir
72
+ l.output_dir = output_dir
73
+ l.name = name
74
+ l.classpath = classpath
75
+ l.should_preverify = tag.javame
76
+ l.jvm_source_version = @jvm_source_version
77
+ l.jvm_target_version = @jvm_target_version
78
+ l.cldc_version = @cldc_version
79
+ l.bootclasspath = @bootclasspath
80
+ l.srcs = @srcs + @deps.collect{ |d| d[:java] }.compact.flatten
81
+ l.resources = @resources + res_files(:wildcard => '*') + (@should_package_deps ? flattened_deps_jars : [])
82
+ l.task_deps << package.descriptor
83
+ l.proguard_proc = Proc.new do |o|
84
+ flattened_deps.collect{ |dep| dep[:proguard_proc] }.compact.each{|p| p.call(o)}
85
+ end
86
+ end
87
+ end
88
+ end