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/lib/filament.rb CHANGED
@@ -1,7 +1,6 @@
1
1
  require 'pathname'
2
2
  require 'set'
3
3
 
4
-
5
4
  # rake stuff
6
5
  begin
7
6
  require 'rake'
@@ -19,16 +18,11 @@ end
19
18
 
20
19
  require 'rake/clean'
21
20
 
22
- require 'filament/workspace'
23
- require 'filament/platform'
24
- require 'filament/package'
25
- require 'filament/target'
26
- require 'filament/artifact'
27
-
28
- require 'filament/util/filelist2'
29
- require 'filament/util/fileutils'
30
-
31
21
  class Module
22
+ # creates a reader and a writer for the given attributes.
23
+ # both reader and writer are the same method. if the method
24
+ # is called without arguments, the current value is returned
25
+ # if it is called with a single arguemnt, the value is set.
32
26
  def attr_accessor2(*symbols)
33
27
  # attr_writer(*symbols)
34
28
  symbols.each do |sym|
@@ -37,23 +31,57 @@ class Module
37
31
  if val.empty?
38
32
  return instance_variable_get(attr_sym)
39
33
  else
40
- return instance_variable_set(attr_sym, val.first)
34
+ val = val.first if val.size == 1
35
+ return instance_variable_set(attr_sym, val)
41
36
  end
42
37
  end
43
38
  end
44
39
  end
40
+
41
+ # temporarily intercepts a given method, evaluating the
42
+ # given block
43
+ def intercept_method(method, temporary_result)
44
+ original_method = "#{Time.now.to_i}_#{method}"
45
+ alias_method original_method, method
46
+
47
+ # Not enough room for a ternary ;_;
48
+ t = if temporary_result.respond_to?(:to_proc)
49
+ temporary_result.to_proc
50
+ else
51
+ Proc.new { temporary_result }
52
+ end
53
+
54
+ define_method(method, t)
55
+ yield
56
+ alias_method method, original_method
57
+ end
58
+ end
59
+
60
+ require 'filament/workspace'
61
+ require 'filament/os'
62
+ require 'filament/package'
63
+ require 'filament/target'
64
+
65
+ require 'filament/util/filelist2'
66
+ require 'filament/util/fileutils'
67
+
68
+ def log(msg)
69
+ puts msg if $verbose
70
+ end
71
+
72
+ def verbose(on)
73
+ RakeFileUtils.verbose(false)
74
+ $verbose = on
45
75
  end
46
76
 
47
77
  module Filament
48
- def log(msg)
49
- puts msg if $verbose
50
- end
51
-
52
- def verbose(on)
53
- RakeFileUtils.verbose(false)
54
- $verbose = on
78
+ class Task
79
+ def work(s)
80
+ d = @working_dir + '/' + s.to_s
81
+ directory d
82
+ return d
83
+ end
55
84
  end
56
-
57
85
  class Application
58
86
  @@plugins = []
59
87
 
@@ -64,7 +92,7 @@ module Filament
64
92
  def initialize
65
93
  @cmd = CmdParse::CommandParser.new(true)
66
94
  @cmd.program_name = "filament"
67
- @cmd.program_version = [0, 2, 3]
95
+ @cmd.program_version = [0, 3, 0]
68
96
  @cmd.add_command(CmdParse::HelpCommand.new)
69
97
  @cmd.add_command(CmdParse::VersionCommand.new)
70
98
  @cmd.options = CmdParse::OptionParserWrapper.new do |opt|
@@ -185,7 +213,3 @@ module Filament
185
213
  end
186
214
  end
187
215
  end
188
-
189
- include Filament::Platform
190
- include Filament
191
-
@@ -2,20 +2,20 @@ require 'cmdparse'
2
2
  require 'filament/plugin'
3
3
 
4
4
  module Filament::Plugins
5
- class Util < Plugin
5
+ class Util < Filament::Plugin
6
6
  def initialize(app)
7
7
  app.subcommand('build', "Build the given targets") do |args|
8
- targets = TargetList.new(*args)
8
+ targets = Filament::TargetList.new(*args)
9
9
  targets.each { |target| target.build }
10
10
  end
11
11
 
12
12
  app.subcommand('clobber', "Clobber the generated files for the given packages") do |args|
13
- packages = PackageList.new(*args)
13
+ packages = Filament::PackageList.new(*args)
14
14
  packages.each { |package| package.clobber }
15
15
  end
16
16
 
17
17
  app.subcommand('execute', "Executes the target, if it is executable") do |args|
18
- targets = TargetList.new(*args)
18
+ targets = Filament::TargetList.new(*args)
19
19
  targets.each do |target|
20
20
  target.build do
21
21
  block = target[:execute]
@@ -25,7 +25,7 @@ module Filament::Plugins
25
25
  end
26
26
 
27
27
  app.subcommand('targets', "Shows targets of given package") do |args|
28
- packages = PackageList.new(*args)
28
+ packages = Filament::PackageList.new(*args)
29
29
  packages.each do |package|
30
30
  puts " #{package.full_name}"
31
31
  package.targets.each do |target|
@@ -35,7 +35,7 @@ module Filament::Plugins
35
35
  end
36
36
 
37
37
  app.subcommand('prereqs', "Shows prerequisites of given packages") do |args|
38
- targets = TargetList.new(*args)
38
+ targets = Filament::TargetList.new(*args)
39
39
  targets.each do |target|
40
40
  puts " #{target.uri}"
41
41
  target.deps.each do |dep|
@@ -45,7 +45,7 @@ module Filament::Plugins
45
45
  end
46
46
 
47
47
  app.subcommand('list', "Lists subpackages of given packages") do |args|
48
- packages = PackageList.new(*args)
48
+ packages = Filament::PackageList.new(*args)
49
49
  packages.each do |package|
50
50
  package.list
51
51
  end
@@ -0,0 +1,11 @@
1
+ module Filament::Java::Mixins
2
+ module Classpath
3
+ def flattened_deps_jars(include_weak=false)
4
+ return flattened_deps(include_weak).collect{|dep| dep[:jar]}.compact
5
+ end
6
+
7
+ def classpath
8
+ return @custom_classpath + flattened_deps_jars(true)
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,7 @@
1
1
  module Filament::Java::Tools
2
2
  class Compile
3
+ include Filament::Java::Tools
4
+
3
5
  attr_writer :sources, :output_dir, :source_version, :target_version,
4
6
  :classpath, :bootclasspath
5
7
 
@@ -25,7 +27,7 @@ module Filament::Java::Tools
25
27
  bootclasspath = join_paths(@bootclasspath)
26
28
  output_dir = fix_paths(@output_dir)
27
29
  sources = fix_paths(@sources).join(' ')
28
- c = "#{JAVAC}"
30
+ c = "#{java_bin('javac')}"
29
31
  c << " -classpath #{classpath}" unless @classpath.empty?
30
32
  c << " -bootclasspath #{bootclasspath}" unless @bootclasspath.empty?
31
33
  c << " -source #{@source_version}" unless @source_version.nil?
@@ -1,5 +1,7 @@
1
1
  module Filament::Java::Tools
2
2
  class Execute
3
+ include Filament::Java::Tools
4
+
3
5
  attr_writer :classpath, :properties, :mainclass, :args, :jar
4
6
 
5
7
  def initialize(mainclass=nil)
@@ -14,7 +16,7 @@ module Filament::Java::Tools
14
16
  end
15
17
 
16
18
  def execute
17
- c = "#{JAVA} "
19
+ c = "#{java_bin('java')} "
18
20
 
19
21
  classpath = join_paths(@classpath)
20
22
  c << "-cp #{classpath} " unless @classpath.nil? or @classpath.empty?
@@ -1,5 +1,7 @@
1
1
  module Filament::Java::Tools
2
2
  class Jar
3
+ include Filament::Java::Tools
4
+
3
5
  attr_writer :jar_file, :base_dir, :manifest, :index, :update
4
6
  attr_accessor :package_files
5
7
 
@@ -19,7 +21,7 @@ module Filament::Java::Tools
19
21
  end
20
22
 
21
23
  def jar
22
- c = "#{JAR} "
24
+ c = "#{java_bin('jar')} "
23
25
  c << 'v' if $verbose
24
26
  c << 'f'
25
27
  if @update
@@ -41,17 +43,19 @@ module Filament::Java::Tools
41
43
  end
42
44
  end
43
45
 
44
- def self.extract(jar_file, output_dir)
45
- cd output_dir do |dir|
46
- if windows?
47
- # using jar is too slow
48
- c = "#{JAR} xf #{fix_paths(jar_file)}"
49
- sys c
50
- else
51
- c = 'unzip '
52
- c << '-q ' unless $verbose
53
- c << "-o #{fix_paths(jar_file)}"
54
- sys c
46
+ class << self
47
+ def extract(jar_file, output_dir)
48
+ cd output_dir do |dir|
49
+ if windows?
50
+ # using jar is too slow
51
+ c = "#{Filament::Java::Tools::java_bin('jar')} xf #{fix_paths(jar_file)}"
52
+ sys c
53
+ else
54
+ c = 'unzip '
55
+ c << '-q ' unless $verbose
56
+ c << "-o #{fix_paths(jar_file)}"
57
+ sys c
58
+ end
55
59
  end
56
60
  end
57
61
  end
@@ -8,6 +8,8 @@ module Filament::Java::Tools
8
8
  end
9
9
 
10
10
  class Proguard
11
+ include Filament::Java::Tools
12
+
11
13
  def initialize(injars=nil, outjars=nil)
12
14
  @options = []
13
15
 
@@ -2,24 +2,24 @@ require 'filament/platform'
2
2
 
3
3
  module Filament
4
4
  module Java
5
- module Tools
6
- def self.bin(path=nil)
7
- java_home_env = ENV['JAVA_HOME']
8
- unless java_home_env.nil?
9
- java_bin = "#{java_home_env}/bin"
10
- return java_bin if path.nil?
11
- return Filament::Platform.to_exec_path("#{java_bin}/#{path}")
12
- else
13
- # assume it's in the path
14
- return path
15
- end
16
- end
17
-
18
- JAVAC = Tools.bin('javac')
19
- JAVA = Tools.bin('java')
20
- JAR = Tools.bin('jar')
21
- end
22
- end
5
+ module Tools
6
+ include Filament::OS
7
+
8
+ def java_bin(path=nil)
9
+ java_home_env = ENV['JAVA_HOME']
10
+ unless java_home_env.nil?
11
+ java_bin = "#{java_home_env}/bin"
12
+ return java_bin if path.nil?
13
+ return to_exec_path("#{java_bin}/#{path}")
14
+ else
15
+ # assume it's in the path
16
+ return path
17
+ end
18
+ end
19
+
20
+ extend self
21
+ end
22
+ end
23
23
  end
24
24
 
25
25
  require 'filament/java/tools/jar'
@@ -1,7 +1,7 @@
1
1
  require 'filament/plugin'
2
2
 
3
3
  module Filament::Plugins
4
- class Java < Plugin
4
+ class Java < Filament::Plugin
5
5
  def initialize(app)
6
6
 
7
7
  end
@@ -1,16 +1,79 @@
1
- require 'filament/javame/mixins/library_mixin'
2
-
3
- module Filament::JavaME
4
- class Library < Filament::Artifact
5
- include JavaME::Mixins::LibraryMixin
6
-
7
- def init
8
- init_library
9
- end
10
-
11
- def build_artifact
12
- define_library(self)
13
- invoke_tasks
14
- end
15
- end
16
- end
1
+ require 'filament/java/mixins/classpath'
2
+ require 'filament/javame/tasks/library_task'
3
+
4
+ module Filament::JavaME
5
+ class Library < Filament::Target
6
+ include Filament::Java::Mixins::Classpath
7
+
8
+ attr_accessor2 :obfuscate
9
+
10
+ attr_writer :should_package_deps
11
+ attr_reader :srcs, :resources, :platform, :cldc_version
12
+
13
+ def custom_entries(h)
14
+ @custom_entries.merge!(h)
15
+ end
16
+
17
+ def append_entries(h)
18
+ h.keys.each do |key|
19
+ @append_entries[key] ||= []
20
+ entry = h[key]
21
+ if entry.is_a?(Array)
22
+ @append_entries[key] += entry
23
+ else
24
+ @append_entries[key] << entry
25
+ end
26
+ end
27
+ end
28
+
29
+ def init
30
+ @srcs = Filament::FileList2.new
31
+ @srcs.tag = :java
32
+
33
+ @resources = Filament::FileList2.new
34
+ @should_package_deps = false
35
+
36
+ @platform = Filament::JavaME::Tools.tags_for($target_platform)
37
+ @cldc_version = Filament::JavaME::Tools.cldc_version_for($target_platform)
38
+ @bootclasspath = Filament::JavaME::Tools.classpath_for($target_platform)
39
+
40
+ @custom_classpath = []
41
+
42
+ @append_entries = {}
43
+ @custom_entries = {}
44
+ end
45
+
46
+ def define
47
+ @library = Filament::JavaME::Tasks::LibraryTask.new do |l|
48
+ define_library(l)
49
+ end
50
+
51
+ output :tag => [:default, :jar],
52
+ :output => @library.jar_path,
53
+ :deployable => true,
54
+ :tasks => @library.tasks
55
+
56
+ output :tag => :jad_proc do |d|
57
+ d.append_entries(@append_entries)
58
+ d.custom_entries(@custom_entries)
59
+ end
60
+ end
61
+
62
+ def define_library(l)
63
+ l.working_dir = working_dir
64
+ l.output_dir = output_dir
65
+ l.name = name
66
+ l.classpath = classpath
67
+ l.bootclasspath = @bootclasspath
68
+ l.srcs = @srcs
69
+
70
+ l.resources = @resources + (@should_package_deps ? flattened_deps_jars : [])
71
+
72
+ l.task_deps << package.descriptor
73
+
74
+ l.proguard_proc = Proc.new do |o|
75
+ flattened_deps.collect{|dep| dep[:proguard_proc]}.compact.each{|p| p.call(o)}
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,16 +1,75 @@
1
- require 'filament/javame/mixins/suite_mixin'
2
-
3
- module Filament::JavaME
4
- class Suite < Filament::Artifact
5
- include JavaME::Mixins::SuiteMixin
6
-
7
- def init
8
- init_suite
9
- end
10
-
11
- def build_artifact
12
- define_suite(self)
13
- invoke_tasks
14
- end
15
- end
16
- end
1
+ require 'filament/javame/library'
2
+
3
+ module Filament::JavaME
4
+ class Suite < Library
5
+ attr_accessor2 :defaultmidlet_class,
6
+ :suite_version, :suite_name, :suite_icon, :suite_vendor,
7
+ :me_configuration, :me_profile
8
+
9
+ # adds a midlet hash with keys :icon, :classname, and :name
10
+ def add_midlet(midlet)
11
+ if midlet == :default
12
+ midlet = { :classname => defaultmidlet_class,
13
+ :icon => suite_icon,
14
+ :name => suite_name }
15
+ end
16
+
17
+ @midlets << midlet
18
+ end
19
+
20
+ def jad_proc(&block)
21
+ @jad_proc = block
22
+ end
23
+
24
+ def init
25
+ super
26
+ @jad_proc = Proc.new {}
27
+ @should_package_deps = true
28
+ @should_obfuscate = false # TODO should be based on $build_type
29
+ @midlets = []
30
+ end
31
+
32
+ def define
33
+ super
34
+
35
+ output :tag => :jad,
36
+ :output => @library.jad_path,
37
+ :deployable => true,
38
+ :tasks => @library.tasks
39
+
40
+ output :tag => :execute,
41
+ :tasks => @library.tasks do
42
+ emulate
43
+ end
44
+ end
45
+
46
+ def define_library(l)
47
+ super(l)
48
+
49
+ l.suite_version = @suite_version
50
+ l.suite_name = @suite_name
51
+ l.suite_icon = @suite_icon
52
+ l.suite_vendor = @suite_vendor
53
+ l.should_obfuscate = @should_obfuscate
54
+ l.midlets = @midlets
55
+ l.is_suite = true
56
+
57
+ l.jad_proc = Proc.new do |d|
58
+ all_jad_procs.each {|p| p.call(d)}
59
+ end
60
+ end
61
+
62
+ private
63
+ def emulate(midletclass=@defaultmidlet_class)
64
+ Filament::JavaME::Tools::emulate(@library.jad_path, midletclass)
65
+ end
66
+
67
+ def all_jad_procs
68
+ configs = flattened_deps.collect{|dep| dep[:jad_proc]}
69
+ configs << self[:jad_proc]
70
+ configs << @jad_proc
71
+ # create a list for imported jad configs
72
+ return configs.compact
73
+ end
74
+ end
75
+ end