Skip to content

WIP: [objective_c] Migrate to native assets #2329

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 21 commits into
base: main
Choose a base branch
from
Draft
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
30 changes: 15 additions & 15 deletions .github/workflows/ffigen.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,17 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
channel: master
- id: install
name: Install dependencies
run: flutter pub get && flutter pub get --directory="example/shared_bindings" && flutter pub get --directory="../objective_c"
run: dart pub get && dart pub get --directory="example/shared_bindings" && dart pub get --directory="../objective_c"
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Analyze code
run: flutter analyze --fatal-infos
run: dart analyze --fatal-infos

test-linux:
needs: analyze
Expand All @@ -56,9 +56,9 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../jni"
run: dart pub get && flutter pub get --directory="../jni"
- name: Install libclang-14-dev
run: sudo apt-get install libclang-14-dev
- name: Build test dylib and bindings
Expand All @@ -80,9 +80,9 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: stable
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
- name: Install clang-format
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
with:
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
with:
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
- name: Install clang-format
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
with:
Expand All @@ -142,13 +142,13 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../objective_c"
run: dart pub get && dart pub get --directory="../objective_c"
- name: Build test dylib and bindings
run: dart test/setup.dart --main-thread-dispatcher
run: dart test/setup.dart
- name: Run Flutter tests
run: flutter test
run: dart test

test-windows:
needs: analyze
Expand All @@ -160,9 +160,9 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../jni"
run: dart pub get && flutter pub get --directory="../jni"
- name: Build test dylib and bindings
run: dart test/setup.dart
- name: Run VM tests
Expand Down Expand Up @@ -191,7 +191,7 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: "master"
channel: master
- name: Install dependencies
run: flutter pub get
- name: Build test dylib and bindings
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/ffigen_weekly.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ jobs:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
with:
channel: 'stable'
channel: master
- name: Install dependencies
run: flutter pub get && flutter pub get --directory="../objective_c" && flutter pub get --directory="../jni"
run: dart pub get && dart pub get --directory="../objective_c" && flutter pub get --directory="../jni"
- name: Install clang-format
uses: ConorMacBride/install-package@3e7ad059e07782ee54fa35f827df52aae0626f30
with:
brew: clang-format
- name: Build test dylib and bindings
run: dart test/setup.dart --main-thread-dispatcher
run: dart test/setup.dart
- name: Run VM tests
run: flutter test
run: dart test
- name: Generate package:jni bindings
run: dart run tool/generate_ffi_bindings.dart
working-directory: pkgs/jni/
29 changes: 13 additions & 16 deletions .github/workflows/objective_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,17 +31,17 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
channel: 'stable'
sdk: dev
- id: install
name: Install dependencies
run: flutter pub get
run: dart pub get
- name: Check formatting
run: dart format --output=none --set-exit-if-changed .
if: always() && steps.install.outcome == 'success'
- name: Analyze code
run: flutter analyze --fatal-infos
run: dart analyze --fatal-infos
if: always() && steps.install.outcome == 'success'

test-mac:
Expand All @@ -52,14 +52,11 @@ jobs:
working-directory: pkgs/objective_c/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
channel: 'stable'
sdk: dev
- name: Install dependencies
run: flutter pub get
- name: Build test dylib
# TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
run: dart test/setup.dart
run: dart pub get
- name: Install coverage
run: dart pub global activate coverage
- name: Run VM tests and collect coverage
Expand Down Expand Up @@ -87,13 +84,13 @@ jobs:
runs-on: 'macos-latest'
defaults:
run:
working-directory: pkgs/objective_c/example/
working-directory: pkgs/objective_c/example
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046
- uses: dart-lang/setup-dart@e51d8e571e22473a2ddebf0ef8a2123f0ab2c02c
with:
channel: 'stable'
sdk: dev
- name: Install dependencies
run: flutter pub get
- name: Build the example app
run: flutter build macos
run: dart pub get
- name: Run the example app
run: dart run lib/main.dart
1 change: 1 addition & 0 deletions pkgs/ffigen/lib/src/code_generator/writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ class Writer {
],
);
}
additionalImports.forEach(markImportUsed);

/// [_lookupFuncIdentifier] should be unique in top level.
_lookupFuncIdentifier = _resolveNameConflict(
Expand Down
13 changes: 8 additions & 5 deletions pkgs/ffigen/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,14 @@ dev_dependencies:
json_schema: ^5.1.1
leak_tracker: ^10.0.7
objective_c: ^8.1.0
test: ^1.16.2
test: ^1.26.2

dependency_overrides:
# package:objective_c has a flutter dependency, so `dart test` must be run
# using the dart from the flutter SDK.
# See https://github.com/dart-lang/native/issues/1068
code_assets:
path: ../code_assets
hooks:
path: ../hooks
native_toolchain_c:
path: ../native_toolchain_c
objective_c:
path: ../objective_c/
path: ../objective_c
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/arc_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ void main() {

group('ARC', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/bad_method_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ import 'util.dart';
void main() {
group('bad_method_test', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/bad_override_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ import 'util.dart';
void main() {
group('bad overrides', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/block_annotation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ void main() {
// correct block type.

setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/block_inherit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,6 @@ import 'util.dart';
void main() {
group('Block inheritance', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/block_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,6 @@ void main() {

group('Blocks', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/cast_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ void main() {

group('cast', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/category_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ import 'util.dart';
void main() {
group('categories', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/forward_decl_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ import 'util.dart';
void main() {
group('forward decl', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/global_native_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,6 @@ import 'util.dart';
void main() {
group('global using @Native', () {
setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
10 changes: 0 additions & 10 deletions pkgs/ffigen/test/native_objc_test/global_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,6 @@ void main() {
late GlobalTestObjCLibrary lib;

setUpAll(() {
// TODO(https://github.com/dart-lang/native/issues/1068): Remove this.
DynamicLibrary.open(
path.join(
packagePathForTests,
'..',
'objective_c',
'test',
'objective_c.dylib',
),
);
final dylib = File(
path.join(
packagePathForTests,
Expand Down
Loading
Loading