Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit e5524b2

Browse files
committed
Remove all conditional logic for the patches
Not having to silence individual warnings frees us from the burden of applying different patches for different compilers and compiler versions.
1 parent 10f4356 commit e5524b2

4 files changed

Lines changed: 17 additions & 49 deletions

File tree

ext/libv8/builder.rb

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ def make_target
2020
profile = enable_config('debug') ? 'debug' : 'release'
2121
"#{libv8_arch}.#{profile}"
2222
end
23-
23+
2424
def make_flags(*flags)
2525
# FreeBSD uses gcc 4.2 by default which leads to
2626
# compilation failures due to warnings about aliasing.
@@ -49,24 +49,29 @@ def make_flags(*flags)
4949
end
5050

5151
def build_libv8!
52+
checkout!
53+
setup_python!
5254
Dir.chdir(V8_Source) do
53-
fail 'No compilers available' if @compiler.nil?
54-
checkout!
55-
setup_python!
5655
setup_build_deps!
57-
patch! *patch_directories_for(@compiler)
56+
fail 'No compilers available' if @compiler.nil?
57+
patch!
5858
print_build_info
59+
puts 'Beginning compilation. This will take some time.'
60+
61+
command = "env CXX=#{@compiler} LINK=#{@compiler}"
5962

6063
case RUBY_PLATFORM
6164
when /mingw/
6265
# use a script that will fix the paths in the generated Makefiles
6366
# don't use make_flags otherwise it will trigger a rebuild of the Makefiles
6467
system "env CXX=#{@compiler} LINK=#{@compiler} bash #{PATCH_DIRECTORY}/mingw-generate-makefiles.sh"
65-
system "env CXX=#{@compiler} LINK=#{@compiler} make #{make_target}"
66-
68+
command += " make #{make_target}"
6769
else
68-
puts `env CXX=#{@compiler} LINK=#{@compiler} #{make} #{make_flags}`
70+
command += " #{make} #{make_flags}"
6971
end
72+
73+
puts "Building v8 with #{command}"
74+
system command
7075
end
7176
return $?.exitstatus
7277
end

ext/libv8/patcher.rb

Lines changed: 4 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,15 @@ module Patcher
44

55
module_function
66

7-
def patch_directories_for(compiler)
8-
patch_directories = []
9-
10-
case
11-
when compiler.target =~ /arm/
12-
patch_directories << 'arm'
13-
end
14-
15-
case compiler
16-
when Compiler::GCC
17-
patch_directories << 'gcc48' if compiler.version >= '4.8'
18-
when Compiler::Clang
19-
patch_directories << 'clang'
20-
patch_directories << 'clang33' if compiler.version >= '3.3'
21-
patch_directories << 'clang51' if compiler.version >= '5.1'
22-
patch_directories << 'clang70' if compiler.version >= '7.0'
23-
patch_directories << 'clang73' if compiler.version >= '7.3'
24-
end
25-
26-
patch_directories
27-
end
28-
29-
def patch_directories(*additional_directories)
30-
absolute_paths = [PATCH_DIRECTORY]
31-
32-
additional_directories.each do |directory|
33-
absolute_paths << File.join(PATCH_DIRECTORY, directory)
34-
end
35-
36-
absolute_paths.uniq
37-
end
38-
39-
def patches(*additional_directories)
40-
patch_directories(*additional_directories).map do |directory|
41-
Dir.glob(File.join directory, '*.patch')
42-
end.flatten.sort
43-
end
44-
45-
def patch!(*additional_directories)
7+
def patch!
468
File.open(".applied_patches", File::RDWR|File::CREAT) do |f|
47-
available_patches = patches *additional_directories
9+
available_patches = Dir.glob(File.join(PATCH_DIRECTORY, '*.patch'))
4810
applied_patches = f.readlines.map(&:chomp)
4911

5012
(available_patches - applied_patches).each do |patch|
13+
puts "Applying #{patch}"
5114
`patch -p1 -N < #{patch}`
52-
fail 'failed to apply patch' unless $?.success?
15+
fail "failed to apply patch #{patch}" unless $?.success?
5316
f.puts patch
5417
end
5518
end
File renamed without changes.

0 commit comments

Comments
 (0)