File indexing completed on 2024-05-05 04:36:54
0001 ## 0002 # This file is part of KDevelop 0003 # Copyright (C) 2011-2015 Miquel Sabaté Solà <mikisabate@gmail.com> 0004 # 0005 # This program is free software: you can redistribute it and/or modify 0006 # it under the terms of the GNU General Public License as published by 0007 # the Free Software Foundation, either version 3 of the License, or 0008 # (at your option) any later version. 0009 # 0010 # This program is distributed in the hope that it will be useful, 0011 # but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 # GNU General Public License for more details. 0014 # 0015 # You should have received a copy of the GNU General Public License 0016 # along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 0018 0019 #!/usr/bin/env ruby 0020 0021 ## 0022 # This script just calls gperf with the correct arguments in order 0023 # to generate the hash.c file. 0024 0025 0026 # Check if the given program exists on your system. 0027 # 0028 # program - a String containing the name of the program. 0029 # 0030 # Returns true if the program exists on your system, false otherwise. 0031 def exists? program 0032 ENV['PATH'].split(File::PATH_SEPARATOR).any? do |directory| 0033 File.executable?(File.join(directory, program.to_s)) 0034 end 0035 end 0036 0037 # Check if exists gperf on your system 0038 unless exists? 'gperf' 0039 puts 'You need gperf to run this script' 0040 exit 0041 end 0042 0043 # Let's execute gperf with the appropiate arguments. 0044 0045 GFLAGS = '-C -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$ gperf.txt > ../hash.c' 0046 0047 puts 'Using gperf to generate hash.c' 0048 `gperf #{GFLAGS}` 0049 text = File.read('../hash.c').gsub /{""}/, '{"", {0,0}, 0}' 0050 File.open('../hash.c', 'w') { |file| file.puts text }