Skip to content

Commit 21c46eb

Browse files
bmehta001Copilot
andcommitted
Update wrappers and misc files for vcpkg compatibility
- Update Obj-C and Swift wrappers for optional module resilience - Update Package.swift for vcpkg install paths - Add export-ignore entries to .gitattributes - Add vcpkg build artifacts to .gitignore - Fix AISendTests.cpp journal cleanup for iOS Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5c04e1b commit 21c46eb

9 files changed

Lines changed: 89 additions & 3 deletions

File tree

.gitattributes

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ GNUmakefile text
8787
*.xml text
8888
*.cfg text
8989

90+
## Exclude vcpkg port and test scaffolding from GitHub tarballs.
91+
## This avoids a chicken-and-egg problem: the portfile contains a SHA512
92+
## of the tarball, so changes to the portfile must not change the tarball.
93+
tools/ports/ export-ignore
94+
tests/vcpkg/ export-ignore
95+
9096
## Self-reference =)
9197
.gitignore text
9298
.gitattributes text

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,3 +405,6 @@ build/.cmake/api/v1/query/client-vscode/query.json
405405

406406
#Test files generated locally.
407407
*.ses
408+
409+
# vcpkg test build directories
410+
tests/vcpkg/build-*/

tests/functests/AISendTests.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ class AISendTests : public ::testing::Test,
142142
fileName += PATH_SEPARATOR_CHAR;
143143
fileName += TEST_STORAGE_FILENAME;
144144
std::remove(fileName.c_str());
145+
std::remove((fileName + "-wal").c_str());
146+
std::remove((fileName + "-shm").c_str());
147+
std::remove((fileName + "-journal").c_str());
145148
}
146149

147150
virtual void Initialize(DebugEventListener& debugListener, std::string const& path, bool compression)

tests/vcpkg/test-vcpkg-ios.sh

100644100755
File mode changed.

tests/vcpkg/test-vcpkg-linux.sh

100644100755
File mode changed.

tests/vcpkg/test-vcpkg-macos.sh

100644100755
File mode changed.

wrappers/obj-c/ODWLogger.mm

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,20 @@
99
#import "ODWLogConfiguration.h"
1010
#import "ODWSemanticContext.h"
1111
#import "ODWSemanticContext_private.h"
12+
13+
#if __has_include("PrivacyGuard.hpp")
14+
#define MATSDK_OBJC_PRIVACYGUARD_AVAILABLE 1
1215
#import "ODWPrivacyGuard_private.h"
16+
#else
17+
#define MATSDK_OBJC_PRIVACYGUARD_AVAILABLE 0
18+
#endif
19+
20+
#if __has_include("Sanitizer.hpp")
21+
#define MATSDK_OBJC_SANITIZER_AVAILABLE 1
1322
#import "ODWSanitizer_private.h"
23+
#else
24+
#define MATSDK_OBJC_SANITIZER_AVAILABLE 0
25+
#endif
1426

1527
#include "EventProperties.hpp"
1628

@@ -411,17 +423,35 @@ void PerformActionWithCppExceptionsCatch(void (^block)())
411423
}
412424

413425
-(void)initializePrivacyGuardWithODWPrivacyGuardInitConfig:(ODWPrivacyGuardInitConfig *)initConfigObject
414-
{
426+
{
427+
#if MATSDK_OBJC_PRIVACYGUARD_AVAILABLE
415428
[ODWPrivacyGuard initializePrivacyGuard:_wrappedLogger withODWPrivacyGuardInitConfig:initConfigObject];
429+
#else
430+
(void)initConfigObject;
431+
[ODWLogger traceException:"Privacy Guard is not available in this build."];
432+
#endif
416433
}
417434

418435
-(void)initializeSanitizerWithODWSanitizerInitConfig:(ODWSanitizerInitConfig *)initConfigObject
419436
{
437+
#if MATSDK_OBJC_SANITIZER_AVAILABLE
420438
[ODWSanitizer initializeSanitizer:_wrappedLogger withODWSanitizerInitConfig:initConfigObject];
439+
#else
440+
(void)initConfigObject;
441+
[ODWLogger traceException:"Sanitizer is not available in this build."];
442+
#endif
421443
}
422444

423445
-(void)initializeSanitizerWithODWSanitizerInitConfig:(ODWSanitizerInitConfig *)initConfigObject urlDomains:(NSArray<NSString *> *)urlDomains emailDomains:(NSArray<NSString *> *)emailDomains analyzerOptions:(int)analyzerOptions
424446
{
447+
#if MATSDK_OBJC_SANITIZER_AVAILABLE
425448
[ODWSanitizer initializeSanitizer:_wrappedLogger withODWSanitizerInitConfig:initConfigObject urlDomains:urlDomains emailDomains:emailDomains analyzerOptions:analyzerOptions];
449+
#else
450+
(void)initConfigObject;
451+
(void)urlDomains;
452+
(void)emailDomains;
453+
(void)analyzerOptions;
454+
[ODWLogger traceException:"Sanitizer is not available in this build."];
455+
#endif
426456
}
427457
@end

wrappers/swift/Package.swift

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,45 @@
22
// The swift-tools-version declares the minimum version of Swift required to build this package.
33

44
import PackageDescription
5+
import Foundation
6+
7+
let packageDirectory = URL(fileURLWithPath: #filePath).deletingLastPathComponent()
8+
9+
func moduleExists(_ relativePath: String) -> Bool {
10+
FileManager.default.fileExists(atPath: packageDirectory.appendingPathComponent(relativePath).standardizedFileURL.path)
11+
}
12+
13+
let hasDiagnosticDataViewer = moduleExists("../../lib/modules/dataviewer")
14+
let hasPrivacyGuard = moduleExists("../../lib/modules/privacyguard")
15+
let hasSanitizer = moduleExists("../../lib/modules/sanitizer")
16+
17+
var excludedSources: [String] = []
18+
var swiftSettings: [SwiftSetting] = []
19+
20+
if hasDiagnosticDataViewer {
21+
swiftSettings.append(.define("MATSDK_DATAVIEWER_AVAILABLE"))
22+
} else {
23+
excludedSources.append("DiagnosticDataViewer.swift")
24+
}
25+
26+
if hasPrivacyGuard {
27+
swiftSettings.append(.define("MATSDK_PRIVACYGUARD_AVAILABLE"))
28+
} else {
29+
excludedSources.append(contentsOf: [
30+
"CommonDataContext.swift",
31+
"PrivacyGuard.swift",
32+
"PrivacyGuardInitConfig.swift",
33+
])
34+
}
35+
36+
if hasSanitizer {
37+
swiftSettings.append(.define("MATSDK_SANITIZER_AVAILABLE"))
38+
} else {
39+
excludedSources.append(contentsOf: [
40+
"Sanitizer.swift",
41+
"SanitizerInitConfig.swift",
42+
])
43+
}
544

645
let package = Package(
746
name: "OneDSSwiftWrapper",
@@ -21,8 +60,11 @@ let package = Package(
2160
.target(
2261
name: "OneDSSwift",
2362
dependencies: [],
63+
path: "Sources/OneDSSwift",
64+
exclude: excludedSources,
2465
cSettings: [
2566
.headerSearchPath("../../Modules/")
26-
]),
67+
],
68+
swiftSettings: swiftSettings),
2769
]
2870
)

wrappers/swift/Sources/OneDSSwift/Logger.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,12 @@ public final class Logger {
137137

138138
/**
139139
Initializes and gets an instance of Privacy Guard.
140-
*/
140+
*/
141+
#if MATSDK_PRIVACYGUARD_AVAILABLE
141142
public func apply(config initConfigObject: PrivacyGuardInitConfig) {
142143
odwLogger.initializePrivacyGuard(with: initConfigObject.getODWPrivacyGuardInitConfig())
143144
}
145+
#endif
144146

145147
// MARK: Set Context methods
146148

0 commit comments

Comments
 (0)