bakeConv 1.1.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: de0d62b2e4b4cb0a0d2031a14bd2d7b06c2e1021
4
- data.tar.gz: 355d0d8980667abe73f3796a29f8984ae5182259
3
+ metadata.gz: 52b4f2a1ff3c69ac8093291b4d8ace6342b5f011
4
+ data.tar.gz: 969558efc184b693f78d5ce6e301909ab92d6c5d
5
5
  SHA512:
6
- metadata.gz: f2bd923915408545869109aaa1474f3e31726b07ba1e0ee5c313d82fc69cd687ecfb455c6ca8e2fdcaee5ac3fb327089196a9672bc13a8c41247d042ed259c04
7
- data.tar.gz: 85000592bd3b112b6648bbb87ccc588c9696d3a0d636d8eb2d43b202f5a749ca46b8e60474c1d0d00372b52f4a7d1d8d588e18e8396fb92336680a2384e6e8de
6
+ metadata.gz: e786e52fdad316208fbdd8d93acf5f685bd9b938e3fb5069c4e41e82e3592bb0c46ec1d17b6f191e5e5f033a6c144039643a67ec006cb94b74cd251fbd28b1b0
7
+ data.tar.gz: 211d6aac9f67465dd75b8cc47307cefbd8fcd9cb7fcbd30a58e769e458b52cf117ca59fd504f9d64aaf99b93d95d80757ba39cd76c4446169a3e52caa768287a
data/lib/Bake.rb CHANGED
@@ -25,6 +25,7 @@ module BConv
25
25
 
26
26
  def run
27
27
  bakeLines = ''
28
+ begin
28
29
  cmd = @setMock ? ['ruby','C:/_dev/projects/bakeMock/bakeMock/bakeMock.rb'] : ['bake']
29
30
  cmd << '-b' << @map['BuildConfig']
30
31
  cmd << '-m' << @map['MainProj']
@@ -36,6 +37,12 @@ module BConv
36
37
  bakeLines = `#{cmd.join(' ')}`
37
38
  end
38
39
 
40
+ rescue Exception => e
41
+ puts e.message
42
+ puts e.back_trace #for debug mode
43
+ abort
44
+ end
45
+
39
46
  abort "Error while trying to call bake!" unless $?.success?
40
47
  return bakeLines
41
48
  end
data/lib/Converter.rb CHANGED
@@ -26,8 +26,8 @@ module BConv
26
26
  File.readlines(fread).each do |line|
27
27
  lineIdx += 1
28
28
  wroteLine = false
29
- @map.keys.each do |key|
30
-
29
+ @map.keys.each do |key|
30
+
31
31
  if line.include?(key.to_s) && @map[key].include?(".txt")
32
32
  preAndPostfix = line.scan(/(.*)\$\$\(#{key}\)(.*)/)
33
33
  if preAndPostfix.length == 1
@@ -53,7 +53,6 @@ module BConv
53
53
  if m
54
54
  puts "Info: Key $$(#{m[1]}) in #{File.basename(filename)}, line #{tmpLineIdx.to_s} wasn\'t replaced!" if m
55
55
  end
56
- puts l
57
56
  fout.write(l)
58
57
  set = false
59
58
  end
@@ -63,7 +62,7 @@ module BConv
63
62
  @map.store(key,Util.strToArray(key, @map))
64
63
  wroteLine = findAndReplace(key, line, fout, "", "")
65
64
  break
66
- elsif line.match(/#{key.to_s}/)
65
+ elsif line.match(/\$\$\(#{key}\)/)
67
66
  wroteLine = findAndReplace(key, line, fout, "", "")
68
67
  break
69
68
  end
data/lib/Filter.rb ADDED
@@ -0,0 +1,41 @@
1
+ # Class Filter: provides function for filtering special values from hash
2
+ # Author: Frauke Blossey
3
+ # 06.08.2015
4
+
5
+ require_relative 'Util'
6
+
7
+ module BConv
8
+
9
+ class Filter
10
+
11
+ def self.hashFilter(keySearched, doFilter, hash)
12
+ 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"
20
+ 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
+ end
35
+ end
36
+ return hash
37
+ end
38
+
39
+ end
40
+
41
+ end
data/lib/PathAdapt.rb ADDED
@@ -0,0 +1,81 @@
1
+ # Class PathAdapt (methods to adapt paths relative to the location of the e.g. CMakeLists file)
2
+ # Author: Frauke Blossey
3
+ # 04.08.2015
4
+
5
+ module BConv
6
+
7
+ require_relative 'Util'
8
+
9
+ class PathAdapt
10
+ SLASH = "/"
11
+ COLON = ":"
12
+
13
+ def self.adapt_path(outputFilePath, bhash)
14
+ diffPathLevels, diffPathLevelsDown = 0, 0
15
+ dir, diffUp = "", ""
16
+ diffArr = []
17
+
18
+ splitOutputFile = File.expand_path(File.dirname(outputFilePath)).split("/")
19
+ splitProjMeta = bhash['BAKE_PROJECTDIR'][0].split("/")
20
+
21
+ if splitOutputFile.length > splitProjMeta.length
22
+ diffPathLevels = splitOutputFile.length-splitProjMeta.length
23
+ for j in (splitOutputFile.length-diffPathLevels)..(splitOutputFile.length-1)
24
+ diffUp += splitOutputFile[j] + "/"
25
+ diffArr << splitOutputFile[j]
26
+ end
27
+ for i in 0..diffPathLevels-1
28
+ dir += "../"
29
+ end
30
+ elsif splitOutputFile.length < splitProjMeta.length
31
+ diffPathLevelsDown = splitProjMeta.length-splitOutputFile.length
32
+ puts "Warning: this case is not supported!"
33
+ return nil
34
+ else
35
+ return bhash
36
+ end
37
+
38
+ pathNames = []
39
+ directories = {}
40
+
41
+ if File.dirname(outputFilePath).eql? File.dirname(bhash['BAKE_PROJECTDIR'][0])
42
+ #files do not have to be adapted
43
+ else
44
+ bhash.each do |key, value|
45
+ if key == 'BAKE_SOURCES' || key == 'BAKE_INCLUDES'
46
+ value.each do |pathElm|
47
+ if pathElm[0] == SLASH || pathElm[1] == COLON
48
+ pathNames << pathElm #nothing to do - is already absolute
49
+ elsif pathElm[0..diffUp.length-1].eql? diffUp
50
+ pathNames << pathElm.split(/^#{diffUp}/)[-1]
51
+ else
52
+ tmpElmArr = pathElm.split("/")
53
+ cnt = 0
54
+ dirLoc = ""
55
+ if tmpElmArr[0] != ".." #string does not start with ".."
56
+ for j in (0..diffArr.length-1)
57
+ if diffArr[j] != tmpElmArr[j]
58
+ cnt = cnt + 1
59
+ dirLoc << "../"
60
+ end
61
+ end
62
+ tmpElm = Util.truncateStr(diffUp,pathElm)
63
+ pathNames << (dirLoc + tmpElm)
64
+ else #string starts with ".." -> don't have to cut
65
+ pathNames << (dir + pathElm)
66
+ end
67
+ end
68
+ end
69
+ directories.store(key, pathNames)
70
+ pathNames = []
71
+ else
72
+ directories.store(key, value)
73
+ end
74
+ end
75
+ end
76
+ return directories
77
+ end
78
+
79
+ end
80
+
81
+ end
data/lib/Util.rb CHANGED
@@ -17,5 +17,19 @@ class Util
17
17
  def self.strToArray(key, map)
18
18
  map[key][1..-2].split(",").map {|elem| elem.strip}
19
19
  end
20
+
21
+ def self.truncateStr(refStr, toTruncStr)
22
+ posOfSlash = refStr.index("/")
23
+ while posOfSlash != nil && toTruncStr[0..1] != ".."
24
+ if refStr[0..posOfSlash] == toTruncStr[0..posOfSlash]
25
+ toTruncStr = toTruncStr[posOfSlash+1..-1]
26
+ refStr = refStr[posOfSlash+1..-1]
27
+ else
28
+ break
29
+ end
30
+ posOfSlash = refStr.index("/")
31
+ end
32
+ return toTruncStr
33
+ end
20
34
 
21
35
  end
data/lib/Version.rb CHANGED
@@ -2,7 +2,7 @@ module BConv
2
2
 
3
3
  class Version
4
4
  def self.number
5
- "1.1.1"
5
+ "1.2.2"
6
6
  end
7
7
  end
8
8
 
data/lib/bakeConverter.rb CHANGED
@@ -9,6 +9,8 @@ require_relative 'Bake'
9
9
  require_relative 'Converter'
10
10
  require_relative 'Version'
11
11
  require_relative 'Help'
12
+ require_relative 'PathAdapt'
13
+ require_relative 'Filter'
12
14
 
13
15
  def main
14
16
  #-------------------------------------------------------
@@ -69,7 +71,8 @@ def main
69
71
  BConv::Help.printHelp
70
72
  exit(0)
71
73
  when "--show_doc"
72
- Launchy.open(File.expand_path("../doc/doc.html", File.dirname(__FILE__)))
74
+ #Launchy.open(File.expand_path("../doc/doc.html", File.dirname(__FILE__)))
75
+ Launchy.open("http://esrlabs.github.io/bakeConv/")
73
76
  exit(0)
74
77
  when "--show_license"
75
78
  puts
@@ -112,10 +115,19 @@ def main
112
115
  puts "Call Bake..."
113
116
  bake = BConv::Bake.new(map, setMock, configFile)
114
117
  bakeLines = bake.run
118
+ #puts bakeLines
115
119
  bhash = bake.getHash(bakeLines)
116
120
  if bhash != nil
117
- bhash.each {|k,v| map[k] = v unless map.has_key?k}
118
- #map.merge!(bhash)
121
+ map.each do |k,v|
122
+ if (k == "GMOCK_FILTER" && v == "true") || k == "DEPENDENCIES_FILTER"
123
+ bhash = BConv::Filter.hashFilter(k, v, bhash)
124
+ end
125
+ end
126
+ end
127
+ bhash_adapted = BConv::PathAdapt.adapt_path(map['OutputFileName'], bhash)
128
+
129
+ if bhash_adapted != nil
130
+ bhash_adapted.each {|k,v| map[k] = v unless (map.has_key?k && k!="DEPENDENCIES_FILTER")}
119
131
  conv = BConv::Converter.new(map, configFile)
120
132
  puts "Convert..."
121
133
  conv.convert
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.1.1
4
+ version: 1.2.2
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-06-25 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: launchy
@@ -36,11 +36,12 @@ files:
36
36
  - lib/ConfigParser.rb
37
37
  - lib/Converter.rb
38
38
  - lib/File_ext.rb
39
+ - lib/Filter.rb
39
40
  - lib/Help.rb
41
+ - lib/PathAdapt.rb
40
42
  - lib/Util.rb
41
43
  - lib/Version.rb
42
44
  - lib/bakeConverter.rb
43
- - doc/doc.html
44
45
  - license.txt
45
46
  - bin/bakeConv
46
47
  homepage:
data/doc/doc.html DELETED
@@ -1,44 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Documentation of bakeConv</title>
5
- <style type="text/css">
6
- #rundrum {
7
- border-width:1px;
8
- border-style:dashed;
9
- border-color:blue;
10
- padding:0.2cm;
11
- text-align:justify; }
12
- </style>
13
- </head>
14
-
15
- <body>
16
-
17
- <h1>bakeConv</h1>
18
- bake converter is used to convert from bake to some other file, e.g. CMake file, which depends on your template file.
19
-
20
- <h2>GuideLines</h2>
21
- <h3>Concepts</h3>
22
- <ul>
23
- <li><a href="concepts/configfile.html">The configuration file Converter.config</a>
24
- <li><a href="concepts/templatefile.html">The template file</a>
25
- </ul>
26
-
27
- <h3>Command Line</h3>
28
- <ul>
29
- <li><a href="cmd/install.html">How to install bake converter</a>
30
- <li><a href="cmd/usecmd.html">How to use bake converter on command line</a>
31
- </ul>
32
-
33
- <h3>Further readings</h3>
34
- <ul>
35
- <li><a href="further/change.html">Changelog</a>
36
- </ul>
37
-
38
- <p>
39
- <hr>
40
- <table width="100%" border="0"><tr><td align="left">Described bakeConv version: 1.0.2</td><td align="right">June 11, 2015</td></tr></table>
41
-
42
-
43
- </body>
44
- </html>