mirror of
https://github.com/rubyjs/libv8
synced 2023-03-27 23:21:48 -04:00
Revamp patching functionality and add clang patches
This commit fixes #94 and closes #105
This commit is contained in:
parent
73d93ea4a0
commit
2a5af64d0e
8 changed files with 115 additions and 15 deletions
|
@ -3,12 +3,14 @@ require File.expand_path '../compiler', __FILE__
|
||||||
require File.expand_path '../arch', __FILE__
|
require File.expand_path '../arch', __FILE__
|
||||||
require File.expand_path '../make', __FILE__
|
require File.expand_path '../make', __FILE__
|
||||||
require File.expand_path '../checkout', __FILE__
|
require File.expand_path '../checkout', __FILE__
|
||||||
|
require File.expand_path '../patcher', __FILE__
|
||||||
|
|
||||||
module Libv8
|
module Libv8
|
||||||
class Builder
|
class Builder
|
||||||
include Libv8::Arch
|
include Libv8::Arch
|
||||||
include Libv8::Make
|
include Libv8::Make
|
||||||
include Libv8::Checkout
|
include Libv8::Checkout
|
||||||
|
include Libv8::Patcher
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@compiler = choose_compiler
|
@compiler = choose_compiler
|
||||||
|
@ -45,7 +47,7 @@ module Libv8
|
||||||
checkout!
|
checkout!
|
||||||
setup_python!
|
setup_python!
|
||||||
setup_build_deps!
|
setup_build_deps!
|
||||||
apply_patches!
|
patch! *patch_directories_for(@compiler)
|
||||||
print_build_info
|
print_build_info
|
||||||
puts `env CXX=#{@compiler} LINK=#{@compiler} #{make} #{make_flags}`
|
puts `env CXX=#{@compiler} LINK=#{@compiler} #{make} #{make_flags}`
|
||||||
end
|
end
|
||||||
|
@ -73,18 +75,6 @@ module Libv8
|
||||||
`ln -fs #{GYP_Source} build/gyp`
|
`ln -fs #{GYP_Source} build/gyp`
|
||||||
end
|
end
|
||||||
|
|
||||||
def apply_patches!
|
|
||||||
File.open(".applied_patches", File::RDWR|File::CREAT) do |f|
|
|
||||||
available_patches = Dir.glob(File.expand_path '../../../patches/*.patch', __FILE__).sort
|
|
||||||
applied_patches = f.readlines.map(&:chomp)
|
|
||||||
|
|
||||||
(available_patches - applied_patches).each do |patch|
|
|
||||||
`patch -p1 -N < #{patch}`
|
|
||||||
f.puts patch
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def choose_compiler
|
def choose_compiler
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Libv8
|
||||||
end
|
end
|
||||||
|
|
||||||
def compatible?
|
def compatible?
|
||||||
version > '3.1'
|
version >= '3.1'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Libv8
|
||||||
end
|
end
|
||||||
|
|
||||||
def compatible?
|
def compatible?
|
||||||
version > '4.2' and version < '4.9'
|
version > '4.3' and version < '4.9'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
54
ext/libv8/patcher.rb
Normal file
54
ext/libv8/patcher.rb
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
module Libv8
|
||||||
|
module Patcher
|
||||||
|
PATCH_DIRECTORY = File.expand_path '../../../patches', __FILE__
|
||||||
|
|
||||||
|
module_function
|
||||||
|
|
||||||
|
def patch_directories_for(compiler)
|
||||||
|
patch_directories = []
|
||||||
|
|
||||||
|
case
|
||||||
|
when compiler.target =~ /arm/
|
||||||
|
patch_directories += 'arm'
|
||||||
|
end
|
||||||
|
|
||||||
|
case compiler
|
||||||
|
when Compiler::GCC
|
||||||
|
patch_directories << 'gcc48' if compiler.version >= '4.8'
|
||||||
|
when Compiler::Clang
|
||||||
|
patch_directories << 'clang'
|
||||||
|
patch_directories << 'clang33' if compiler.version >= '3.3'
|
||||||
|
end
|
||||||
|
|
||||||
|
patch_directories
|
||||||
|
end
|
||||||
|
|
||||||
|
def patch_directories(*additional_directories)
|
||||||
|
absolute_paths = [PATCH_DIRECTORY]
|
||||||
|
|
||||||
|
additional_directories.each do |directory|
|
||||||
|
absolute_paths << File.join(PATCH_DIRECTORY, directory)
|
||||||
|
end
|
||||||
|
|
||||||
|
absolute_paths.uniq
|
||||||
|
end
|
||||||
|
|
||||||
|
def patches(*additional_directories)
|
||||||
|
patch_directories(*additional_directories).map do |directory|
|
||||||
|
Dir.glob(File.join directory, '*.patch')
|
||||||
|
end.flatten.sort
|
||||||
|
end
|
||||||
|
|
||||||
|
def patch!(*additional_directories)
|
||||||
|
File.open(".applied_patches", File::RDWR|File::CREAT) do |f|
|
||||||
|
available_patches = patches *additional_directories
|
||||||
|
applied_patches = f.readlines.map(&:chomp)
|
||||||
|
|
||||||
|
(available_patches - applied_patches).each do |patch|
|
||||||
|
`patch -p1 -N < #{patch}`
|
||||||
|
f.puts patch
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
28
patches/clang/no-unused-private-field.patch
Normal file
28
patches/clang/no-unused-private-field.patch
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
diff --git a/build/common.gypi b/build/common.gypi
|
||||||
|
index 3a59639..14bf0f9 100644
|
||||||
|
--- a/build/common.gypi
|
||||||
|
+++ b/build/common.gypi
|
||||||
|
@@ -376,7 +376,8 @@
|
||||||
|
}],
|
||||||
|
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
|
||||||
|
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
|
||||||
|
- '-Wnon-virtual-dtor', '-Woverloaded-virtual' ],
|
||||||
|
+ '-Wnon-virtual-dtor', '-Woverloaded-virtual',
|
||||||
|
+ '-Wno-unused-private-field' ],
|
||||||
|
}],
|
||||||
|
['OS=="linux" and v8_enable_backtrace==1', {
|
||||||
|
# Support for backtrace_symbols.
|
||||||
|
diff --git a/build/standalone.gypi b/build/standalone.gypi
|
||||||
|
index 125c5bf..c8d9b4f 100644
|
||||||
|
--- a/build/standalone.gypi
|
||||||
|
+++ b/build/standalone.gypi
|
||||||
|
@@ -98,7 +98,8 @@
|
||||||
|
'target_defaults': {
|
||||||
|
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
|
||||||
|
'-Wnon-virtual-dtor', '-pthread', '-fno-rtti',
|
||||||
|
- '-fno-exceptions', '-pedantic' ],
|
||||||
|
+ '-fno-exceptions', '-pedantic',
|
||||||
|
+ '-Wno-unused-private-field' ],
|
||||||
|
'ldflags': [ '-pthread', ],
|
||||||
|
'conditions': [
|
||||||
|
[ 'OS=="linux"', {
|
|
@ -0,0 +1,28 @@
|
||||||
|
diff --git a/build/common.gypi b/build/common.gypi
|
||||||
|
index 14bf0f9..301109a 100644
|
||||||
|
--- a/build/common.gypi
|
||||||
|
+++ b/build/common.gypi
|
||||||
|
@@ -377,7 +377,8 @@
|
||||||
|
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
|
||||||
|
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
|
||||||
|
'-Wnon-virtual-dtor', '-Woverloaded-virtual',
|
||||||
|
- '-Wno-unused-private-field' ],
|
||||||
|
+ '-Wno-unused-private-field', '-Wno-nested-anon-types',
|
||||||
|
+ '-Wno-unused-function' ],
|
||||||
|
}],
|
||||||
|
['OS=="linux" and v8_enable_backtrace==1', {
|
||||||
|
# Support for backtrace_symbols.
|
||||||
|
diff --git a/build/standalone.gypi b/build/standalone.gypi
|
||||||
|
index c8d9b4f..ddd1693 100644
|
||||||
|
--- a/build/standalone.gypi
|
||||||
|
+++ b/build/standalone.gypi
|
||||||
|
@@ -99,7 +99,8 @@
|
||||||
|
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
|
||||||
|
'-Wnon-virtual-dtor', '-pthread', '-fno-rtti',
|
||||||
|
'-fno-exceptions', '-pedantic',
|
||||||
|
- '-Wno-unused-private-field' ],
|
||||||
|
+ '-Wno-unused-private-field', '-Wno-nested-anon-types',
|
||||||
|
+ '-Wno-unused-function' ],
|
||||||
|
'ldflags': [ '-pthread', ],
|
||||||
|
'conditions': [
|
||||||
|
[ 'OS=="linux"', {
|
Loading…
Reference in a new issue