Module: Bake

Defined in:
lib/tocxx.rb,
lib/bake/cache.rb,
lib/bake/subst.rb,
lib/blocks/docu.rb,
lib/common/root.rb,
lib/blocks/block.rb,
lib/blocks/sleep.rb,
lib/common/crc32.rb,
lib/common/utils.rb,
lib/bakery/toBake.rb,
lib/bakeqac/filter.rb,
lib/blocks/compile.rb,
lib/blocks/convert.rb,
lib/blocks/library.rb,
lib/common/cleanup.rb,
lib/common/process.rb,
lib/common/version.rb,
lib/bake/libElement.rb,
lib/blocks/fileutil.rb,
lib/blocks/makefile.rb,
lib/multithread/job.rb,
lib/bake/mergeConfig.rb,
lib/blocks/blockBase.rb,
lib/bake/model/loader.rb,
lib/bake/toolchain/ti.rb,
lib/blocks/executable.rb,
lib/bake/config/checks.rb,
lib/bake/config/loader.rb,
lib/bake/options/usage.rb,
lib/bake/toolchain/gcc.rb,
lib/bake/toolchain/iar.rb,
lib/blocks/commandLine.rb,
lib/common/exit_helper.rb,
lib/adapt/config/loader.rb,
lib/bake/model/language.rb,
lib/bake/options/create.rb,
lib/bake/toolchain/diab.rb,
lib/bake/toolchain/keil.rb,
lib/bake/toolchain/msvc.rb,
lib/bakery/buildPattern.rb,
lib/bakery/model/loader.rb,
lib/blocks/showIncludes.rb,
lib/bake/model/metamodel.rb,
lib/bake/options/options.rb,
lib/bake/options/showDoc.rb,
lib/bake/toolchain/clang.rb,
lib/common/ide_interface.rb,
lib/bakery/model/language.rb,
lib/common/abortException.rb,
lib/common/options/finder.rb,
lib/common/options/parser.rb,
lib/bake/toolchain/gcc_env.rb,
lib/bake/toolchain/tasking.rb,
lib/bakery/model/metamodel.rb,
lib/bakery/options/options.rb,
lib/format/options/options.rb,
lib/bake/toolchain/provider.rb,
lib/bakeqac/options/options.rb,
lib/bake/model/metamodel_ext.rb,
lib/bake/options/showLicense.rb,
lib/bake/toolchain/greenhills.rb,
lib/bakeclean/options/options.rb,
lib/blocks/has_execute_command.rb,
lib/bake/options/showToolchains.rb,
lib/bake/toolchain/clang_analyze.rb,
lib/bake/toolchain/clang_bitcode.rb,
lib/rtext-service/options/options.rb,
lib/bake/toolchain/colorizing_formatter.rb,
lib/bake/toolchain/errorparser/error_parser.rb,
lib/bake/toolchain/errorparser/process_output.rb,
lib/bake/toolchain/errorparser/ti_linker_error_parser.rb,
lib/bake/toolchain/errorparser/gcc_linker_error_parser.rb,
lib/bake/toolchain/errorparser/iar_linker_error_parser.rb,
lib/bake/toolchain/errorparser/diab_linker_error_parser.rb,
lib/bake/toolchain/errorparser/keil_linker_error_parser.rb,
lib/bake/toolchain/errorparser/msvc_linker_error_parser.rb,
lib/bake/toolchain/errorparser/ti_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/gcc_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/iar_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/diab_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/keil_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/msvc_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/tasking_linker_error_parser.rb,
lib/bake/toolchain/errorparser/tasking_compiler_error_parser.rb,
lib/bake/toolchain/errorparser/greenhills_linker_error_parser.rb,
lib/bake/toolchain/errorparser/greenhills_compiler_error_parser.rb

Defined Under Namespace

Modules: BakeryModel, Blocks, Configs, Metamodel, Multithread, Toolchain, Utils Classes: AbortException, AdaptConfig, BakeFormatOptions, BakeRtextServiceOptions, BakecleanOptions, BakeqacOptions, BakeryLoader, BakeryOptions, BuildPattern, CRC32, Cache, CacheAccess, ColorizingFormatter, Config, Create, DiabCompilerErrorParser, DiabLinkerErrorParser, Doc, ErrorDesc, ErrorParser, ExitHelper, GCCCompilerErrorParser, GCCLinkerErrorParser, GreenHillsCompilerErrorParser, GreenHillsLinkerErrorParser, IARCompilerErrorParser, IARLinkerErrorParser, IDEInterface, Idp, KeilCompilerErrorParser, KeilLinkerErrorParser, LibElement, LibElements, License, Loader, MSVCCompilerErrorParser, MSVCLinkerErrorParser, MergeConfig, Options, Parser, ProcessHelper, ProjectFilter, Root, Subst, SystemCommandFailed, TICompilerErrorParser, TILinkerErrorParser, TaskingCompilerErrorParser, TaskingLinkerErrorParser, ToCxx, ToolchainInfo, Usage, Version

Constant Summary collapse

BUILD_PASSED =
0
BUILD_FAILED =
1
BUILD_ABORTED =
2
Language =
RText::Language.new(Metamodel.ecore,
  :feature_provider => proc {|c|
    RGen::Serializer::OppositeReferenceFilter.call(c.eAllStructuralFeatures).reject {|f|
      f.eAnnotations.any? {|a|
        a.details.any? {|d| d.key == 'internal' && d.value == 'true'}
      }
    }
  },
  :unlabled_arguments => proc {|c|
    if c.name == "Compiler" or c.name == "CompilerAdaptions"
      ["ctype"]
    elsif c.name == "Define"
      ["str"]
    elsif c.name == "Flags" or c.name == "LibPostfixFlags" or c.name == "LibPrefixFlags"
      ["overwrite"]
    elsif c.name == "DefaultToolchain"
      ["basedOn"]
    elsif c.name == "Description"
      ["text"]
    elsif c.name == "SrcFileEndings"
      ["endings"]
    else
      ["name"]
    end
  },
  :identifier_provider => Idp.new,
  :line_number_attribute => "line_number",
  :fragment_ref_attribute => "fragment_ref"
)
BakeryLanguage =
RText::Language.new(BakeryModel.ecore,
  :feature_provider => proc {|c|
    RGen::Serializer::OppositeReferenceFilter.call(c.eAllStructuralFeatures).reject {|f|
      f.eAnnotations.any? {|a|
        a.details.any? {|d| d.key == 'internal' && d.value == 'true'}
      }
    }
  },
  :unlabled_arguments => proc {|c|
    ["name"]
  },
  :line_number_attribute => "line_number",
  :file_name_attribute => "file_name"
)

Class Method Summary collapse

Class Method Details

.cleanupObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/common/cleanup.rb', line 7

def self.cleanup()
  Blocks::ALL_BLOCKS.clear
  Blocks::ALL_COMPILE_BLOCKS.clear
  Blocks::CC2J.clear
  Bake::IDEInterface.instance.set_abort(false)
  Blocks::Block.reset_block_counter
  Blocks::Block.reset_delayed_result
  Configs::Checks.cleanupWarnings
  ToCxx::reset_include_deps
end

.findDirOfFileToRoot(dir, filename) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/common/options/finder.rb', line 3

def self.findDirOfFileToRoot(dir, filename)
  if !File.exist?(dir)
    Bake.formatter.printError("Error: #{dir} does not exist")
    ExitHelper.exit(1)
  end
  loop do
    completeName = dir + "/" + filename
    return dir if File.exist?(completeName)
    newDir = File.dirname(dir)
    return nil if newDir == dir
    dir = newDir
  end
end

.formatterObject



120
121
122
# File 'lib/bake/toolchain/colorizing_formatter.rb', line 120

def self.formatter
  @@formatter ||= ColorizingFormatter.new
end

.getBuildPattern(cols, name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/bakery/toBake.rb', line 5

def self.getBuildPattern(cols, name)

  colMeta = @options.collection_dir+"/Collection.meta"

  if (cols.length == 0)
    Bake.formatter.printError("Collection #{name} not found", colMeta)
    ExitHelper.exit(1)
  elsif (cols.length > 1)
    Bake.formatter.printError("Collection #{name} found more than once", colMeta)
    ExitHelper.exit(1)
  end

  col = cols[0]

  col.project.each do |p|
    if p.name == ""
      Bake.formatter.printError("Project name empty", p)
      ExitHelper.exit(1)
    end
    if p.config == ""
      Bake.formatter.printError("Config name empty", p)
      ExitHelper.exit(1)
    end
  end

  toBuildPattern = []
  @options.roots.each do |root|
    col.project.each do |p|
      projs = Root.search_to_depth(root.dir,p.name + "/Project.meta", root.depth).map { |p| Pathname.new(p).cleanpath.to_s }
      if File.basename(root.dir) == p.name && File.exist?(root.dir + "/Project.meta")
        projs << root.dir + "/Project.meta"
      end
      if projs.length == 0
        Bake.formatter.printWarning("pattern does not match any project: #{p.name}", p)
      end
      projs.each do |f|
        toBuildPattern << BuildPattern.new(f, "^"+p.config.gsub("*","(\\w*)")+"$", p.args, p.args_end, p)
      end
    end
  end

  toBuild = []
  toBuildPattern.each do |bp|
    next unless bp.proj
    contents = File.open(bp.proj, "r") {|io| io.read }
    contents.split("\n").each do |c|
      res = c.gsub(/#.*/,"").match("\\s*(Library|Executable|Custom){1}Config\\s*\"?([\\w:-]*)\"?")
      if res
        if res[2].match(bp.conf) != nil
          toBuild << BuildPattern.new(bp.proj, res[2], bp.args, bp.args_end, nil)
          bp.coll_p.found
        end
      end
    end
  end

  toBuildPattern.select {|bp| !bp.coll_p.isFound}.map {|bp| bp.coll_p}.uniq.each do |p|
    Bake.formatter.printWarning("pattern does not match any config: #{p.config}", p)
  end

  col.exclude.each do |p|
    p.name = "/"+p.name.gsub("*","(\\w*)")+"/Project.meta"
    p.config = "^"+p.config.gsub("*","(\\w*)")+"$"
  end

  col.exclude_dir.each do |e|
    e.name = File.expand_path(e.name, @options.collection_dir)
  end

  toBuild.delete_if do |bp|
    exclude = false
    col.exclude.each do |p|
      exclude = true if (bp.proj.match(p.name) != nil and bp.conf.match(p.config) != nil)
    end
    col.exclude_dir.each do |e|
      exclude = true if bp.proj.start_with?(e.name)
    end
    exclude
  end

  toBuild.uniq!

  return toBuild
end

.optionsObject



396
397
398
# File 'lib/bake/options/options.rb', line 396

def self.options
  @@options ||= Options.new([])
end

.options=(options) ⇒ Object



400
401
402
# File 'lib/bake/options/options.rb', line 400

def self.options=(options)
  @@options = options
end