Skip to content

Commit

Permalink
Update darwin-framework-tool to build Matter.framework on changes. (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
krypton36 authored and pull[bot] committed Jun 28, 2023
1 parent 320a90f commit 1186187
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 12 deletions.
23 changes: 17 additions & 6 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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") {
Expand All @@ -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}",
Expand Down Expand Up @@ -127,7 +138,7 @@ executable("darwin-framework-tool") {

ldflags = [
"-rpath",
"@executable_path/macos_framework_output/",
"@executable_path/macos_framework_output/Build/Products/Debug/",
]

frameworks = [
Expand Down
24 changes: 18 additions & 6 deletions scripts/build/build_darwin_framework.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,38 @@
# 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):
abs_path = os.path.abspath(args.out_path)
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__":
Expand Down

0 comments on commit 1186187

Please sign in to comment.