-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCreateNewFragmentGenerator.rb
More file actions
executable file
·72 lines (53 loc) · 1.84 KB
/
CreateNewFragmentGenerator.rb
File metadata and controls
executable file
·72 lines (53 loc) · 1.84 KB
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
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
#!/bin/env ruby
require 'fileutils'
if ARGV.length != 2
puts "Usage: " + __FILE__ + " <Fragment generator token> <Fragment token>"
exit 1
end
fraggentoken = ARGV[0]
fragtoken = ARGV[1]
if ! ENV['ARTDAQDEMO_REPO']
puts "Couldn\'t find ARTDAQDEMO_REPO variable; have you sourced setupARTDAQDEMO?"
exit 1
end
basedir = ENV['ARTDAQDEMO_REPO']
gendir = basedir + "/artdaq-demo/Generators/"
overlaydir = basedir + "/artdaq-demo/Overlays/"
Dir.chdir basedir
sourcefiles = []
# Copy the Toy* source files to the source files for the new code
[".hh", "_generator.cc"].each do |ext|
#puts gendir + "ToySimulator" + ext + " " + gendir + fraggentoken + ext
FileUtils.cp( gendir + "ToySimulator" + ext , gendir + fraggentoken + ext )
sourcefiles << gendir + fraggentoken + ext
end
[".hh", ".cc", "Writer.hh"].each do |ext|
#puts overlaydir + "ToyFragment" + ext + " " + overlaydir + fragtoken + "Fragment" + ext
FileUtils.cp( overlaydir + "ToyFragment" + ext , overlaydir + fragtoken + "Fragment" + ext )
sourcefiles << overlaydir + fragtoken + "Fragment" + ext
end
# Search-and-replace the fragment and fragment generator names, using
# the tokens passed at the command line
sourcefiles.each do |sourcefile|
sourcetext = File.read( sourcefile )
sourcetext = sourcetext.gsub('ToySimulator', fraggentoken)
sourcetext = sourcetext.gsub('Toy', fragtoken)
outf = File.open( sourcefile, 'w')
outf.puts sourcetext
end
# Add in the new generator to the CMakeLists.txt file for compilation
sourcetext = File.read( gendir + "CMakeLists.txt" )
sourcetext += "\n\n"
sourcetext += "simple_plugin(" + fraggentoken + " \"generator\"\n"
sourcetext += <<-'EOS'
artdaq-demo_Overlays
artdaq_Application
artdaq_DAQdata
artdaq_Utilities
art_Utilities
${FHICLCPP}
${CETLIB}
)
EOS
outf = File.open( gendir + "CMakeLists.txt", 'w')
outf.puts sourcetext