From 11861873f0bdd573c1dc1793564dead48ab5f1db Mon Sep 17 00:00:00 2001 From: Joshua Villasenor Date: Tue, 19 Jul 2022 14:03:40 -0700 Subject: [PATCH] Update darwin-framework-tool to build Matter.framework on changes. (#20952) --- examples/darwin-framework-tool/BUILD.gn | 23 +++++++++++++++++------ scripts/build/build_darwin_framework.py | 24 ++++++++++++++++++------ 2 files changed, 35 insertions(+), 12 deletions(-) diff --git a/examples/darwin-framework-tool/BUILD.gn b/examples/darwin-framework-tool/BUILD.gn index 2bb38888cf2ab8..513be497c1fb4f 100644 --- a/examples/darwin-framework-tool/BUILD.gn +++ b/examples/darwin-framework-tool/BUILD.gn @@ -27,7 +27,10 @@ assert(chip_build_tools) action("build-darwin-framework") { script = "${chip_root}/scripts/build/build_darwin_framework.py" - inputs = [ "${chip_root}/src/darwin/Framework/Matter.xcodeproj" ] + inputs = [ + "${chip_root}/src/darwin/Framework/CHIP", + "${chip_root}/src/darwin/Framework/Matter.xcodeproj", + ] args = [ "--project_path", @@ -36,13 +39,20 @@ action("build-darwin-framework") { "--out_path", "macos_framework_output", "--target", - "Matter", + "Matter Framework", "--log_path", rebase_path("${root_build_dir}/darwin_framework_build.log", root_build_dir), ] output_name = "Matter.framework" - outputs = [ "${root_out_dir}/macos_framework_output/${output_name}" ] + outputs = [ + "${root_out_dir}/macos_framework_output/Build/Products/Debug/${output_name}", + "${root_build_dir}/darwin_framework_build.log", + "${root_out_dir}/macos_framework_output/ModuleCache.noindex/", + "${root_out_dir}/macos_framework_output/Logs", + "${root_out_dir}/macos_framework_output/Index", + "${root_out_dir}/macos_framework_output/Build", + ] } config("config") { @@ -53,10 +63,11 @@ config("config") { "${chip_root}/zzz_generated/controller-clusters", "${chip_root}/examples/chip-tool", "${chip_root}/zzz_generated/chip-tool", - "${root_out_dir}/macos_framework_output", + "${root_out_dir}/macos_framework_output/Build/Products/Debug/", ] - framework_dirs = [ "${root_out_dir}/macos_framework_output" ] + framework_dirs = + [ "${root_out_dir}/macos_framework_output/Build/Products/Debug/" ] defines = [ "CONFIG_ENABLE_YAML_TESTS=${config_enable_yaml_tests}", @@ -127,7 +138,7 @@ executable("darwin-framework-tool") { ldflags = [ "-rpath", - "@executable_path/macos_framework_output/", + "@executable_path/macos_framework_output/Build/Products/Debug/", ] frameworks = [ diff --git a/scripts/build/build_darwin_framework.py b/scripts/build/build_darwin_framework.py index 51e26b7d044a3c..bfc7e33bafe057 100644 --- a/scripts/build/build_darwin_framework.py +++ b/scripts/build/build_darwin_framework.py @@ -14,12 +14,26 @@ # limitations under the License. import argparse import os -import subprocess +from subprocess import PIPE, Popen def run_command(command): + returncode = -1 + command_log = b'' print("Running {}".format(command)) - return str(subprocess.check_output(command.split())) + with Popen(command, cwd=os.getcwd(), stdout=PIPE, stderr=PIPE) as process: + for line in process.stdout: + command_log += line + + for line in process.stderr: + command_log += line + + process.wait() + returncode = process.returncode + + with open(args.log_path, "wb") as f: + f.write(command_log) + return returncode def build_darwin_framework(args): @@ -27,13 +41,11 @@ def build_darwin_framework(args): if not os.path.exists(abs_path): os.mkdir(abs_path) - command = "xcodebuild -target {target} -sdk macosx -project {project} CONFIGURATION_BUILD_DIR={outpath}".format( - target=args.target, project=args.project_path, outpath=abs_path) + command = ['xcodebuild', '-scheme', args.target, '-sdk', 'macosx', '-project', args.project_path, '-derivedDataPath', abs_path] command_result = run_command(command) print("Build Framework Result: {}".format(command_result)) - with open(args.log_path, "w") as f: - f.write(command_result) + exit(command_result) if __name__ == "__main__":