forked from EricssonResearch/EDHOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRakefile
38 lines (32 loc) · 936 Bytes
/
Rakefile
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
require "rexml/document"
require "rexml/xpath"
include REXML
XMLFILE = "ecdhe.xml"
CDDLFILE = "ecdhe.cddl"
CDDLFILE_p1 = "ecdhe_extract.cddl"
task :verify => [CDDLFILE, XMLFILE] do |t|
doc = Document.new(File.read(XMLFILE))
XPath.each(doc, "//artwork[@type='CBORdiag']/text()") do |snip|
IO.popen("diag2cbor.rb | cddl #{CDDLFILE} v -", 'r+') do |io|
io.write snip.to_s.gsub("nil", "null").gsub(/\n\s*/, "")
io.close_write
p io.read
end
end
end
task :gen => CDDLFILE do |t|
sh "cddl #{t.source} g"
end
file CDDLFILE_p1 => [XMLFILE] do |t|
doc = Document.new(File.read(t.source))
File.open(t.name, "w") do |f|
f.puts XPath.match(doc, "//artwork[@type='CDDL']/text()").to_a.join.gsub(">", ">")
end
end
file CDDLFILE => ["prefix.cddl", CDDLFILE_p1, "cose.cddl"] do |t|
doc = File.open(t.name, "w")
t.prerequisites.each do |src|
doc2 = File.read(src)
doc.puts doc2
end
end