Skip to content

Commit

Permalink
Revert the non-workflow changes from PR #project-chip#24539, since th…
Browse files Browse the repository at this point in the history
…ose are not needed anymore.
  • Loading branch information
bzbarsky-apple committed Jan 20, 2023
1 parent f802c34 commit 0b068bb
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 59 deletions.
7 changes: 2 additions & 5 deletions scripts/codepregen.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def _ParallelGenerateOne(arg):
@click.option(
'--generator',
default='all',
type=click.Choice(['all', 'zap', 'codegen', 'codegen-cpp-only']),
type=click.Choice(['all', 'zap', 'codegen']),
help='To what code generator to restrict the generation.')
@click.option(
'--input-glob',
Expand Down Expand Up @@ -119,12 +119,9 @@ def main(log_level, parallel, dry_run, generator, input_glob, sdk_root, output_d

if generator == 'zap':
filter.file_type = IdlFileType.ZAP
elif generator == 'codegen' or generator == 'codegen-cpp-only':
elif generator == 'codegen':
filter.file_type = IdlFileType.MATTER

if generator == 'codegen-cpp-only':
filter.cpp_only = True

targets = FindPregenerationTargets(sdk_root, filter, runner)

runner.ensure_directory_exists(output_dir)
Expand Down
4 changes: 1 addition & 3 deletions scripts/pregenerate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ class TargetFilter:
# If non-empty only the given paths will be code-generated
path_glob: List[str] = field(default_factory=list)

cpp_only: bool = False


# TODO: the build GlobMatcher is more complete by supporting `{}` grouping
# For now this limited glob seems sufficient.
Expand Down Expand Up @@ -100,5 +98,5 @@ def FindPregenerationTargets(sdk_root: str, filter: TargetFilter, runner):
continue

for generator in generators:
if generator.Accept(idl, filter.cpp_only):
if generator.Accept(idl):
yield generator.CreateTarget(idl, runner=runner)
13 changes: 5 additions & 8 deletions scripts/pregenerate/using_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CodegenBridgePregenerator:
def __init__(self, sdk_root):
self.sdk_root = sdk_root

def Accept(self, idl: InputIdlFile, cpp_only: bool):
def Accept(self, idl: InputIdlFile):
# Bridge is highly specific, a single path is acceptable for dynamic
# bridge codegen
return idl.relative_path == "examples/dynamic-bridge-app/bridge-common/bridge-app.matter"
Expand All @@ -79,12 +79,9 @@ class CodegenJavaPregenerator:
def __init__(self, sdk_root):
self.sdk_root = sdk_root

def Accept(self, idl: InputIdlFile, cpp_only: bool):
if cpp_only:
return False

# Java is highly specific, a single path is acceptable for java
# codegen
def Accept(self, idl: InputIdlFile):
# Java is highly specific, a single path is acceptable for dynamic
# bridge codegen
return idl.relative_path == "src/controller/data_model/controller-clusters.matter"

def CreateTarget(self, idl: InputIdlFile, runner):
Expand All @@ -97,7 +94,7 @@ class CodegenCppAppPregenerator:
def __init__(self, sdk_root):
self.sdk_root = sdk_root

def Accept(self, idl: InputIdlFile, cpp_only: bool):
def Accept(self, idl: InputIdlFile):
if idl.file_type != IdlFileType.MATTER:
return False

Expand Down
2 changes: 1 addition & 1 deletion scripts/pregenerate/using_zap.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ZapApplicationPregenerator:
def __init__(self, sdk_root):
self.sdk_root = sdk_root

def Accept(self, idl: InputIdlFile, cpp_only: bool):
def Accept(self, idl: InputIdlFile):
if idl.file_type != IdlFileType.ZAP:
return False

Expand Down
43 changes: 4 additions & 39 deletions scripts/tools/zap_regen_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,41 +113,6 @@ def generate(self) -> TargetRunStats:
)


class ZAPPregenerateTarget:
def __init__(self, input_glob, output_dir, generator=None):
self.input_glob = input_glob
self.output_dir = output_dir
self.script = "./scripts/codepregen.py"
self.command = [self.script, "--input-glob", input_glob]
self.generator = generator

if generator is not None:
self.command.extend(["--generator", generator])
self.command.append(output_dir)

def distinct_output(self):
input_template = self.input_glob
if self.generator is not None:
input_template += " " + self.generator
return ZapDistinctOutput(input_template=input_template, output_directory=self.output_dir)

def log_command(self):
logging.info(" %s" % " ".join(self.command))

def generate(self) -> TargetRunStats:
logging.info("Generating target: %s" % " ".join(self.command))

generate_start = time.time()
subprocess.check_call(self.command)
generate_end = time.time()

return TargetRunStats(
generate_time=generate_end - generate_start,
config=self.script,
template=self.script,
)


def checkPythonVersion():
if sys.version_info[0] < 3:
print('Must use Python 3. Current version is ' +
Expand Down Expand Up @@ -235,10 +200,10 @@ def getGlobalTemplatesTargets():
#
# TODO: These files can be code generated at compile time, we should figure
# out a path for this codegen to not be required.
targets.append(ZAPPregenerateTarget(
"*controller-clusters*", "zzz_generated/darwin", generator="zap"))
targets.append(ZAPPregenerateTarget(
"*controller-clusters*", "zzz_generated/darwin", generator="codegen-cpp-only"))
targets.append(ZAPGenerateTarget(
'src/controller/data_model/controller-clusters.zap',
template="src/app/zap-templates/app-templates.json",
output_dir=os.path.join('zzz_generated/darwin/controller-clusters/zap-generated')))

return targets

Expand Down
4 changes: 2 additions & 2 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@
"$(CHIP_ROOT)/zzz_generated/app-common",
"$(CHIP_ROOT)/zzz_generated/controller-clusters",
/* darwin-specific bypassing compile time codegen for header inclusion */
"$(CHIP_ROOT)/zzz_generated/darwin/src/controller/data_model/controller-clusters/zap/app-templates",
"$(CHIP_ROOT)/zzz_generated/darwin/controller-clusters",
);
INFOPLIST_FILE = CHIP/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down Expand Up @@ -1172,7 +1172,7 @@
"$(CHIP_ROOT)/zzz_generated/app-common",
"$(CHIP_ROOT)/zzz_generated/controller-clusters",
/* darwin-specific bypassing compile time codegen for header inclusion */
"$(CHIP_ROOT)/zzz_generated/darwin/src/controller/data_model/controller-clusters/zap/app-templates",
"$(CHIP_ROOT)/zzz_generated/darwin/controller-clusters",
);
INFOPLIST_FILE = CHIP/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
Expand Down
1 change: 0 additions & 1 deletion src/darwin/Framework/chip_xcode_build_connector.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ declare -a args=(
"target_defines=$target_defines"
"target_cflags=[$target_cflags]"
"mac_target_arch=\"$target_arch\""
"chip_code_pre_generated_directory=\"$CHIP_ROOT/zzz_generated/darwin\""
"mac_deployment_target=\"$LLVM_TARGET_TRIPLE_OS_VERSION$LLVM_TARGET_TRIPLE_SUFFIX\""
)

Expand Down

0 comments on commit 0b068bb

Please sign in to comment.