diff options
author | Kazuki Yamaguchi <k@rhe.jp> | 2016-01-11 19:38:04 +0900 |
---|---|---|
committer | Kazuki Yamaguchi <k@rhe.jp> | 2016-01-11 19:38:04 +0900 |
commit | 5f78d95ac909738f6a54c8ad707ea659cf2d6ab3 (patch) | |
tree | 987a2b42417c535bdb1f1bf4dcc1e8ef079502d9 /lib | |
parent | e85ec9eee7e1e8a0640d1a189a9b5504bd5ea7eb (diff) | |
download | poe-5f78d95ac909738f6a54c8ad707ea659cf2d6ab3.tar.gz |
support PHP
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tasks/compiler.rake | 33 |
1 files changed, 31 insertions, 2 deletions
diff --git a/lib/tasks/compiler.rake b/lib/tasks/compiler.rake index f86bd57..214d7f3 100644 --- a/lib/tasks/compiler.rake +++ b/lib/tasks/compiler.rake @@ -9,8 +9,8 @@ namespace :compiler do "2.1.8" => "https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.8.tar.gz", } desc "Install a ruby" - task :install, :version - task install: :environment do |t, args| + task :ruby, :version + task ruby: :environment do |t, args| url = RUBIES[args[:version]] or raise(ArgumentError, "unknown ruby") name = url.split("/").last @@ -32,4 +32,33 @@ namespace :compiler do } } end + + PHPS = { + "7.0.2" => "http://jp2.php.net/distributions/php-7.0.2.tar.gz", + "5.6.17" => "http://jp2.php.net/distributions/php-5.6.17.tar.gz", + } + desc "Install a php" + task :php, :version + task php: :environment do |t, args| + url = PHPS[args[:version]] or raise(ArgumentError, "unknown php") + name = url.split("/").last + + destdir = Rails.root.join("playground/php/#{args[:version]}") + raise ArgumentError, "already installed?" if Dir.exist?(destdir.to_s) + prefix = "/opt" + + Dir.mktmpdir { |dir| + FileUtils.chdir(dir) { + system("curl -O #{Shellwords.escape(url)}") or raise("failed to download") + system("tar xf #{Shellwords.escape(name)}") or raise("failed to extract") + FileUtils.chdir(name.split(".tar.gz").first) { + system("./configure --prefix=#{prefix} --enable-shared") or raise("failed to configure") + system("make -j6") or raise("failed to make") + system("make install INSTALL_ROOT=#{destdir.to_s}") or raise("failed to install") + + Compiler.create!(language: "php", version: args[:version], command_line: "#{prefix}/bin/php PROGRAM") + } + } + } + end end |