|
26 | 26 |
|
27 | 27 | build do
|
28 | 28 | block 're-install grpc gem with system OpenSSL' do
|
| 29 | + env = with_standard_compiler_flags(with_embedded_path) |
29 | 30 | gem_bin = embedded_bin('gem')
|
30 | 31 | command = %(#{embedded_bin('ruby')} -e "puts Gem::Specification.select { |x| x.name == 'grpc' }.map(&:version).uniq.map(&:to_s)")
|
31 | 32 | grpc_versions = shellout!(command).stdout || ""
|
|
35 | 36 |
|
36 | 37 | warn "Multiple versions of gRPC found: #{grpc_versions.join(', ')}" if grpc_versions.length > 1
|
37 | 38 |
|
38 |
| - source = 'grpc-system-ssl.patch' |
39 |
| - _locations, patch_path = find_file('config/patches', source) |
| 39 | + patches = {} |
40 | 40 |
|
41 |
| - raise "Missing gRPC patch: #{source}" unless patch_path |
| 41 | + grpc_versions.each do |version| |
| 42 | + source = |
| 43 | + # https://github.com/grpc/grpc/pull/27660 significantly changed the extconf.rb for TruffleRuby |
| 44 | + if Gem::Version.new(version) < Gem::Version.new('1.48.0') |
| 45 | + 'grpc-system-ssl-1.42.0.patch' |
| 46 | + else |
| 47 | + 'grpc-system-ssl-1.48.0.patch' |
| 48 | + end |
| 49 | + |
| 50 | + _locations, patch_path = find_file('config/patches', source) |
| 51 | + patches[version] = patch_path |
| 52 | + end |
42 | 53 |
|
43 | 54 | shellout!("#{gem_bin} install --no-document gem-patch -v 0.1.6")
|
44 | 55 | shellout!("#{gem_bin} uninstall --force --all grpc")
|
45 | 56 |
|
| 57 | + # This works around an issue with the grpc gem attempting to include |
| 58 | + # /opt/gitlab/include headers instead of the vendored re2 headers: |
| 59 | + # https://github.com/grpc/grpc/pull/32580. This can be removed |
| 60 | + # after grpc is updated with that pull request. |
| 61 | + env['CPPFLAGS'] = "-Ithird_party/re2 #{env['CPPFLAGS']}" |
| 62 | + |
46 | 63 | grpc_versions.each do |version|
|
| 64 | + patch_path = patches[version] |
47 | 65 | gemfile = "grpc-#{version}.gem"
|
48 | 66 | shellout!("rm -f #{gemfile}")
|
49 | 67 | shellout!("#{gem_bin} fetch grpc -v #{version} --platform ruby")
|
50 | 68 | shellout!("#{gem_bin} patch -p1 #{gemfile} #{patch_path}")
|
51 |
| - shellout!("#{gem_bin} install --platform ruby --no-document #{gemfile}") |
| 69 | + shellout!("#{gem_bin} install --platform ruby --no-document #{gemfile}", env: env) |
52 | 70 | end
|
53 | 71 |
|
54 | 72 | shellout!("#{gem_bin} uninstall gem-patch")
|
|
0 commit comments