bakeConv 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 54c74fa0b572d947cfc10c64e2cb9bdde2b65cdb
4
- data.tar.gz: 2063ac52ef08aded42b620c16bd2c41fddc110ca
3
+ metadata.gz: a564dfac3eb6816f428188a0ab0b3674be29d392
4
+ data.tar.gz: fe91e06eb189d0399d00f7cbad600b3374a0d4ba
5
5
  SHA512:
6
- metadata.gz: 97f2d4efcdec98c419a6d3e43c0a67efee0dd795713ee7d6d02dcfe2d091155a494741d7e38fb9584eef4e7a4afb681ae31a1037b503bfdb8c9a54ee833c7d89
7
- data.tar.gz: 3785de4d0adc21601ee3accf9b844b4cd03e31d8e769c0416f83c51ba316c91515023732a4c9385d5b86d94cfe702b9cc772fa9c475f64652f2cff05c952fa42
6
+ metadata.gz: 50d3805099bb35d0095317ef413611f13002309950759e412db711948ccbe2c2a55209ceb23382687a2f815b868c6132a53cba713540a03445521ad378b41717
7
+ data.tar.gz: 53ecea82597d2200b8cd72ca90f6d9a014229d08d64585c82249d5cff185558e673edc6c8fedf66a0c4c16294305e50875ae9e077e7dacc9246cc540f087262e
data/lib/Bake.rb CHANGED
@@ -59,7 +59,6 @@ module BConv
59
59
  value << line.strip if value != nil
60
60
  value = line.strip if value == nil
61
61
  b_hash.store(key,value)
62
-
63
62
  end
64
63
  elsif line.start_with?(" ") && line[1] != " "
65
64
  if state == Bake::START_INFO || state == Bake::VAR
data/lib/ConfigParser.rb CHANGED
@@ -26,10 +26,13 @@ module BConv
26
26
  while(line = l.gets) != nil
27
27
  line.gsub!('\\','/')
28
28
  ar = line.split("=")
29
+
29
30
  if (ar.length == 2)
30
- comPos = ar[1].index("#")
31
- ar[1] = ar[1][0..comPos-1] if comPos != nil
32
- mapping.store(ar[0].strip,ar[1].strip)
31
+ if ar[0].strip[0] != "#"
32
+ comPos = ar[1].index("#")
33
+ ar[1] = ar[1][0..comPos-1] if comPos != nil
34
+ mapping.store(ar[0].strip,ar[1].strip)
35
+ end
33
36
  elsif ar[1] == ""
34
37
  mapping.store(ar[0].strip,"")
35
38
  end
@@ -39,27 +42,19 @@ module BConv
39
42
  raise "Error: MainProj parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('MainProj') == false
40
43
  raise "Error: BuildConfig parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('BuildConfig') == false
41
44
  raise "Error: Proj2Convert parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('Proj2Convert') == false
42
- raise "Error: OutputFileName parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('OutputFileName') == false
45
+ raise "Error: OutputFile parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('OutputFile') == false
43
46
  raise "Error: TemplateFile parameter from Mapping in line #{lineNumber} is missing!" if mapping.has_key?('TemplateFile') == false
44
47
 
48
+ #raise "Error: Parameter in #{File.basename(@filename)}, Mapping line #{lineNumber} is missing!" if ar[0].strip == ""
49
+
45
50
  if @projToConvert != "" && @projToConvert != mapping['Proj2Convert']
46
51
  mapping = {}
47
52
  else
48
53
  mappings << mapping
49
54
  end
50
-
51
- # if @projToConvert.length != 0
52
- # @projToConvert.each do |val|
53
- # if val == mapping['Proj2Convert']
54
- # mappings << mapping
55
- # end
56
- # end
57
- # else
58
- # mappings << mapping
59
- # end
60
-
61
55
  setEndLabel = true
62
56
  break
57
+
63
58
  elsif line.include?("Mapping")
64
59
  raise "Error: end label } from Mapping in line #{lineNumber} is missing!"
65
60
  end
@@ -70,7 +65,7 @@ module BConv
70
65
  raise "Error: Mapping keyword in front of line #{lineNumber} is missing?"
71
66
  end
72
67
  end
73
- return mappings
68
+ return 0, mappings
74
69
  end
75
70
  rescue Exception => e
76
71
  puts e.message
data/lib/Converter.rb CHANGED
@@ -15,26 +15,36 @@ module BConv
15
15
  end
16
16
 
17
17
  def convert
18
- outputfilename = Util.makeAbsolute(@map['OutputFileName'], @configFile)
18
+ outputfilename = Util.makeAbsolute(@map['OutputFile'], @configFile)
19
19
  templatefilename = Util.makeAbsolute(@map['TemplateFile'], @configFile)
20
20
 
21
21
  lineIdx = 0
22
22
  tmpLineIdx = 0
23
23
  set = true
24
+
25
+ @map.delete_if{|k,_| (k=="EXCLUDE_BAKE_DEPENDENCIES" || k=="EXCLUDE_BAKE_SOURCES" || k=="EXCLUDE_BAKE_INCLUDES") } #not useful anymore
26
+
24
27
  begin
25
28
  File.open(outputfilename, 'w') do |fout|
26
29
  File.open(templatefilename) do |fread|
27
30
  File.readlines(fread).each do |line|
28
31
  lineIdx += 1
29
32
  wroteLine = false
33
+
30
34
  @map.keys.each do |key|
31
-
32
35
  if line.include?(key.to_s) && @map[key].include?(".txt")
33
36
  preAndPostfix = line.scan(/(.*)\$\$\(#{key}\)(.*)/)
37
+ preAndPostfixOpt = line.scan(/(.*)\$OPTION\(#{key}\)(.*)/)
38
+
34
39
  if preAndPostfix.length == 1
35
40
  prefix = preAndPostfix[0][0]
36
41
  postfix = preAndPostfix[0][1]
37
42
  end
43
+ #need some cosmetics!
44
+ if preAndPostfixOpt.length == 1
45
+ prefix = preAndPostfixOpt[0][0]
46
+ postfix = preAndPostfixOpt[0][1]
47
+ end
38
48
 
39
49
  filename = Util.makeAbsolute(@map[key], @configFile)
40
50
  raise "Error: Template file #{File.basename(filename)} is empty!" if File.zero?(filename)
@@ -46,14 +56,15 @@ module BConv
46
56
  @map.keys.each do |k|
47
57
  wroteLine = findAndReplace(k, l, fout, prefix, postfix)
48
58
  break if wroteLine == true
49
- end
59
+ end
60
+
50
61
  if wroteLine == false
51
62
  l.strip!
52
63
  l = prefix + l + postfix + "\n"
53
64
  m = l.match(/\$\$\((.*)\)/)
54
- if m
55
- puts "Info: Key $$(#{m[1]}) in #{File.basename(filename)}, line #{tmpLineIdx.to_s} wasn\'t replaced!" if m
56
- end
65
+ opt = l.match(/\$OPTION\((.*)\)/)
66
+ raise "Error: Key $$(#{m[1]}) in #{File.basename(filename)}, line #{tmpLineIdx.to_s} wasn\'t replaced!" if m
67
+ puts "Info: Key $OPTION(#{opt[1]}) in #{File.basename(filename)}, line #{tmpLineIdx.to_s} wasn\'t replaced!" if opt
57
68
  fout.write(l)
58
69
  set = false
59
70
  end
@@ -66,15 +77,18 @@ module BConv
66
77
  elsif line.match(/\$\$\(#{key}\)/)
67
78
  wroteLine = findAndReplace(key, line, fout, "", "")
68
79
  break
80
+ elsif line.match(/\$OPTION\(#{key}\)/)
81
+ wroteLine = findAndReplace(key, line, fout, "", "")
82
+ break
69
83
  end
70
84
  end
71
85
 
72
86
  if wroteLine == false
73
87
  if set == true
74
88
  m = line.match(/\$\$\((.*)\)/)
75
- if m
76
- puts "Info: Key $$(#{m[1]}) in #{File.basename(templatefilename)}, line #{lineIdx.to_s} wasn\'t replaced!"
77
- end
89
+ opt = line.match(/\$OPTION\((.*)\)/)
90
+ raise "Error: Key $$(#{m[1]}) in #{File.basename(templatefilename)}, line #{lineIdx.to_s} wasn\'t replaced!" if m
91
+ puts "Info: Key $OPTION(#{opt[1]}) in #{File.basename(templatefilename)}, line #{lineIdx.to_s} wasn\'t replaced!" if opt
78
92
  fout.write(line)
79
93
  end
80
94
  set = true
@@ -89,16 +103,19 @@ module BConv
89
103
  puts e.back_trace if @debugMode == true
90
104
  abort
91
105
  end
106
+ return 0
92
107
  end
93
108
 
94
109
  def findAndReplace(key, line, fout, prefix, postfix)
95
110
  wroteLine = false
96
111
  found = line.scan(/(.*)\$\$\(#{key}\)(.*)/)
97
-
112
+ foundOpt = line.scan(/(.*)\$OPTION\(#{key}\)(.*)/)
113
+
114
+ found = foundOpt if (found.length==0 && foundOpt.length!=0)
115
+
98
116
  if found.length == 1
99
117
  pre = found[0][0]
100
118
  post = found[0][1]
101
-
102
119
  if @map[key].kind_of?(Array)
103
120
  @map[key].each do |val|
104
121
  line = prefix + pre + val.to_s + post + postfix + "\n"
@@ -114,6 +131,10 @@ module BConv
114
131
  line.gsub!(/\$\$\(#{key}\)/, @map[key].to_s)
115
132
  fout.write(line)
116
133
  wroteLine = true
134
+ elsif line.include?("/\$OPTION\(#{key}\)/") && found.length == 0
135
+ line.gsub!(/\$OPTION\(#{key}\)/, @map[key].to_s)
136
+ fout.write(line)
137
+ wroteLine = true
117
138
  end
118
139
  return wroteLine
119
140
  end
data/lib/File_ext.rb CHANGED
@@ -5,7 +5,7 @@
5
5
  class File
6
6
 
7
7
  def self.isAbsolute?(filename)
8
- File.expand_path(filename) == filename
8
+ return File.expand_path(filename) == filename
9
9
  end
10
10
 
11
11
  end
data/lib/Filter.rb CHANGED
@@ -8,29 +8,17 @@ module BConv
8
8
 
9
9
  class Filter
10
10
 
11
- def self.hashFilter(keySearched, doFilter, hash)
11
+ def self.hashFilter(keySearched, forFiltering, hash)
12
+ forFilteringArr = forFiltering[1..-2].split(",").map {|elm| elm.strip}
12
13
  hash.each do |key, value|
13
- if keySearched == "GMOCK_FILTER"
14
- value.each { |elm| value.delete(elm) if elm.match(/\/?gmock\/?/) }
15
- elsif keySearched == "DEPENDENCIES_FILTER"
16
- if doFilter == "true"
17
- hash.delete(key) if key == "BAKE_DEPENDENCIES"
18
- else
19
- hash.delete(key) if key == "BAKE_DEPENDENCIES_FILTERED"
14
+ if key == keySearched.split("EXCLUDE_")[1]
15
+ forFilteringArr.each do |elm|
16
+ value.each do |val|
17
+ if val.include?(elm)
18
+ value.delete(val)
19
+ end
20
+ end
20
21
  end
21
- end
22
- end
23
-
24
- if keySearched == "DEPENDENCIES_FILTER"
25
- hvalues = []
26
- if doFilter == "false"
27
- hash["BAKE_DEPENDENCIES"].each { |v| hvalues << v }
28
- hash.store("DEPENDENCIES_FILTER", hvalues)
29
- hash.delete("BAKE_DEPENDENCIES")
30
- else
31
- hash["BAKE_DEPENDENCIES_FILTERED"].each { |v| hvalues << v }
32
- hash.store("DEPENDENCIES_FILTER", hvalues)
33
- hash.delete("BAKE_DEPENDENCIES_FILTERED")
34
22
  end
35
23
  end
36
24
  return hash
data/lib/PathAdapt.rb CHANGED
@@ -10,13 +10,15 @@ module BConv
10
10
  SLASH = "/"
11
11
  COLON = ":"
12
12
 
13
- def self.adapt_path(outputFilePath, bhash, cfgFleFromCmdLne)
13
+ def self.adapt_path(outputFilePath, bhash, cfgFleFromCmdLne, debugMode)
14
14
  diffPathLevels, diffPathLevelsDown = 0, 0
15
15
  dir, diffUp = "", ""
16
16
  diffArr = []
17
17
 
18
- splitOutputFile = File.expand_path(File.dirname(outputFilePath),File.dirname(cfgFleFromCmdLne)).split("/")
19
- splitProjMeta = bhash['BAKE_PROJECTDIR'][0].split("/")
18
+ begin
19
+ splitOutputFile = File.expand_path(File.dirname(outputFilePath),File.dirname(cfgFleFromCmdLne)).split("/")
20
+ splitProjMeta = bhash['BAKE_PROJECTDIR'][0].split("/") if bhash['BAKE_PROJECTDIR'][0].include?("/") && bhash['BAKE_PROJECTDIR'] != nil
21
+ #raise "Error: BAKE_PROJDIR is missing!" if bhash['BAKE_PROJECTDIR'] == nil
20
22
 
21
23
  if splitOutputFile.length > splitProjMeta.length
22
24
  diffPathLevels = splitOutputFile.length-splitProjMeta.length
@@ -73,6 +75,11 @@ module BConv
73
75
  end
74
76
  end
75
77
  end
78
+ rescue Exception => e
79
+ puts e.message
80
+ puts e.backtrace.inspect if debugMode == true
81
+ exit(1)
82
+ end
76
83
  return directories
77
84
  end
78
85
 
data/lib/Util.rb CHANGED
@@ -11,7 +11,8 @@ class Util
11
11
  outputfilename = file
12
12
  else
13
13
  outputfilename = File.dirname(configFile) + "/" + file
14
- end
14
+ end
15
+ return outputfilename
15
16
  end
16
17
 
17
18
  def self.strToArray(key, map)
data/lib/Version.rb CHANGED
@@ -2,7 +2,7 @@ module BConv
2
2
 
3
3
  class Version
4
4
  def self.number
5
- "1.3.0"
5
+ return "1.4.0"
6
6
  end
7
7
  end
8
8
 
data/lib/bakeConverter.rb CHANGED
@@ -20,7 +20,8 @@ def main
20
20
  projToConvert = ""
21
21
  cfgFleFromCmdLne = ""
22
22
  setMock = false
23
- debugMode = false
23
+ debugMode = false
24
+ mapConverted = 0
24
25
 
25
26
  begin
26
27
  args = ARGV.select.each_with_index{|str, i| i.even? && str[0] == "-"}
@@ -36,7 +37,7 @@ def main
36
37
  end
37
38
 
38
39
  if ARGV.length == 1 && ARGV[0] != "--help" && ARGV[0] != "-h" && ARGV[0] != "--show_doc" && ARGV[0] != "--version" && ARGV[0] != "-v" && ARGV[0] != "--show_license" && ARGV[0] != "--mock"
39
- puts "Error: Too less arguments! (try --help)"
40
+ #puts "Error: Too less arguments! (try --help)"
40
41
  puts "Config file is missing!" if opts[0] == nil
41
42
  exit(-1)
42
43
  elsif ARGV.length == 0 || (ARGV.length == 1 && ARGV[0] == "--mock")
@@ -76,7 +77,6 @@ def main
76
77
  when "--debug"
77
78
  debugMode = true
78
79
  when "--show_doc"
79
- #Launchy.open(File.expand_path("../doc/doc.html", File.dirname(__FILE__)))
80
80
  Launchy.open("http://esrlabs.github.io/bakeConv/")
81
81
  exit(0)
82
82
  when "--show_license"
@@ -93,9 +93,9 @@ def main
93
93
  end
94
94
  end
95
95
 
96
- rescue => e
96
+ rescue Exception => e
97
97
  puts "Error in arguments!"
98
- puts e.to_s if debug_mode == true
98
+ puts e.backtrace if debugMode == true
99
99
  exit(-1)
100
100
  end
101
101
 
@@ -108,11 +108,10 @@ def main
108
108
  cp = BConv::ConfigParser.new(configFile, projToConvert, debugMode)
109
109
 
110
110
  puts "Reading config..."
111
- mappings = cp.readConfig
111
+ status, mappings = cp.readConfig
112
112
 
113
113
  abort "Error: Config file is empty OR the requested project(s) is commented out!" if mappings.length == 0
114
114
  puts "Converting #{mappings.length} projects..."
115
-
116
115
  idxCnt = 0
117
116
 
118
117
  mappings.each do |map|
@@ -126,22 +125,30 @@ def main
126
125
  bhash = bake.getHash(bakeLines)
127
126
  if bhash != nil
128
127
  map.each do |k,v|
129
- if (k == "GMOCK_FILTER" && v == "true") || k == "DEPENDENCIES_FILTER"
128
+ if (k == "EXCLUDE_BAKE_SOURCES") || (k == "EXCLUDE_BAKE_INCLUDES") || (k == "EXCLUDE_BAKE_DEPENDENCIES")
130
129
  bhash = BConv::Filter.hashFilter(k, v, bhash)
131
130
  end
132
131
  end
132
+ bhash_adapted = BConv::PathAdapt.adapt_path(map['OutputFile'], bhash, cfgFleFromCmdLne, debugMode)
133
133
  end
134
- bhash_adapted = BConv::PathAdapt.adapt_path(map['OutputFileName'], bhash, cfgFleFromCmdLne)
135
134
 
136
135
  if bhash_adapted != nil
137
- bhash_adapted.each {|k,v| map[k] = v unless (map.has_key?k && k!="DEPENDENCIES_FILTER")}
136
+ bhash_adapted.each {|k,v| map[k] = v unless (map.has_key?k)}
138
137
  conv = BConv::Converter.new(map, configFile, debugMode)
139
138
  puts "Convert..."
140
- conv.convert
139
+ status = conv.convert
140
+ mapConverted = mapConverted + 1 if status == 0
141
141
  end
142
142
  end
143
143
 
144
- puts "Done"
144
+ puts "Done: Converted #{mapConverted} from #{mappings.length} projects."
145
+
146
+ if (mapConverted == mappings.length) && (mapConverted != 0)
147
+ return exit(0)
148
+ else
149
+ return exit(1)
150
+ end
151
+
145
152
  end
146
153
 
147
154
  #-------------------------------------------------------
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bakeConv
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frauke Blossey
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-09-02 00:00:00.000000000 Z
11
+ date: 2015-09-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: launchy