Skip to content

Commit b3ea02a

Browse files
committed
Install ragel during build if needed
1 parent 2e202f3 commit b3ea02a

File tree

2 files changed

+17
-11
lines changed

2 files changed

+17
-11
lines changed

bin/setup

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,4 @@ set -euo pipefail
55
bundle
66

77
# install ragel
8-
if [[ $(command -v ragel) == "" ]]; then
9-
if [[ $(command -v brew) != "" ]]; then
10-
brew install ragel
11-
elif [[ $(command -v apt-get) != "" ]]; then
12-
sudo apt-get install -y ragel
13-
else
14-
echo "could not install ragel, please do so manually"
15-
exit 1
16-
fi
17-
fi
8+
rake ragel:install

tasks/ragel.rake

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RAGEL_SOURCE_FILES = %w[scanner] # scanner.rl imports the other files
44

55
namespace :ragel do
66
desc 'Process the ragel source files and output ruby code'
7-
task :rb do
7+
task rb: :install do
88
RAGEL_SOURCE_FILES.each do |source_file|
99
output_file = "#{RAGEL_OUTPUT_DIR}/#{source_file}.rb"
1010
# using faster flat table driven FSM, about 25% larger code, but about 30% faster
@@ -26,4 +26,19 @@ namespace :ragel do
2626
sh "rm -f #{RAGEL_OUTPUT_DIR}/#{file}.rb"
2727
end
2828
end
29+
30+
desc 'Make sure that ragel is installed'
31+
task :install do
32+
if system('command -v ragel')
33+
# already installed
34+
elsif system('command -v brew')
35+
puts 'ragel not found, installing with homebrew ...'
36+
`brew install ragel`
37+
elsif system('command -v apt-get')
38+
puts 'ragel not found, installing with apt-get ...'
39+
`sudo apt-get install -y ragel`
40+
else
41+
raise 'Could not install ragel. Please install it manually.'
42+
end
43+
end
2944
end

0 commit comments

Comments
 (0)