Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop running prettify during regen_all for java files #26795

Merged
merged 4 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
import sys
import tempfile
import time
import traceback
import urllib.request
from dataclasses import dataclass
from enum import Flag, auto
from pathlib import Path
Expand Down Expand Up @@ -216,34 +214,10 @@ def __init__(self, generator: str, output_directory: str, idl_path: str):
self.command = ["./scripts/codegen.py", "--output-dir", output_directory,
"--generator", generator, idl_path]

def runJavaPrettifier(self):
try:
java_outputs = subprocess.check_output(["./scripts/codegen.py", "--name-only", "--generator",
self.generator, "--log-level", "fatal", self.idl_path]).decode("utf8").split("\n")
java_outputs = [os.path.join(self.output_directory, name) for name in java_outputs if name]

logging.info("Prettifying %d java files:", len(java_outputs))
for name in java_outputs:
logging.info(" %s" % name)

# Keep this version in sync with what restyler uses (https://github.com/project-chip/connectedhomeip/blob/master/.restyled.yaml).
FORMAT_VERSION = "1.6"
URL_PREFIX = 'https://github.com/google/google-java-format/releases/download/google-java-format'
JAR_NAME = f"google-java-format-{FORMAT_VERSION}-all-deps.jar"
jar_url = f"{URL_PREFIX}-{FORMAT_VERSION}/{JAR_NAME}"

path, http_message = urllib.request.urlretrieve(jar_url, Path.home().joinpath(JAR_NAME).as_posix())

subprocess.check_call(['java', '-jar', path, '--replace'] + java_outputs)
except Exception as err:
traceback.print_exception(err)
print('google-java-format error:', err)

def generate(self) -> TargetRunStats:
generate_start = time.time()

subprocess.check_call(self.command)
self.runJavaPrettifier()

generate_end = time.time()

Expand Down
Loading