Class: Bake::Blocks::Show

Inherits:
Object
  • Object
show all
Defined in:
lib/blocks/showIncludes.rb

Class Method Summary collapse

Class Method Details

.includesObject



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/blocks/showIncludes.rb', line 19

def self.includes
  secureShow {
  Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|
    print projName
    incs = []
    blocks.each { |block| incs += block.include_list }
    incs.uniq.each { |inc| print "##{inc}" }
    print "\n"
  end
  ExitHelper.exit(0) }
end

.includesAndDefines(mainConfig, mainTcs) ⇒ Object



82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
# File 'lib/blocks/showIncludes.rb', line 82

def self.includesAndDefines(mainConfig, mainTcs)
  secureShow {
  mainBlock = Blocks::ALL_BLOCKS[Bake.options.main_project_name+","+Bake.options.build_config]

  intIncs = readInternalIncludes(mainConfig, mainBlock, mainTcs)
  intDefs = readInternalDefines(mainConfig, mainBlock)


  Blocks::ALL_COMPILE_BLOCKS.sort.each do |projName, blocks|

    blockIncs = []
    blockDefs = {:CPP => [], :C => [], :ASM => []}
    blocks.each do |block|
      blockIncs += block.include_list 
      [:CPP, :C, :ASM].each { |type| blockDefs[type] += block.tcs[:COMPILER][type][:DEFINES] }
    end
    
    puts projName
    puts " includes"
    (blockIncs + intIncs).uniq.each { |i| puts "  #{i}" }
    [:CPP, :C, :ASM].each do |type|
      puts " #{type} defines"
      (blockDefs[type] + intDefs[type]).uniq.each { |d| puts "  #{d}" }
    end
    puts " done"
    
  end
  ExitHelper.exit(0) }
end

.readInternalDefines(mainConfig, mainBlock) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/blocks/showIncludes.rb', line 63

def self.readInternalDefines(mainConfig, mainBlock)
  intDefs = {:CPP => [], :C => [], :ASM => []}
  Dir.chdir(Bake.options.main_dir) do
    mainConfig.defaultToolchain.compiler.each do |c|
      if (c.internalDefines)
        dname = mainBlock.convPath(c.internalDefines)
        if dname != ""
          if not File.exists?(dname)
            Bake.formatter.printError("InternalDefines file #{dname} does not exist", c.internalDefines)
            ExitHelper.exit(1)
          end
          IO.foreach(dname) {|x| add_line_if_no_comment(intDefs[c.ctype],x)  }
        end
      end
    end
  end
  return intDefs
end

.readInternalIncludes(mainConfig, mainBlock, mainTcs) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/blocks/showIncludes.rb', line 31

def self.readInternalIncludes(mainConfig, mainBlock, mainTcs)
  intIncs = []
  iinc = mainConfig.defaultToolchain.internalIncludes
  Dir.chdir(Bake.options.main_dir) do
    if (iinc)
      
      cppExe      = File.which(mainTcs[:COMPILER][:CPP][:COMMAND]) 
      cExe        = File.which(mainTcs[:COMPILER][:C][:COMMAND])
      asmExe      = File.which(mainTcs[:COMPILER][:ASM][:COMMAND])
      archiverExe = File.which(mainTcs[:ARCHIVER][:COMMAND])
      linkerExe   = File.which(mainTcs[:LINKER][:COMMAND])
      
      iname = mainBlock.convPath(iinc)
      if iname != ""
        if not File.exists?(iname)
          Bake.formatter.printError("InternalIncludes file #{iname} does not exist", iinc)
          ExitHelper.exit(1)
        end
        IO.foreach(iname) do |x|
          x.sub!("$(CPPPath)",      cppExe)
          x.sub!("$(CPath)",        cExe)
          x.sub!("$(ASMPath)",      asmExe)
          x.sub!("$(ArchiverPath)", archiverExe)
          x.sub!("$(LinkerPath)",   linkerExe)
          add_line_if_no_comment(intIncs,x)
        end
      end
    end
  end
  return intIncs
end

.secureShowObject



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/blocks/showIncludes.rb', line 5

def self.secureShow
  begin
    yield
  rescue Exception => e
    if (not SystemExit === e)
      puts e
      puts e.backtrace
      ExitHelper.exit(1)
    else
      raise e
    end
  end
end