Class: Rant::Generators::CSharp

Inherits:
Object
  • Object
show all
Defined in:
lib/rant/import/csharp.rb

Overview

Generator for compiling c sharp sources

Class Method Summary collapse

Class Method Details

.compiler_adapter_factoryObject


31
32
33
# File 'lib/rant/import/csharp.rb', line 31

def self.compiler_adapter_factory
  @@compiler_adapter_factory ||= Rant::CSharp::CompilerAdapterFactory.new
end

.get_compiler(context, cs_args) ⇒ Object


35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rant/import/csharp.rb', line 35

def self.get_compiler(context, cs_args)
  if cs_args[:compiler]    
    if cs_args[:compiler].respond_to?(:new)
      compiler = cs_args[:compiler].new
    else
      compiler = cs_args[:compiler]
    end
    cs_args.delete(:compiler)
  else
    compiler = compiler_adapter_factory.compiler(context)
  end
  compiler
end

.rant_gen(rant, ch, args, &block) ⇒ Object


6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/rant/import/csharp.rb', line 6

def self.rant_gen(rant, ch, args, &block)   
  target = args.shift
  cs_args = args.shift

  # Verify arguments
  rant.abort_at(ch, "CSharp requires a target") if !target || target.empty?
  rant.abort_at(ch, "CSharp requires sources") if !cs_args[:sources] || 
                                                   cs_args[:sources].empty?

  # Massage argument hash
  dependencies = []
  dependencies += cs_args[:sources]
  dependencies += cs_args[:resources] if cs_args[:resources]
  dependencies += cs_args[:libs] if cs_args[:libs]

  # Create a file target to the output file,
  # depend on all source files, resources,
  # and libs
  rant.file target => dependencies do |t|
    cmd = get_compiler(rant.context, cs_args).cmd(target, cs_args)

    rant.context.sys.sh cmd
  end
end