Class: Bake::Configs::Checks

Inherits:
Object
  • Object
show all
Defined in:
lib/bake/config/checks.rb

Class Method Summary collapse

Class Method Details

.commonMetamodelCheck(configs, filename, isAdapt = false) ⇒ Object



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/bake/config/checks.rb', line 23

def self.commonMetamodelCheck(configs, filename, isAdapt = false)

  if configs.length == 0 && !isAdapt
    Bake.formatter.printError("No config found", filename)
    ExitHelper.exit(1)
  end

  configs.each do |config|
    if config.respond_to?("toolchain") and config.toolchain
      config.toolchain.compiler.each do |c|
        if [:CPP,:C,:ASM].none? {|t| t == c.ctype}
          Bake.formatter.printError("Type of compiler must be CPP, C or ASM", c)
          ExitHelper.exit(1)
        end
        if not c.internalDefines.nil? and c.internalDefines != ""
          Bake.formatter.printError("InternalDefines only allowed in DefaultToolchain", c.internalDefines)
          ExitHelper.exit(1)
        end
        if c.fileEndings && c.fileEndings.endings.empty?
          Bake.formatter.printError("FileEnding must not be empty.", c.fileEndings)
          ExitHelper.exit(1)
        end
      end
      config.toolchain.lintPolicy.each do |l|
        Bake.formatter.printWarning("Lint support was removed. Please delete LintPolicy from Project.meta.", l)
      end
    end
    if config.respond_to?("defaultToolchain") and config.defaultToolchain
      config.defaultToolchain.lintPolicy.each do |l|
        Bake.formatter.printWarning("Lint support was removed. Please delete LintPolicy from Project.meta.", l)
      end
      config.defaultToolchain.compiler.each do |c|
        if [:CPP,:C,:ASM].none? {|t| t == c.ctype}
          Bake.formatter.printError("Type of compiler must be CPP, C or ASM", c)
          ExitHelper.exit(1)
        end
        if c.fileEndings && c.fileEndings.endings.empty?
          Bake.formatter.printError("FileEnding must not be empty.", c.fileEndings)
          ExitHelper.exit(1)
        end
      end
    end

    config.includeDir.each do |inc|
      if not ["front", "back", ""].include?inc.inject
        Bake.formatter.printError("inject of IncludeDir must be 'front' or 'back'", inc)
        ExitHelper.exit(1)
      end
      if not ["front", "back", ""].include?inc.infix
        Bake.formatter.printError("infix of IncludeDir must be 'front' or 'back'", inc)
        ExitHelper.exit(1)
      end
      if (inc.infix != "" and inc.inject != "")
        Bake.formatter.printError("IncludeDir must have inject OR infix (deprecated)", inc)
        ExitHelper.exit(1)
      end
    end if config.respond_to?("includeDir")

    if not ["", "yes", "no", "all"].include?config.mergeInc
      Bake.formatter.printError("Allowed modes are 'all', 'yes', 'no' and unset.",config)
      ExitHelper.exit(1)
    end

  end

end

.symlinkCheck(filename) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/bake/config/checks.rb', line 6

def self.symlinkCheck(filename)
  dirOfProjMeta = File.dirname(filename)
  Dir.chdir(dirOfProjMeta) do
    if Dir.pwd != dirOfProjMeta and File.dirname(Dir.pwd) != File.dirname(dirOfProjMeta)
      isSym = false
      begin
        isSym = File.symlink?(dirOfProjMeta)
      rescue
      end
      if isSym
        Bake.formatter.printError("Symlinks only allowed with the same parent dir as the target: #{dirOfProjMeta} --> #{Dir.pwd}", filename)
        ExitHelper.exit(1)
      end
    end
  end
end