Skip to content

Commit

Permalink
Install ragel during build if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
jaynetics committed Feb 8, 2023
1 parent 2e202f3 commit b3ea02a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 11 deletions.
11 changes: 1 addition & 10 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,4 @@ set -euo pipefail
bundle

# install ragel
if [[ $(command -v ragel) == "" ]]; then
if [[ $(command -v brew) != "" ]]; then
brew install ragel
elif [[ $(command -v apt-get) != "" ]]; then
sudo apt-get install -y ragel
else
echo "could not install ragel, please do so manually"
exit 1
fi
fi
rake ragel:install
17 changes: 16 additions & 1 deletion tasks/ragel.rake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ RAGEL_SOURCE_FILES = %w[scanner] # scanner.rl imports the other files

namespace :ragel do
desc 'Process the ragel source files and output ruby code'
task :rb do
task rb: :install do
RAGEL_SOURCE_FILES.each do |source_file|
output_file = "#{RAGEL_OUTPUT_DIR}/#{source_file}.rb"
# using faster flat table driven FSM, about 25% larger code, but about 30% faster
Expand All @@ -26,4 +26,19 @@ namespace :ragel do
sh "rm -f #{RAGEL_OUTPUT_DIR}/#{file}.rb"
end
end

desc 'Make sure that ragel is installed'
task :install do
if system('command -v ragel')
# already installed
elsif system('command -v brew')
puts 'ragel not found, installing with homebrew ...'
`brew install ragel`
elsif system('command -v apt-get')
puts 'ragel not found, installing with apt-get ...'
`sudo apt-get install -y ragel`
else
raise 'Could not install ragel. Please install it manually.'
end
end
end

0 comments on commit b3ea02a

Please sign in to comment.