Skip to content

Commit

Permalink
Stop running prettify during regen_all for java files (#26795)
Browse files Browse the repository at this point in the history
* Remove run of java prettify on jinja codegen.

* zap regen all

* Make linter happy
  • Loading branch information
andy31415 authored and pull[bot] committed Mar 18, 2024
1 parent 51f2593 commit 4072289
Show file tree
Hide file tree
Showing 4 changed files with 32,719 additions and 38,343 deletions.
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

0 comments on commit 4072289

Please sign in to comment.