Skip to content

Commit 56498ad

Browse files
[objective_c] Use user_defines to gate test utilities in build hook (Fixes #2999)
1 parent 27890da commit 56498ad

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

pkgs/objective_c/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
Objective-C.
88
- Fix a [bug](https://github.com/dart-lang/native/issues/3290) where missing
99
debug symbols caused app store valiadtion warnings.
10+
- Moved test utilities to use `user_defines` in the build hook instead of a
11+
separate helper package (fixes [#2999](https://github.com/dart-lang/native/issues/2999)).
1012

1113
## 9.3.0
1214
- `autoReleasePool` now returns the value produced by its callback.

pkgs/objective_c/hook/build.dart

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ const objCFlags = ['-x', 'objective-c', '-fobjc-arc'];
1313

1414
const assetName = 'objective_c.dylib';
1515

16-
// TODO(https://github.com/dart-lang/native/issues/2272): Remove this from the
17-
// main build.
18-
const testFiles = ['test/util.c'];
19-
2016
final logger = Logger('')
2117
..level = Level.INFO
2218
..onRecord.listen((record) {
@@ -59,13 +55,9 @@ void main(List<String> args) async {
5955
}
6056
}
6157

62-
// Only include the test utils on mac OS. They use memory functions that
63-
// aren't supported on iOS, like mach_vm_region. We don't need them on iOS
64-
// anyway since we only run memory tests on mac.
65-
if (os == OS.macOS) {
66-
cFiles.addAll(
67-
testFiles.map((f) => input.packageRoot.resolve(f).toFilePath()),
68-
);
58+
final includeTestUtils = input.userDefines['include_test_utils'] == 'true';
59+
if (includeTestUtils) {
60+
cFiles.add(input.packageRoot.resolve('test/util.c').toFilePath());
6961
}
7062

7163
final sysroot = sdkPath(codeConfig);

pkgs/objective_c/pubspec.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
22
# for details. All rights reserved. Use of this source code is governed by a
33
# BSD-style license that can be found in the LICENSE file.
4-
54
name: objective_c
65
description: 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.'
76
version: 9.4.0-wip
@@ -45,3 +44,7 @@ dependency_overrides:
4544
path: ../hooks
4645
native_toolchain_c:
4746
path: ../native_toolchain_c
47+
48+
hook:
49+
user_defines:
50+
include_test_utils: "false"

0 commit comments

Comments
 (0)