filament 0.2.3 → 0.3.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 (42) hide show
  1. data/CHANGELOG +26 -0
  2. data/lib/filament/os.rb +77 -0
  3. data/lib/filament/package.rb +76 -26
  4. data/lib/filament/platform.rb +81 -78
  5. data/lib/filament/target.rb +50 -11
  6. data/lib/filament/util/filelist2.rb +10 -2
  7. data/lib/filament/util/fileutils.rb +1 -1
  8. data/lib/filament.rb +48 -24
  9. data/plugins/00util/lib/filament/plugins/util.rb +7 -7
  10. data/plugins/01java/lib/filament/java/mixins/classpath.rb +11 -0
  11. data/plugins/01java/lib/filament/java/tools/compile.rb +3 -1
  12. data/plugins/01java/lib/filament/java/tools/execute.rb +3 -1
  13. data/plugins/01java/lib/filament/java/tools/jar.rb +16 -12
  14. data/plugins/01java/lib/filament/java/tools/proguard.rb +2 -0
  15. data/plugins/01java/lib/filament/java/tools.rb +18 -18
  16. data/plugins/01java/lib/filament/plugins/java.rb +1 -1
  17. data/plugins/02javame/lib/filament/javame/library.rb +79 -16
  18. data/plugins/02javame/lib/filament/javame/suite.rb +75 -16
  19. data/plugins/02javame/lib/filament/javame/tasks/library_task.rb +190 -0
  20. data/plugins/02javame/lib/filament/javame/tools/emulator.rb +1 -1
  21. data/plugins/02javame/lib/filament/javame/tools/external/mpp_sdk.rb +0 -1
  22. data/plugins/02javame/lib/filament/javame/tools/external/wtk.rb +0 -1
  23. data/plugins/02javame/lib/filament/javame/{platform.rb → tools/platform.rb} +6 -5
  24. data/plugins/02javame/lib/filament/javame/tools/preverifier.rb +1 -1
  25. data/plugins/02javame/lib/filament/javame/tools.rb +1 -1
  26. data/plugins/02javame/lib/init.rb +6 -19
  27. data/plugins/04spin/lib/filament/spin/sji.rb +36 -0
  28. data/plugins/04spin/lib/filament/spin/tasks/sji_task.rb +86 -0
  29. data/plugins/04spin/lib/init.rb +4 -0
  30. data/plugins/04spin/lib/spin/sji.rb +339 -0
  31. data/plugins/05push/lib/filament/plugins/push.rb +3 -3
  32. data/plugins/10svn/lib/filament/plugins/svn.rb +3 -3
  33. data/plugins/10svn/lib/filament/scm/svn.rb +7 -13
  34. data/plugins/10svn/lib/init.rb +1 -1
  35. data/plugins/11http/lib/filament/plugins/http.rb +6 -0
  36. data/plugins/11http/lib/filament/scm/http.rb +67 -0
  37. data/plugins/11http/lib/init.rb +5 -0
  38. metadata +34 -8
  39. data/lib/filament/artifact.rb +0 -49
  40. data/plugins/01java/lib/filament/java/mixins/java_mixin.rb +0 -19
  41. data/plugins/02javame/lib/filament/javame/mixins/library_mixin.rb +0 -181
  42. data/plugins/02javame/lib/filament/javame/mixins/suite_mixin.rb +0 -114
data/CHANGELOG CHANGED
@@ -1,3 +1,29 @@
1
+ 0.3.0:
2
+ Filament:
3
+ - Updated Target#output to optionally take a block as output value
4
+ - Renamed Scm => SCM
5
+ - Created CompoundSCM to manage many SCMs
6
+ - Moved Filament::Platform module to Filament::OS
7
+ - Created Platform class, to manage platforms - use Platform.import(<yaml>)
8
+ - Replaced Artifact with Target
9
+ - FileList2 now has a tag attribute, allowing to set the tag it uses to resolve targets
10
+ - Added dependence on mechanize gem
11
+ - [FIXED] create scms with realpath, not package
12
+ HTTP Plugin:
13
+ - Uses mechanize to crawl a page for links
14
+ - Added plugin to manage pulling stuff from the web
15
+ - Future support may include pushing stuff to the web (over webdav)
16
+ Spin Plugin:
17
+ - Added libs for generating sji (both java and spin) interfaces
18
+ - creates a target with :java and :spin source outputs
19
+ - outputs a jad_proc to add entries for interpreter startup
20
+
21
+ Java Plugin:
22
+ - Dropped use of JAVAC, JAR, etc. to just use java_bin('javac'), etc.
23
+ JavaME Plugin:
24
+ - Merged Library and Suite functionality into a single rake tasklib
25
+ - Simplified Library and Suite artifacts
26
+
1
27
  0.2.3:
2
28
  SVN Plugin:
3
29
  - Fixed an svn include problem
@@ -0,0 +1,77 @@
1
+ module Filament::OS
2
+ TARGET_PLATFORMS = {}
3
+
4
+ def darwin?
5
+ return ! PLATFORM.index("darwin").nil?
6
+ end
7
+
8
+ def windows?
9
+ return cygwin?
10
+ end
11
+
12
+ def cygwin?
13
+ return ! PLATFORM.index("cygwin").nil?
14
+ end
15
+
16
+ def sys(c)
17
+ log c
18
+ raise "!!! Error executing '#{c}'" unless system(c)
19
+ end
20
+
21
+ def to_unix_path(path)
22
+ return nil if path.nil?
23
+ if cygwin?
24
+ return path unless /:\\/ === path
25
+ drive, path = path.split(":\\", 2)
26
+ path.gsub!(/\\/, '/')
27
+ return "/cygdrive/#{drive}/#{path}"
28
+ end
29
+ return path
30
+ end
31
+
32
+ def to_exec_path(path)
33
+ return nil if path.nil?
34
+ return to_unix_path(path) if cygwin?
35
+ return path
36
+ end
37
+
38
+ def to_windows_path(path)
39
+ return nil if path.nil?
40
+ if path.index('cygdrive').nil?
41
+ puts "#{path}\n"
42
+ return path
43
+ end
44
+
45
+ path = path.chomp.sub(/\/cygdrive\//, '')
46
+ drive, path = path.split(/\//, 2)
47
+
48
+ return "#{drive}:/#{path}"
49
+ end
50
+
51
+ def fix_paths(paths)
52
+ return nil if paths.nil?
53
+
54
+ if cygwin?
55
+ paths = paths.to_a.collect do |path|
56
+ to_windows_path(path)
57
+ end
58
+ end
59
+
60
+ return paths.to_a
61
+ end
62
+
63
+ def join_paths(paths)
64
+ return nil if paths.nil?
65
+
66
+ if windows?
67
+ joined = fix_paths(paths).join(';')
68
+ return "'#{joined}'"
69
+ end
70
+
71
+ return fix_paths(paths).join(':')
72
+ end
73
+
74
+ alias :u :to_unix_path
75
+ alias :w :to_windows_path
76
+ alias :fix :fix_paths
77
+ end
@@ -17,33 +17,72 @@ module Filament
17
17
  end
18
18
  end
19
19
 
20
- class PackageScm
21
- def self.applies?(package)
22
- return false
23
- end
24
-
25
- def initialize(package)
26
- @package = package
27
- end
20
+ module SCM
21
+ class Base
22
+ def self.applies?(path)
23
+ return false
24
+ end
28
25
 
29
- def revision; return nil; end
26
+ def initialize(path)
27
+ @realpath = Pathname.new(path)
28
+ raise "path must be absolute" unless @realpath.absolute?
29
+ end
30
+
31
+ def revision; return nil; end
32
+
33
+ def update; end
30
34
 
31
- def update
32
- @package.subpackages.each {|s| s.scm.update}
35
+ def status; end
36
+
37
+ def commit(msg); end
33
38
  end
34
39
 
35
- def status
36
- @package.subpackages.each {|s| s.scm.status}
40
+ class CompoundSCM
41
+ def initialize
42
+ @scms = []
43
+ end
44
+
45
+ def <<(scm)
46
+ @scms << scm
47
+ end
48
+
49
+ def update
50
+ @scms.each {|s| s.update}
51
+ end
52
+
53
+ def status
54
+ @scms.each {|s| s.status}
55
+ end
56
+
57
+ def commit(msg)
58
+ @scms.each {|s| s.commit(msg)}
59
+ end
60
+
61
+ def empty?
62
+ return @scms.empty?
63
+ end
37
64
  end
65
+
66
+ class PackageSCM
67
+ def initialize(package)
68
+ @package = package
69
+ end
70
+
71
+ def update
72
+ @package.subpackages.each {|s| s.scm.update}
73
+ end
38
74
 
39
- def commit(msg)
40
- @package.subpackages.each {|s| s.scm.commit(msg)}
75
+ def status
76
+ @package.subpackages.each {|s| s.scm.status}
77
+ end
78
+
79
+ def commit(msg)
80
+ @package.subpackages.each {|s| s.scm.commit(msg)}
81
+ end
41
82
  end
42
83
  end
43
84
 
44
85
  class Package
45
- include Memoize
46
-
47
86
  @@package_scms = []
48
87
  def self.scm(klass)
49
88
  @@package_scms << klass
@@ -53,12 +92,12 @@ module Filament
53
92
  klass.new(name, &block)
54
93
  end
55
94
 
95
+ attr_accessor2 :scm
96
+
56
97
  attr_reader :parent, :name, :realpath, :workspace, :package_resolver, :target_resolver, :build_context
57
98
  alias :pathname :realpath
58
99
 
59
100
  def initialize(h)
60
- memoize :scm
61
-
62
101
  @parent = h[:parent]
63
102
  @workspace = h[:workspace]
64
103
 
@@ -104,6 +143,8 @@ module Filament
104
143
 
105
144
  @execution_context = ExecutionContext.new(self)
106
145
  @build_context = BuildContext.new(self)
146
+
147
+ @scm = SCM::CompoundSCM.new
107
148
  end
108
149
 
109
150
  def exist?
@@ -293,12 +334,18 @@ module Filament
293
334
 
294
335
  # returns the scm for this package
295
336
  def scm
337
+ load
338
+
339
+ return @scm unless @scm.empty?
340
+
341
+ @scm << Filament::SCM::PackageSCM.new(self)
342
+
296
343
  @@package_scms.each do |scm|
297
- return scm.new(self) if scm.applies?(self)
344
+ @scm << scm.new(@realpath) if scm.applies?(self)
298
345
  end
299
346
 
300
347
  # default to the simplest scm
301
- return PackageScm.new(self)
348
+ return @scm
302
349
  end
303
350
 
304
351
  # executes cmd with this packages as the wd, and with $this_package set to self
@@ -317,7 +364,7 @@ module Filament
317
364
  end
318
365
 
319
366
  ### Target-related stuff
320
- def descriptor_loaded?
367
+ def loaded?
321
368
  return @descriptor_loaded
322
369
  end
323
370
 
@@ -330,14 +377,17 @@ module Filament
330
377
  return self
331
378
  end
332
379
 
333
- def load
334
- return if descriptor_loaded?
380
+ def load(fail_on_missing=false)
381
+ return if loaded?
335
382
  @descriptor_loaded = true
336
383
 
337
384
  pn = Pathname.new(descriptor)
338
385
  unless pn.exist?
339
- return if parent?
340
- raise "package descriptor for #{@realpath} does not exist '#{pn}'"
386
+ unless parent? or not fail_on_missing
387
+ raise "package descriptor for #{@realpath} does not exist '#{pn}'"
388
+ end
389
+
390
+ return
341
391
  end
342
392
 
343
393
  @execution_context.execute { instance_eval(pn.read, pn.realpath) }
@@ -1,79 +1,82 @@
1
- module Filament
2
- module Platform
3
- TARGET_PLATFORMS = {}
4
-
5
- def darwin?
6
- return ! PLATFORM.index("darwin").nil?
7
- end
8
-
9
- def windows?
10
- return cygwin?
11
- end
12
-
13
- def cygwin?
14
- return ! PLATFORM.index("cygwin").nil?
15
- end
16
-
17
- def sys(c)
18
- log c
19
- raise "!!! Error executing '#{c}'" unless system(c)
20
- end
21
-
22
- def to_unix_path(path)
23
- return nil if path.nil?
24
- if cygwin?
25
- return path unless /:\\/ === path
26
- drive, path = path.split(":\\", 2)
27
- path.gsub!(/\\/, '/')
28
- return "/cygdrive/#{drive}/#{path}"
29
- end
30
- return path
31
- end
32
-
33
- def to_exec_path(path)
34
- return nil if path.nil?
35
- return to_unix_path(path) if cygwin?
36
- return path
37
- end
38
-
39
- def to_windows_path(path)
40
- return nil if path.nil?
41
- if path.index('cygdrive').nil?
42
- puts "#{path}\n"
43
- return path
44
- end
45
-
46
- path = path.chomp.sub(/\/cygdrive\//, '')
47
- drive, path = path.split(/\//, 2)
48
-
49
- return "#{drive}:/#{path}"
50
- end
51
-
52
- def fix_paths(paths)
53
- return nil if paths.nil?
54
-
55
- if cygwin?
56
- paths = paths.to_a.collect do |path|
57
- to_windows_path(path)
58
- end
59
- end
60
-
61
- return paths.to_a
62
- end
63
-
64
- def join_paths(paths)
65
- return nil if paths.nil?
66
-
67
- if windows?
68
- joined = fix_paths(paths).join(';')
69
- return "'#{joined}'"
70
- end
71
-
72
- return fix_paths(paths).join(':')
73
- end
74
-
75
- alias :u :to_unix_path
76
- alias :w :to_windows_path
77
- alias :fix :fix_paths
78
- end
1
+ require 'yaml'
2
+
3
+ module Filament
4
+ class Platform
5
+ def self.property(*attrs)
6
+ attrs.each do |a|
7
+ attr_writer(a)
8
+ define_method(a) do
9
+ value = @attributes[a]
10
+ return value unless value.nil?
11
+ prototypes.each do |p|
12
+ value = p.send(a)
13
+ break if value.nil?
14
+ end
15
+ return value
16
+ end
17
+ end
18
+ end
19
+
20
+ def self.property_list(*attrs)
21
+ attrs.each do |a|
22
+ attr_writer(a)
23
+ define_method(a) do
24
+ value = @attributes[a] || []
25
+ value = value.to_a
26
+ prototypes.each {|p| value += p.send(a)}
27
+ return value
28
+ end
29
+ end
30
+ end
31
+
32
+ def self.import(data)
33
+ platforms = YAML.load(data)
34
+
35
+ platforms.each do |name, map|
36
+ attributes = {}
37
+ map.each do |key, value|
38
+ attributes[key.to_sym] = value
39
+ end
40
+
41
+ create(name, attributes)
42
+ end
43
+ end
44
+
45
+ def self.create(name, attributes)
46
+ name = name.to_sym
47
+
48
+ prototypes = attributes.delete(:inherit) || []
49
+ prototypes = prototypes.to_a
50
+
51
+ platform = new(name, prototypes, attributes)
52
+ @@platforms ||= {}
53
+ @@platforms[name] = platform
54
+ end
55
+
56
+ def self.find(h)
57
+ name = h[:name].to_sym
58
+
59
+ @@platforms ||= {}
60
+ return @@platforms[name]
61
+ end
62
+
63
+ property_list :tags, :classpath
64
+ property :javame_configuration, :javame_configuration_version
65
+
66
+ attr_reader :name
67
+
68
+ def prototypes
69
+ return @prototypes.collect {|p| Platform.find(:name => p)}
70
+ end
71
+
72
+ private
73
+ def initialize(name, prototypes, attributes)
74
+ @name = name
75
+ @attributes = attributes
76
+ @prototypes = prototypes
77
+
78
+ tags = @attributes[:tags] || []
79
+ @attributes[:tags] = tags.to_a.collect {|tag| tag.to_sym}
80
+ end
81
+ end
79
82
  end
@@ -28,7 +28,7 @@ module Filament
28
28
 
29
29
  @package = h[:package] || $context[:this_package]
30
30
  @invoked = false
31
- @block = block
31
+ @proc = Proc.new {}
32
32
  @outputs = {}
33
33
  @deployables = []
34
34
 
@@ -36,6 +36,27 @@ module Filament
36
36
  raise 'targets must have a package' if @package.nil?
37
37
 
38
38
  @package << self
39
+
40
+ init
41
+
42
+ @proc = Proc.new do
43
+ instance_eval(&block)
44
+ define
45
+ end
46
+ end
47
+
48
+ def init; end
49
+
50
+ def define; end
51
+
52
+ def working_dir(subdir=nil)
53
+ base = "#{$context[:working_dir]}/#{package.path}/#{name}"
54
+
55
+ return subdir.nil? ? base : "#{base}/#{subdir.to_s}"
56
+ end
57
+
58
+ def output_dir
59
+ return "#{$context[:output_dir]}/#{package.path}"
39
60
  end
40
61
 
41
62
  def uri
@@ -48,8 +69,9 @@ module Filament
48
69
  end
49
70
 
50
71
  # walks tree of dependencies, returns a complete list
51
- def flattened_deps
72
+ def flattened_deps(include_weak=false)
52
73
  all = @deps.to_a.clone
74
+ all += @weak_deps.to_a.clone if include_weak
53
75
 
54
76
  fd = []
55
77
  until all.empty?
@@ -57,33 +79,43 @@ module Filament
57
79
  unless fd.include?(d)
58
80
  fd << d
59
81
  all += d.deps
82
+ all += d.weak_deps if include_weak
60
83
  end
61
84
  end
62
85
  return fd
63
86
  end
64
87
 
65
88
  # adds some :output to the given :tag
89
+ # if a block is given, assume that's the output
66
90
  # if :deployable is true, also adds :output to deployables
67
- def output(h)
91
+ def output(h, &block)
68
92
  tag = h[:tag]
69
- output = h[:output]
93
+ h[:output] ||= block
70
94
  if tag.respond_to?(:to_ary)
71
95
  tag.to_ary.each do |t|
72
- output(:tag => t, :output => output)
96
+ h2 = h.clone
97
+ h2[:tag] = t
98
+ output(h2)
73
99
  end
74
100
  else
75
- @outputs[tag] = output
101
+ @outputs[tag] = h
76
102
  end
77
103
 
78
- @deployables << output if h[:deployable]
104
+ @deployables << h[:output] if h[:deployable]
79
105
  end
80
106
 
81
107
  # returns the value in the output hash for the given tag
82
- def get_output(tag)
108
+ def [](tag)
83
109
  invoke
84
- return @outputs[tag]
110
+
111
+ o = @outputs[tag]
112
+
113
+ return nil if o.nil?
114
+
115
+ tasks = o[:tasks]
116
+ tasks.each {|t| t.invoke} unless tasks.nil?
117
+ return o[:output]
85
118
  end
86
- alias :[] :get_output
87
119
 
88
120
  # builds this specific target (and all dependencies)
89
121
  # after building, it executes the provided block in the build context
@@ -106,8 +138,15 @@ module Filament
106
138
  @package.execute do
107
139
  @weak_deps.each {|t| t.invoke}
108
140
  @deps.each {|t| t.invoke}
141
+
109
142
  puts ">>> BUILDING #{uri} (#{@package.pathname}, #{self})"
110
- instance_eval(&@block)
143
+ instance_eval(&@proc)
144
+
145
+ @outputs.values.select{|h| h.key?(:tasks)}.collect{|h| h[:tasks]}.each do |tasks|
146
+ tasks.each do |t|
147
+ t.invoke
148
+ end
149
+ end
111
150
  end
112
151
  end
113
152
  end
@@ -2,21 +2,29 @@ require 'filament/target'
2
2
 
3
3
  module Filament
4
4
  class FileList2 < FileList
5
+ attr_accessor :tag
6
+ attr_reader :targets
7
+
5
8
  def initialize(*args)
6
9
  super(*args)
7
10
  @target_resolver = $context[:target_resolver]
11
+ @tag = :default
12
+ @targets = []
8
13
  end
9
14
 
10
15
  def resolve_filament_uris(*entries)
11
16
  files = []
12
17
  entries.each do |entry|
13
18
  if entry.respond_to? :to_ary
14
- resolve_uris(*entry.to_ary)
19
+ resolve_filament_uris(*entry.to_ary)
15
20
  else
16
21
  if @target_resolver.valid_uri?(entry)
17
22
  target = @target_resolver.resolve(entry)
23
+
18
24
  raise "target does not exist: #{entry}" if target.nil?
19
- files << target[:default]
25
+ @targets << target
26
+
27
+ include(*target[@tag].to_a)
20
28
  else
21
29
  files << entry
22
30
  end
@@ -2,7 +2,7 @@ require 'fileutils'
2
2
  require 'pathname'
3
3
 
4
4
  module Filament
5
- def cp_r_if(src, dest, &block)
5
+ def self.cp_r_if(src, dest, &block)
6
6
  src_p = Pathname.new(src)
7
7
  dest_p = Pathname.new(dest)
8
8