2 # create-algo-impl-relation.rb
4 This file is part of the AVR-Crypto-Lib.
5 Copyright (C) 2008, 2009 Daniel Otte (daniel.otte@rub.de)
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 SPEED_DIR = 'speed_log/'
22 SIZE_DIR = 'size_log/'
23 OUT_DIR = 'algo_implementation/'
30 def get_module_names(finname)
32 f = File.open(finname, 'r')
33 f.gets # first line is ignored
35 if m=l.match(/[\s]([^\s]*)$/)
44 def mkalgoimplrelation_file(foutname, finname, algos)
46 puts "ERROR: algos==nil! fout=#{foutname} fin=#{finname}"
49 if File.exists?(foutname)
50 puts "File #{foutname} already exists!"
53 modules = get_module_names(finname).join(' ')
54 f = File.open(foutname, 'w')
56 f.puts(algo+': '+modules)
62 if not File.directory?(SPEED_DIR)
63 puts "ERROR: #{SPEED_DIR} is no directory!"
67 if not File.directory?(SIZE_DIR)
68 puts "ERROR: #{SIZE_DIR} is no directory!"
72 if not File.directory?(OUT_DIR)
73 puts "ERROR: #{OUT_DIR} is no directory!"
77 list = Dir.entries(SPEED_DIR)
80 if m=entry.match(/([^.]*)\.([^.]*)\.txt/)
81 algo_list[m[2]] = Array.new if algo_list[m[2]]==nil
82 algo_list[m[2]] << m[1]
86 list = Dir.entries(SIZE_DIR)
88 if m=entry.match(/([^.]*)\.size/)
89 mkalgoimplrelation_file(OUT_DIR+m[1]+'.algos', SIZE_DIR+entry, algo_list[m[1]])