File: embedSdf.rb

package info (click to toggle)
sdformat 12.3.0%2Bds-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 7,980 kB
  • sloc: cpp: 54,706; python: 3,729; javascript: 704; ruby: 366; sh: 97; ansic: 30; makefile: 16
file content (45 lines) | stat: -rwxr-xr-x 1,171 bytes parent folder | download
1
2
3
4
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
#!/usr/bin/env ruby

# The list of supported SDF specification versions. This will let us drop
# versions without removing the directories.
supportedSdfVersions = ['1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3', '1.2']

# The list of supported SDF conversions. This list includes versions that
# a user can convert an existing SDF version to.
supportedSdfConversions = ['1.9', '1.8', '1.7', '1.6', '1.5', '1.4', '1.3']

puts %q!
#include "EmbeddedSdf.hh"

namespace sdf {
inline namespace SDF_VERSION_NAMESPACE {

const std::map<std::string, std::string> &GetEmbeddedSdf() {
  static const std::map<std::string, std::string> result{
!

# Stores the contents of the file in the map.
def embed(pathname)
  puts "{\"#{pathname}\", R\"__sdf_literal__("
  infile = File.open(pathname)
  puts infile.read
  puts ")__sdf_literal__\"},"
end

# Embed the supported *.sdf files.
supportedSdfVersions.each do |version|
  Dir.glob("#{version}/*.sdf").sort.each { |file| embed(file) }
end

# Embed the supported *.convert files.
supportedSdfConversions.each do |version|
  Dir.glob("#{version}/*.convert").sort.each { |file| embed(file) }
end
puts %q!
  };
  return result;
}

}
}
!