Skip to content

Commit

Permalink
Initial version of a Phar archive builder
Browse files Browse the repository at this point in the history
  • Loading branch information
drslump committed Feb 1, 2012
1 parent 194d5fc commit 8273a91
Showing 1 changed file with 45 additions and 1 deletion.
46 changes: 45 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ namespace :pear do
task :package => ['doc:build', :xml] do

# Copy supporting files to the package root

support_files.each do |file|
cp file, "library/#{file}"
end
Expand Down Expand Up @@ -69,6 +68,51 @@ namespace :pear do

end


namespace :phar do

phar_file = "protobuf.phar"

desc "Build a phar archive"
task :build do
unless ENV['version'] then
puts 'Version number not given. Use "phar:build version=1.0"'
exit 1
end

puts "Creating a temporary directory with the files..."

# Create a temporary directory
tmp_dest = "/tmp/phar-#{Time.now.to_i}"
mkdir_p tmp_dest

# Copy library files there
cp_r "library/", tmp_dest

# Process copied files, replacing @package_version@
version = ENV['version'] + '-phar'
FileList["#{tmp_dest}/**/*.php"].each do |fpath|
puts fpath
sh "sed -i.bak 's/@package_version@/#{version}/g' #{fpath}"
end

puts "Launching phar builder..."
sh "phar pack -f #{phar_file} -s protoc-gen-php.php -c bz2 -h sha1 #{tmp_dest}/library"

puts "Cleaning up temporary directory..."
rm_r tmp_dest
end

desc "Clean up"
task :clean do
puts "Cleaning up..."

# Remove the phar file
rm_f phar_file
end
end


namespace :doc do

desc "Generate manual"
Expand Down

0 comments on commit 8273a91

Please sign in to comment.