rant 0.5.6 → 0.5.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (56) hide show
  1. data/NEWS +12 -0
  2. data/README +3 -3
  3. data/Rantfile +7 -1
  4. data/doc/Untitled-1~ +7 -0
  5. data/doc/command.rdoc +1 -1
  6. data/doc/csharp.rdoc +49 -72
  7. data/doc/csharp.rdoc~ +37 -0
  8. data/doc/csharp_deprecated.rdoc +73 -0
  9. data/doc/homepage/index.html +5 -8
  10. data/doc/homepage/index.html~ +134 -0
  11. data/doc/sys.rdoc +14 -0
  12. data/lib/rant/coregen.rb~ +262 -0
  13. data/lib/rant/csharp/base_compiler_adapter.rb +125 -0
  14. data/lib/rant/csharp/base_compiler_adapter.rb~ +105 -0
  15. data/lib/rant/csharp/compiler_adapter_factory.rb +40 -0
  16. data/lib/rant/csharp/compiler_adapter_factory.rb~ +39 -0
  17. data/lib/rant/csharp/csc_compiler.rb +15 -0
  18. data/lib/rant/csharp/csc_compiler.rb~ +39 -0
  19. data/lib/rant/csharp/gmcs_compiler.rb +9 -0
  20. data/lib/rant/csharp/gmcs_compiler.rb~ +10 -0
  21. data/lib/rant/csharp/mcs_compiler.rb +13 -0
  22. data/lib/rant/csharp/mcs_compiler.rb~ +40 -0
  23. data/lib/rant/csharp/msc_compiler.rb~ +39 -0
  24. data/lib/rant/import/csharp.rb +48 -0
  25. data/lib/rant/import/csharp.rb~ +58 -0
  26. data/lib/rant/import/nunittest.rb +32 -0
  27. data/lib/rant/import/resgen.rb +21 -0
  28. data/lib/rant/import/resgen.rb~ +20 -0
  29. data/lib/rant/init.rb +1 -1
  30. data/lib/rant/rantlib.rb +1 -0
  31. data/lib/rant/rantlib.rb~ +1376 -0
  32. data/lib/rant/rantsys.rb +6 -0
  33. data/run_import +1 -1
  34. data/run_rant +1 -1
  35. data/test/import/package/test_package.rb~ +628 -0
  36. data/test/rule.rf +4 -0
  37. data/test/test_filetask.rb~ +97 -0
  38. data/test/test_rule.rb +10 -0
  39. data/test/test_sys_methods.rb +22 -0
  40. data/test/units/csharp/test_base_compiler_adapter.rb +107 -0
  41. data/test/units/csharp/test_base_compiler_adapter.rb~ +73 -0
  42. data/test/units/csharp/test_compiler_adapter_factory.rb +66 -0
  43. data/test/units/csharp/test_compiler_adapter_factory.rb~ +66 -0
  44. data/test/units/csharp/test_csc_compiler.rb +23 -0
  45. data/test/units/csharp/test_csc_compiler.rb~ +23 -0
  46. data/test/units/csharp/test_gmsc_compiler.rb +19 -0
  47. data/test/units/csharp/test_gmsc_compiler.rb~ +19 -0
  48. data/test/units/csharp/test_msc_compiler.rb +23 -0
  49. data/test/units/csharp/test_msc_compiler.rb~ +23 -0
  50. data/test/units/csharp_test_helper.rb +6 -0
  51. data/test/units/import/test_csharp.rb +127 -0
  52. data/test/units/import/test_csharp.rb~ +126 -0
  53. data/test/units/import/test_nunittest.rb +122 -0
  54. data/test/units/import/test_resgen.rb +107 -0
  55. data/test/units/import/test_resgen.rb~ +88 -0
  56. metadata +269 -224
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/csc_compiler')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/mcs_compiler')
3
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/gmcs_compiler')
4
+
5
+ module Rant::CSharp
6
+ class CompilerAdapterFactory
7
+ attr_accessor :context
8
+ attr_accessor :compiler_map
9
+
10
+ def initialize context
11
+ @context = context
12
+ @compiler = nil
13
+
14
+ # Default compiler mappings
15
+ @compiler_map ||= {
16
+ "csc" => CscCompiler,
17
+ "mcs" => McsCompiler,
18
+ "gmcs" => GmcsCompiler
19
+ }
20
+ end
21
+
22
+ def compiler
23
+ if !@compiler
24
+ compiler_map.each_key do |key|
25
+ if context.env.find_bin(key)
26
+ @compiler = compiler_map[key].new(context)
27
+ break
28
+ end
29
+ end
30
+
31
+ if !@compiler
32
+ raise Exception.new("Could not find C# compiler in path (csc, mcs, gmcs). " +
33
+ "Please amend your path or explicitly define one with the :compiler option")
34
+ end
35
+ end
36
+
37
+ @compiler
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/csc_compiler')
2
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/mcs_compiler')
3
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/gmcs_compiler')
4
+
5
+ module Rant::CSharp
6
+ class CompilerAdapterFactory
7
+ attr_accessor :context
8
+ attr_accessor :compiler_map
9
+
10
+ def initialize context
11
+ @context = context
12
+
13
+ # Default compiler mappings
14
+ @compiler_map ||= {
15
+ "csc" => CscCompiler,
16
+ "mcs" => McsCompiler,
17
+ "gmcs" => GmcsCompiler
18
+ }
19
+ end
20
+
21
+ def compiler
22
+ if !@compiler
23
+ compiler_map.each_key do |key|
24
+ if context.env.find_bin(key)
25
+ @compiler = compiler_map[key].new(context)
26
+ break
27
+ end
28
+ end
29
+
30
+ if !@compiler
31
+ raise Exception.new("Could not find C# compiler in path (csc, mcs, gmcs). " +
32
+ "Please amend your path or explicitly define one with the :compiler option")
33
+ end
34
+ end
35
+
36
+ @compiler
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,15 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/base_compiler_adapter')
2
+
3
+ module Rant::CSharp
4
+ class CscCompiler < BaseCompilerAdapter
5
+ def initialize bin = 'csc /nologo'
6
+ super
7
+ @switch_map = { :resources => "res",
8
+ :libs => "r"}
9
+ end
10
+
11
+ def argument_prefix
12
+ "/"
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/base_compiler_adapter')
2
+
3
+ module Rant::CSharp
4
+ class CscCompiler < BaseCompilerAdapter
5
+ attr_accessor :bin
6
+
7
+ def initialize bin = 'csc /nologo'
8
+ @bin = bin
9
+ end
10
+
11
+ def switch_map
12
+ @switch_map ||= { :resources => "res",
13
+ :libs => "r"}
14
+ end
15
+
16
+ def map_arg arg
17
+ switch_map[arg] ? switch_map[arg] : arg
18
+ end
19
+
20
+ def outfile target
21
+ string_argument "out", target
22
+ end
23
+
24
+ def boolean_argument arg, on
25
+ switch = map_arg(arg)
26
+ ret = "/#{switch}"
27
+ ret += on ? "+" : "-"
28
+ end
29
+
30
+ def string_argument arg, value
31
+ switch = map_arg(arg)
32
+ # Assume all string arguments except target are
33
+ # files
34
+ value = ::Rant::Sys.sp(value) if arg != :target
35
+
36
+ "/#{switch}:#{value}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,9 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/mcs_compiler')
2
+
3
+ module Rant::CSharp
4
+ class GmcsCompiler < McsCompiler
5
+ def initialize bin = 'gmcs'
6
+ super
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,10 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/mcs_compiler')
2
+
3
+ module Rant::CSharp
4
+ class GmcsCompiler < McsCompiler
5
+ def initialize bin = 'gmcs'
6
+ puts __caller__
7
+ @bin = bin
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/base_compiler_adapter')
2
+
3
+ module Rant::CSharp
4
+ class McsCompiler < BaseCompilerAdapter
5
+ def initialize bin = 'mcs'
6
+ super
7
+ end
8
+
9
+ def argument_prefix
10
+ "-"
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,40 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/base_compiler_adapter')
2
+
3
+ module Rant::CSharp
4
+ class McsCompiler < BaseCompilerAdapter
5
+ attr_accessor :bin
6
+
7
+ def initialize bin = 'mcs'
8
+ puts __caller__
9
+ @bin = bin
10
+ end
11
+
12
+ def switch_map
13
+ @switch_map ||= {} # :resources => "res",
14
+ # :libs => "r"}
15
+ end
16
+
17
+ def map_arg arg
18
+ switch_map[arg] ? switch_map[arg] : arg
19
+ end
20
+
21
+ def outfile target
22
+ string_argument "out", target
23
+ end
24
+
25
+ def boolean_argument arg, on
26
+ switch = map_arg(arg)
27
+ ret = "-#{switch}"
28
+ ret += on ? "+" : "-"
29
+ end
30
+
31
+ def string_argument arg, value
32
+ switch = map_arg(arg)
33
+ # Assume all string arguments except target are
34
+ # files
35
+ value = context.sys.sp(value) if arg != :target
36
+
37
+ "-#{switch}:#{value}"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/base_compiler_adapter')
2
+
3
+ module Rant::CSharp
4
+ class MscCompiler < BaseCompilerAdapter
5
+ attr_accessor :bin
6
+
7
+ def initialize bin = 'msc'
8
+ @bin = bin
9
+ end
10
+
11
+ def switch_map
12
+ @switch_map ||= {} # :resources => "res",
13
+ # :libs => "r"}
14
+ end
15
+
16
+ def map_arg arg
17
+ switch_map[arg] ? switch_map[arg] : arg
18
+ end
19
+
20
+ def outfile target
21
+ string_argument "out", target
22
+ end
23
+
24
+ def boolean_argument arg, on
25
+ switch = map_arg(arg)
26
+ ret = "-#{switch}"
27
+ ret += on ? "+" : "-"
28
+ end
29
+
30
+ def string_argument arg, value
31
+ switch = map_arg(arg)
32
+ # Assume all string arguments except target are
33
+ # files
34
+ value = ::Rant::Sys.sp(value) if arg != :target
35
+
36
+ "-#{switch}:#{value}"
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,48 @@
1
+ require File.expand_path(File.dirname(__FILE__) +
2
+ '/../csharp/compiler_adapter_factory')
3
+
4
+ # Generator for compiling c sharp sources
5
+ class Rant::Generators::CSharp
6
+ def self.rant_gen(rant, ch, args, &block)
7
+ target = args.shift
8
+ cs_args = args.shift
9
+
10
+ # Verify arguments
11
+ rant.abort_at(ch, "CSharp requires a target") if !target || target.empty?
12
+ rant.abort_at(ch, "CSharp requires sources") if !cs_args[:sources] ||
13
+ cs_args[:sources].empty?
14
+
15
+ # Massage argument hash
16
+ dependencies = []
17
+ dependencies += cs_args[:sources]
18
+ dependencies += cs_args[:resources] if cs_args[:resources]
19
+ dependencies += cs_args[:libs] if cs_args[:libs]
20
+
21
+ # Create a file target to the output file,
22
+ # depend on all source files, resources,
23
+ # and libs
24
+ rant.file target => dependencies do |t|
25
+ cmd = get_compiler(rant.context, cs_args).cmd(target, cs_args)
26
+
27
+ rant.context.sys.sh cmd
28
+ end
29
+ end
30
+
31
+ def self.compiler_adapter_factory
32
+ @@compiler_adapter_factory ||= Rant::CSharp::CompilerAdapterFactory.new
33
+ end
34
+
35
+ def self.get_compiler(context, cs_args)
36
+ if cs_args[:compiler]
37
+ if cs_args[:compiler].respond_to?(:new)
38
+ compiler = cs_args[:compiler].new
39
+ else
40
+ compiler = cs_args[:compiler]
41
+ end
42
+ cs_args.delete(:compiler)
43
+ else
44
+ compiler = compiler_adapter_factory.compiler(context)
45
+ end
46
+ compiler
47
+ end
48
+ end
@@ -0,0 +1,58 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../csharp/compiler_adapter_factory')
2
+
3
+ # Generator for compiling c sharp sources
4
+ class Rant::Generators::CSharp
5
+ def self.compiler_adapter_factory
6
+ @@compiler_adapter_factory ||= Rant::CSharp::CompilerAdapterFactory.new
7
+ end
8
+
9
+ def self.rant_gen(rant, ch, args, &block)
10
+ target = args.shift
11
+ cs_args = args.shift
12
+
13
+ # Massage argument hash
14
+ dependencies = []
15
+ dependencies += cs_args[:sources]
16
+ dependencies += cs_args[:resources] if cs_args[:resources]
17
+ dependencies += cs_args[:libs] if cs_args[:libs]
18
+
19
+ # Create a file target to the output file,
20
+ # depend on all source files, resources,
21
+ # and libs
22
+ rant.file target => dependencies do |t|
23
+ if cs_args[:compiler]
24
+ if cs_args[:compiler].respond_to?(:new)
25
+ compiler = cs_args[:compiler].new
26
+ else
27
+ compiler = cs_args[:compiler]
28
+ end
29
+ cs_args.delete(:compiler)
30
+ else
31
+ compiler = compiler_adapter_factory.compiler(rant.context)
32
+ end
33
+
34
+
35
+ cmd = compiler.cmd(target, cs_args)
36
+
37
+ rant.context.sys.sh cmd
38
+ end
39
+ end
40
+ end
41
+
42
+ # Create a file task for compiling resources
43
+ class Rant::Generators::Resgen
44
+ def self.rant_gen(rant, ch, args, &block)
45
+ gen_args = args.shift
46
+ gen_args[:build_dir] ||= '.'
47
+
48
+ regex = Regexp.new("#{Regexp.escape(gen_args[:build_dir] + '/' + gen_args[:namespace])}\.(.+?)\.resources")
49
+
50
+ src = lambda { |target|
51
+ [regex.match(target)[1].gsub(/\./, "/") + ".resx"]
52
+ }
53
+
54
+ rant.context.gen ::Rant::Generators::Rule, regex => src do |t|
55
+ rant.context.sys.sh "resgen /useSourcePath /compile #{t.source},#{t.name}"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,32 @@
1
+ # Generator for running NUnit tests
2
+ class Rant::Generators::NUnitTest
3
+ def self.rant_gen(rant, ch, args, &block)
4
+ target = args.shift
5
+ gen_args = args.shift
6
+
7
+ # Verify arguments
8
+ rant.abort_at(ch, "NUnitTest requires a task name") if !target ||
9
+ target.empty?
10
+ rant.abort_at(ch, "NUnitTest requires dlls") if !gen_args[:dlls] ||
11
+ gen_args[:dlls].empty?
12
+
13
+ # Define test task
14
+ rant.task target do |t|
15
+ gen_args[:bin] ||= "nunit-console /nologo"
16
+ dlls = process_dlls(rant, gen_args[:dlls])
17
+
18
+ rant.context.sys.sh "#{gen_args[:bin]} #{dlls}"
19
+ end
20
+ end
21
+
22
+ def self.process_dlls(rant, dlls)
23
+ if dlls.respond_to?(:arglist)
24
+ dlls = dlls.arglist
25
+ elsif dlls.kind_of?(Array)
26
+ dlls = dlls.collect{|x| rant.context.sys.sp(x)}.join(" ")
27
+ else
28
+ dlls = rant.context.sys.sp(dlls)
29
+ end
30
+ dlls
31
+ end
32
+ end
@@ -0,0 +1,21 @@
1
+ # Create a file task for compiling resources
2
+ class Rant::Generators::Resgen
3
+ def self.rant_gen(rant, ch, args, &block)
4
+ gen_args = args.shift
5
+ gen_args[:build_dir] ||= ''
6
+ gen_args[:build_dir] += '/' if !gen_args[:build_dir].empty?
7
+ gen_args[:namespace] ||= ''
8
+ gen_args[:namespace] += '.' if !gen_args[:namespace].empty?
9
+ prefix = Regexp.escape(gen_args[:build_dir] + gen_args[:namespace])
10
+ regex = Regexp.new("#{prefix}(.+?)\\.resources")
11
+
12
+ src = lambda { |target|
13
+ [regex.match(target)[1].gsub(/\./, "/") + ".resx"]
14
+ }
15
+
16
+ rant.context.gen Rant::Generators::Rule, regex => src do |t|
17
+ rant.context.sys.sh "resgen /useSourcePath /compile " +
18
+ rant.context.sys.sp("#{t.source},#{t.name}")
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ # Create a file task for compiling resources
2
+ class Rant::Generators::Resgen
3
+ def self.rant_gen(rant, ch, args, &block)
4
+ gen_args = args.shift
5
+ gen_args[:build_dir] ||= ''
6
+ gen_args[:build_dir] += '/' if !gen_args[:build_dir].empty?
7
+ gen_args[:namespace] ||= ''
8
+ gen_args[:namespace] += '.' if !gen_args[:namespace].empty?
9
+ prefix = Regexp.escape(gen_args[:build_dir] + gen_args[:namespace])
10
+ regex = Regexp.new("#{prefix}(.+?)\\.resources")
11
+
12
+ src = lambda { |target|
13
+ [regex.match(target)[1].gsub(/\./, "/") + ".resx"]
14
+ }
15
+
16
+ rant.context.gen Rant::Generators::Rule, regex => src do |t|
17
+ rant.context.sys.sh "resgen /useSourcePath /compile #{t.source},#{t.name}"
18
+ end
19
+ end
20
+ end
@@ -56,7 +56,7 @@ class String
56
56
  end
57
57
 
58
58
  module Rant
59
- VERSION = '0.5.6'
59
+ VERSION = '0.5.7'
60
60
 
61
61
  @__rant_no_value__ = Object.new.freeze
62
62
  def self.__rant_no_value__