|
60 | 60 | default(ENV["GOOGLEAPIS_GEN_GITHUB_TOKEN"] || ENV["GITHUB_TOKEN"]) |
61 | 61 | desc "GitHub token for cloning the googleapis-gen repository." |
62 | 62 | end |
| 63 | + flag :pull_googleapis, "--pull-googleapis[=COMMIT]" do |
| 64 | + desc "Generate by pulling googleapis/googleapis and running Bazel from the protos there" |
| 65 | + end |
63 | 66 | flag :source_path, "--source-path=PATH" do |
64 | 67 | desc "Path to the googleapis-gen source repo." |
65 | 68 | end |
@@ -99,9 +102,10 @@ def run |
99 | 102 | gems = choose_gems |
100 | 103 | cd context_directory |
101 | 104 | setup_git |
102 | | - gem_info = collect_gem_info gems |
103 | | - |
104 | 105 | pull_images |
| 106 | + maybe_pull_googleapis |
| 107 | + |
| 108 | + gem_info = collect_gem_info gems |
105 | 109 | if piper_client || protos_path |
106 | 110 | set :source_path, run_bazel(gem_info) |
107 | 111 | else |
@@ -163,6 +167,24 @@ def pull_images |
163 | 167 | exec ["docker", "pull", "#{POSTPROCESSOR_IMAGE}:#{postprocessor_tag}"] |
164 | 168 | end |
165 | 169 |
|
| 170 | +def maybe_pull_googleapis |
| 171 | + return unless pull_googleapis |
| 172 | + commit = pull_googleapis |
| 173 | + commit = "HEAD" if commit == true |
| 174 | + googleapis_dir = File.join context_directory, "tmp", "googleapis" |
| 175 | + rm_rf googleapis_dir |
| 176 | + mkdir_p googleapis_dir |
| 177 | + at_exit { FileUtils.rm_rf googleapis_dir } |
| 178 | + cd googleapis_dir do |
| 179 | + exec ["git", "init"] |
| 180 | + exec ["git", "remote", "add", "origin", "https://github.com/googleapis/googleapis.git"] |
| 181 | + exec ["git", "fetch", "--depth=1", "origin", commit] |
| 182 | + exec ["git", "branch", "github-head", "FETCH_HEAD"] |
| 183 | + exec ["git", "switch", "github-head"] |
| 184 | + end |
| 185 | + set :protos_path, googleapis_dir |
| 186 | +end |
| 187 | + |
166 | 188 | def collect_gem_info gems |
167 | 189 | gem_info = {} |
168 | 190 | gems.each do |name| |
@@ -205,7 +227,7 @@ def run_bazel gem_info |
205 | 227 | bazel_alias = enable_bazelisk ? "bazelisk" : "bazel" |
206 | 228 | gem_info.each_value do |info| |
207 | 229 | info[:bazel_targets].each do |library_path, bazel_target| |
208 | | - exec [bazel_alias, "build", "//#{library_path}:#{bazel_target}"], chdir: bazel_base_dir |
| 230 | + exec [bazel_alias, "build", "--verbose_failures", "//#{library_path}:#{bazel_target}"], chdir: bazel_base_dir |
209 | 231 | end |
210 | 232 | end |
211 | 233 | source_dir = capture([bazel_alias, "info", "bazel-bin"], chdir: bazel_base_dir).chomp |
|
0 commit comments