Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ dependency_overrides:
path: ../native_toolchain_c
objective_c:
path: ../objective_c

hooks:
user_defines:
objective_c:
include_test_utils: true
1 change: 1 addition & 0 deletions pkgs/objective_c/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Objective-C.
- Fix a [bug](https://github.com/dart-lang/native/issues/3290) where missing
debug symbols caused app store valiadtion warnings.
- Removed some test-only utilities from the release dylib (fixes [#2999](https://github.com/dart-lang/native/issues/2999)).

## 9.3.0
- `autoReleasePool` now returns the value produced by its callback.
Expand Down
15 changes: 4 additions & 11 deletions pkgs/objective_c/hook/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ const objCFlags = ['-x', 'objective-c', '-fobjc-arc'];

const assetName = 'objective_c.dylib';

// TODO(https://github.com/dart-lang/native/issues/2272): Remove this from the
// main build.
const testFiles = ['test/util.c'];

final logger = Logger('')
..level = Level.INFO
..onRecord.listen((record) {
Expand Down Expand Up @@ -59,13 +55,10 @@ void main(List<String> args) async {
}
}

// Only include the test utils on mac OS. They use memory functions that
// aren't supported on iOS, like mach_vm_region. We don't need them on iOS
// anyway since we only run memory tests on mac.
if (os == OS.macOS) {
cFiles.addAll(
testFiles.map((f) => input.packageRoot.resolve(f).toFilePath()),
);
final includeTestUtils =
input.userDefines['include_test_utils'] as bool? ?? false;
if (includeTestUtils) {
cFiles.add(input.packageRoot.resolve('test/util.c').toFilePath());
}

final sysroot = sdkPath(codeConfig);
Expand Down
6 changes: 5 additions & 1 deletion pkgs/objective_c/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
# for details. All rights reserved. Use of this source code is governed by a
# BSD-style license that can be found in the LICENSE file.

name: objective_c
description: 'A library to access Objective C from Flutter that acts as a support library for package:ffigen.'
version: 9.4.0-wip
Expand Down Expand Up @@ -45,3 +44,8 @@ dependency_overrides:
path: ../hooks
native_toolchain_c:
path: ../native_toolchain_c

hooks:
user_defines:
objective_c:
include_test_utils: true
7 changes: 5 additions & 2 deletions pkgs/objective_c/test/hook_build_path_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,12 @@ exit 0
}

final logLines = File(compilerLog).readAsLinesSync();
final decodedUtil = '$symlinkPath/test/util.c';
expect(logLines, contains(decodedUtil));
final decodedSrc = '$symlinkPath/src/objective_c.c';
expect(logLines, contains(decodedSrc));
expect(logLines.any((line) => line.contains('%2547')), isFalse);

final decodedUtil = '$symlinkPath/test/util.c';
expect(logLines, isNot(contains(decodedUtil)));
},
skip: !Platform.isMacOS ? 'Requires macOS' : null,
);
Expand Down
7 changes: 6 additions & 1 deletion pkgs/objective_c/test/util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,17 @@ void doGC() {
calloc.free(gcNow);
}

@Native<Int Function(Pointer<Void>)>(isLeaf: true, symbol: 'isReadableMemory')
@Native<Int Function(Pointer<Void>)>(
isLeaf: true,
symbol: 'isReadableMemory',
assetId: 'package:objective_c/objective_c.dylib',
)
external int _isReadableMemory(Pointer<Void> ptr);

@Native<Uint64 Function(Pointer<Void>)>(
isLeaf: true,
symbol: 'getObjectRetainCount',
assetId: 'package:objective_c/objective_c.dylib',
)
external int _getObjectRetainCount(Pointer<Void> object);

Expand Down
Loading