Add hhvm subtasks
This commit is contained in:
parent
d349a90636
commit
bdb3b929fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -25,3 +25,4 @@
|
||||
/config/config.rb
|
||||
/vendor/
|
||||
/.bundle/
|
||||
/pkg/
|
||||
|
@ -7,6 +7,26 @@
|
||||
require_relative '../config/config'
|
||||
require_relative 'package'
|
||||
require 'net/http'
|
||||
require 'pathname'
|
||||
|
||||
module SlackBuilder
|
||||
extend Rake::FileUtilsExt
|
||||
|
||||
def self.clone(repo, package, tag_prefix = 'v')
|
||||
repository = Pathname.new('pkg') + package.name_version
|
||||
|
||||
if repository.directory?
|
||||
sh 'git', '-C', repository.to_path, 'remote', 'update', '--prune'
|
||||
else
|
||||
sh 'git', 'clone', repo, repository.to_path
|
||||
end
|
||||
|
||||
sh 'git', '-C', repository.to_path, 'checkout', "#{tag_prefix}#{package.version}"
|
||||
sh 'git', '-C', repository.to_path, 'submodule', 'update', '--init', '--recursive'
|
||||
|
||||
repository
|
||||
end
|
||||
end
|
||||
|
||||
def write_download(target, response)
|
||||
checksum = Digest::MD5.new
|
||||
|
@ -17,6 +17,10 @@ class Package
|
||||
def name
|
||||
File.basename @path
|
||||
end
|
||||
|
||||
def name_version
|
||||
"#{name}-#{@version}"
|
||||
end
|
||||
end
|
||||
|
||||
class Download
|
||||
|
67
rakelib/hhvm.rake
Normal file
67
rakelib/hhvm.rake
Normal file
@ -0,0 +1,67 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
# frozen_string_literal: true
|
||||
|
||||
namespace :hhvm do
|
||||
desc 'Generates diffs with removed download URLs'
|
||||
task :bundled_dependencies, [:version] do |_, arguments|
|
||||
run_on_source arguments[:version] do |third_party|
|
||||
c_make_lists = third_party + 'CMakeLists.txt'
|
||||
next unless c_make_lists.exist?
|
||||
|
||||
contents = c_make_lists.read
|
||||
set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('
|
||||
next if set_hhvm_start.nil?
|
||||
|
||||
line = contents[..set_hhvm_start].count "\n"
|
||||
in_lines = contents.lines
|
||||
4.times { in_lines.delete_at(line + 2) }
|
||||
|
||||
puts Open3.capture2('diff', '-Nur', c_make_lists.to_path, '-', stdin_data: in_lines.join).first
|
||||
end
|
||||
end
|
||||
|
||||
desc 'Generated SlackBuild code to prepare bundled dependencies'
|
||||
task :bundled_code, [:version] do |_, arguments|
|
||||
run_on_source arguments[:version] do |third_party|
|
||||
c_make_lists = third_party + 'CMakeLists.txt'
|
||||
next unless c_make_lists.exist?
|
||||
|
||||
contents = c_make_lists.read
|
||||
set_hhvm_start = contents.index 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('
|
||||
next if set_hhvm_start.nil?
|
||||
|
||||
set_hhvm_end = contents.index ')', set_hhvm_start
|
||||
set_hhvm_start += 'SET_HHVM_THIRD_PARTY_SOURCE_ARGS('.length
|
||||
set_hhvm_end -= 1
|
||||
contents = contents[set_hhvm_start..set_hhvm_end].split[1..].map(&:strip)
|
||||
|
||||
src = Pathname.new('third-party') +
|
||||
third_party.basename +
|
||||
"bundled_#{third_party.basename}-prefix" + 'src'
|
||||
bundled = src + "bundled_#{third_party.basename}"
|
||||
archive_name = contents[1][contents[1].rindex('/') + 1..-2]
|
||||
|
||||
puts "mkdir -p #{bundled}"
|
||||
puts "install -m 0644 -D $CWD/#{archive_name} #{src + archive_name}"
|
||||
puts "tar -zxvf $CWD/#{archive_name} -C #{bundled}"
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_on_source(version, &block)
|
||||
package = Package.new 'development/hhvm',
|
||||
version: version,
|
||||
homepage: 'https://hhvm.com/',
|
||||
requires: %w[tbb glog libdwarf libmemcached dobule-conversion]
|
||||
repository = SlackBuilder.clone 'https://github.com/facebook/hhvm.git', package, 'HHVM-'
|
||||
|
||||
(repository + 'third-party').each_child do |third_party|
|
||||
block.call third_party
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user