コード例 #1
0
def build_grpc(target):
  """Build a grpc build target and copy all generate source files."""
  output = bazel_build(
    target=target,
    cwd=googleapis,
  )

  src_output = Path(tempfile.mkdtemp())
  for proto_jar in output.glob("*grpc-src.jar"):
    logger.debug(f"unzipping: {os.path.basename(proto_jar)}")
    shell.run(["unzip", "-o", proto_jar, "-d", src_output / "src"])

  java.fix_grpc_headers(src_output, "")
  s.copy(src_output / "src/com", "grpc-google-iam-v1/src/main/java/com")
コード例 #2
0
def bazel_build(target: str, cwd: Union[Path, str]) -> Path:
  """Build a bazel target and return the output build directory."""
  old_cwd = os.getcwd()
  os.chdir(str(cwd))

  bazel_run_args = [
    "bazel",
    "--max_idle_secs=240",
    "build",
    target,
  ]

  logger.debug(f"Generating code for: {target}.")
  shell.run(bazel_run_args)

  output_dir = Path(f"bazel-bin{os.path.sep}{target[2:].split(':')[0]}").resolve()
  os.chdir(old_cwd)

  return output_dir
コード例 #3
0
import os
from pathlib import Path
import tempfile
from typing import Union

import synthtool as s
from synthtool.languages import java
from synthtool.sources import git
from synthtool import logger, shell

versions = ['v1']

GOOGLEAPIS_URL = git.make_repo_clone_url("googleapis/googleapis")

logger.debug("Cloning googleapis.")
googleapis = git.clone(GOOGLEAPIS_URL)

def bazel_build(target: str, cwd: Union[Path, str]) -> Path:
  """Build a bazel target and return the output build directory."""
  old_cwd = os.getcwd()
  os.chdir(str(cwd))

  bazel_run_args = [
    "bazel",
    "--max_idle_secs=240",
    "build",
    target,
  ]

  logger.debug(f"Generating code for: {target}.")