Skip to content

Commit 4cf28ab

Browse files
authored
[Darwin] Framework diagnostics at startup (project-chip#36696)
* add script to make git commit SHA of build available to framework via derived header * trigger diagnostic log at framework init * enumerate derived output file
1 parent 8cd3050 commit 4cf28ab

File tree

4 files changed

+72
-0
lines changed

4 files changed

+72
-0
lines changed

src/darwin/Framework/CHIP/MTRFramework.mm

+3
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
#import "MTRFramework.h"
18+
#import "MTRFrameworkDiagnostics.h"
1819

1920
#include <dispatch/dispatch.h>
2021
#include <lib/support/CHIPMem.h>
@@ -34,5 +35,7 @@ void MTRFrameworkInit()
3435
// Suppress CHIP logging until we actually need it for redirection
3536
// (see MTRSetLogCallback()). Logging to os_log is always enabled.
3637
chip::Logging::SetLogFilter(chip::Logging::kLogCategory_None);
38+
39+
MTRFrameworkInitDiagnosticLog();
3740
});
3841
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
void MTRFrameworkInitDiagnosticLog();
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/**
2+
* Copyright (c) 2024 Project CHIP Authors
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "git_commit_sha.h"
18+
19+
#import "MTRLogging_Internal.h"
20+
21+
void MTRFrameworkInitDiagnosticLog()
22+
{
23+
MTR_LOG("Matter Framework Init (git: %s)", GIT_COMMIT_SHA);
24+
}

src/darwin/Framework/Matter.xcodeproj/project.pbxproj

+28
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,8 @@
331331
99C65E10267282F1003402F6 /* MTRControllerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 99C65E0F267282F1003402F6 /* MTRControllerTests.m */; };
332332
99D466E12798936D0089A18F /* MTRCommissioningParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = 99D466E02798936D0089A18F /* MTRCommissioningParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
333333
9B0484F52C701154006C2D5F /* MTRDeviceController_Concrete.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B0484F42C701154006C2D5F /* MTRDeviceController_Concrete.h */; };
334+
9B1728F02CFE573C00825030 /* MTRFrameworkDiagnostics.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B1728EF2CFE573600825030 /* MTRFrameworkDiagnostics.h */; };
335+
9B1728F22CFE574600825030 /* MTRFrameworkDiagnostics.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B1728F12CFE574000825030 /* MTRFrameworkDiagnostics.mm */; };
334336
9B231B042C62EF650030EB37 /* (null) in Headers */ = {isa = PBXBuildFile; };
335337
9B231B052C62EF650030EB37 /* MTRDeviceController_Concrete.mm in Sources */ = {isa = PBXBuildFile; fileRef = 9B231B032C62EF650030EB37 /* MTRDeviceController_Concrete.mm */; };
336338
9B5CCB592C6E6FD3009DD99B /* MTRDeviceController_XPC_Internal.h in Headers */ = {isa = PBXBuildFile; fileRef = 9B5CCB582C6E6FD3009DD99B /* MTRDeviceController_XPC_Internal.h */; };
@@ -811,6 +813,8 @@
811813
99C65E0F267282F1003402F6 /* MTRControllerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MTRControllerTests.m; sourceTree = "<group>"; };
812814
99D466E02798936D0089A18F /* MTRCommissioningParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRCommissioningParameters.h; sourceTree = "<group>"; };
813815
9B0484F42C701154006C2D5F /* MTRDeviceController_Concrete.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDeviceController_Concrete.h; sourceTree = "<group>"; };
816+
9B1728EF2CFE573600825030 /* MTRFrameworkDiagnostics.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRFrameworkDiagnostics.h; sourceTree = "<group>"; };
817+
9B1728F12CFE574000825030 /* MTRFrameworkDiagnostics.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRFrameworkDiagnostics.mm; sourceTree = "<group>"; };
814818
9B231B032C62EF650030EB37 /* MTRDeviceController_Concrete.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRDeviceController_Concrete.mm; sourceTree = "<group>"; };
815819
9B5CCB582C6E6FD3009DD99B /* MTRDeviceController_XPC_Internal.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDeviceController_XPC_Internal.h; sourceTree = "<group>"; };
816820
9B5CCB5A2C6EC890009DD99B /* MTRDevice_XPC.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDevice_XPC.h; sourceTree = "<group>"; };
@@ -1514,6 +1518,8 @@
15141518
754F3DF327FBB94B00E60580 /* MTREventTLVValueDecoder_Internal.h */,
15151519
515C1C6E284F9FFB00A48F0C /* MTRFramework.h */,
15161520
515C1C6D284F9FFB00A48F0C /* MTRFramework.mm */,
1521+
9B1728EF2CFE573600825030 /* MTRFrameworkDiagnostics.h */,
1522+
9B1728F12CFE574000825030 /* MTRFrameworkDiagnostics.mm */,
15171523
998F286C26D55E10001846C6 /* MTRKeypair.h */,
15181524
3DECCB6F2934AC1C00585AEC /* MTRLogging.h */,
15191525
991DC08A247704DC00C13860 /* MTRLogging_Internal.h */,
@@ -1844,6 +1850,7 @@
18441850
5178E6822AE098520069DF72 /* MTRCommissionableBrowserResult_Internal.h in Headers */,
18451851
516415FD2B6ACA8300D5CE11 /* MTRServerAccessControl.h in Headers */,
18461852
3CF134AB289D8DF70017A19E /* MTRDeviceAttestationInfo.h in Headers */,
1853+
9B1728F02CFE573C00825030 /* MTRFrameworkDiagnostics.h in Headers */,
18471854
B2E0D7B2245B0B5C003C5B48 /* MTRManualSetupPayloadParser.h in Headers */,
18481855
5109E9C02CCAD64F0006884B /* MTRDeviceDataValidation.h in Headers */,
18491856
3CF134A7289D8ADA0017A19E /* MTRCSRInfo.h in Headers */,
@@ -1946,6 +1953,7 @@
19461953
isa = PBXNativeTarget;
19471954
buildConfigurationList = B20252A12459E34F00F97062 /* Build configuration list for PBXNativeTarget "Matter" */;
19481955
buildPhases = (
1956+
9B7838562CFE3AE600FB04C4 /* Acquire git revision info */,
19491957
0C40A67D246C9AC700885C81 /* Run GN Build (chip_xcode_build_connector) */,
19501958
B20252882459E34F00F97062 /* Headers */,
19511959
B20252892459E34F00F97062 /* Sources */,
@@ -2059,6 +2067,25 @@
20592067
shellPath = /bin/sh;
20602068
shellScript = "./chip_xcode_build_connector.sh\n";
20612069
};
2070+
9B7838562CFE3AE600FB04C4 /* Acquire git revision info */ = {
2071+
isa = PBXShellScriptBuildPhase;
2072+
buildActionMask = 2147483647;
2073+
files = (
2074+
);
2075+
inputFileListPaths = (
2076+
);
2077+
inputPaths = (
2078+
);
2079+
name = "Acquire git revision info";
2080+
outputFileListPaths = (
2081+
);
2082+
outputPaths = (
2083+
"$(DERIVED_FILE_DIR)/git_commit_sha.h",
2084+
);
2085+
runOnlyForDeploymentPostprocessing = 0;
2086+
shellPath = /bin/sh;
2087+
shellScript = "GIT_COMMIT_SHA=$(git rev-parse --short HEAD)\n\n# Create a temporary header file to hold the commit SHA\ntmp_header_path=\"${DERIVED_FILES_DIR}/git_commit_sha.h\"\ncat << EOF > \"$tmp_header_path\"\n#ifndef GIT_COMMIT_SHA_H\n#define GIT_COMMIT_SHA_H\n\n#define GIT_COMMIT_SHA \"${GIT_COMMIT_SHA}\"\n\n#endif /* GIT_COMMIT_SHA_H */\nEOF\n\necho \"git sha available in ${DERIVED_FILES_DIR}/git_commit_sha.h\"\n";
2088+
};
20622089
/* End PBXShellScriptBuildPhase section */
20632090

20642091
/* Begin PBXSourcesBuildPhase section */
@@ -2198,6 +2225,7 @@
21982225
AF5F90FF2878D351005503FA /* MTROTAProviderDelegateBridge.mm in Sources */,
21992226
516415FF2B6B132200D5CE11 /* DataModelHandler.cpp in Sources */,
22002227
75139A6F2B7FE5E900E3A919 /* MTRDeviceControllerLocalTestStorage.mm in Sources */,
2228+
9B1728F22CFE574600825030 /* MTRFrameworkDiagnostics.mm in Sources */,
22012229
51E95DFC2A78443C00A434F0 /* MTRSessionResumptionStorageBridge.mm in Sources */,
22022230
7534F12828BFF20300390851 /* MTRDeviceAttestationDelegate.mm in Sources */,
22032231
B4C8E6B72B3453AD00FCD54D /* MTRDiagnosticLogsDownloader.mm in Sources */,

0 commit comments

Comments
 (0)