Skip to content
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

[infra] Use Pub Workspaces #1884

Open
wants to merge 44 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e2d528f
Added ffi to workspace
Levi-Lesches Jan 12, 2025
935a52c
Added ffigen to workspace
Levi-Lesches Jan 12, 2025
4abff69
Added jni to workspace (FAILED)
Levi-Lesches Jan 12, 2025
58df689
Fixed jni issues
Levi-Lesches Jan 13, 2025
6d1fb6b
Fixed issues in ffigen
Levi-Lesches Jan 13, 2025
2998552
Added jnigen to workspace
Levi-Lesches Jan 13, 2025
fefc30f
Added native_assets_builder to the workspace
Levi-Lesches Jan 13, 2025
349c05c
Fixed issues with native_assets_builder/test_data/*
Levi-Lesches Jan 13, 2025
aad35e2
Fix lints
Levi-Lesches Jan 13, 2025
d512ee2
Fixed issues in native_assets_cli
Levi-Lesches Jan 13, 2025
c6069a0
Added objective_c to the workspace
Levi-Lesches Jan 13, 2025
7394804
Added swift2objc ot the workspace
Levi-Lesches Jan 13, 2025
c1ec515
Added swiftgen to the workspace
Levi-Lesches Jan 13, 2025
eaf70d0
Bumped publish CI to stable channel (from dev)
Levi-Lesches Jan 13, 2025
234310e
Added ffi and ffigen to workspace analysis_options.yaml
Levi-Lesches Jan 13, 2025
04efe21
Added jni to analysis_options.yaml and fixed lints
Levi-Lesches Jan 13, 2025
0285b9a
Added jnigen to analysis_options.yaml and fixed lints
Levi-Lesches Jan 13, 2025
4c21c13
Added native_assets_builder to analysis_options.yaml
Levi-Lesches Jan 13, 2025
2cdbf2c
Added native_assets_cli to analysis_options.yaml
Levi-Lesches Jan 13, 2025
788f876
Added native_toolchain_c and objective_c to analysis_options
Levi-Lesches Jan 13, 2025
b0d1609
Added swift2objc to analysis_options and fixed lints
Levi-Lesches Jan 13, 2025
29536dc
Added swiftgen to analysis_options
Levi-Lesches Jan 13, 2025
4f0391a
Formatted and fixed lints
Levi-Lesches Jan 13, 2025
1e939dd
Added all native_assets_builder/test_data to workspace
Levi-Lesches Jan 13, 2025
e449145
Revert "Added all native_assets_builder/test_data to workspace"
Levi-Lesches Jan 13, 2025
466625f
Fixed wrong_linker name
Levi-Lesches Jan 13, 2025
b69058e
Fixed fail_on_os_sdk_version_link name
Levi-Lesches Jan 13, 2025
92c57ac
Fixed native_add_source name
Levi-Lesches Jan 13, 2025
27286a9
Fixed native_add_version_skew name
Levi-Lesches Jan 13, 2025
bad52ba
Added all test_data to the workspace (not version_skew)
Levi-Lesches Jan 13, 2025
815671e
Updated CI to use Flutter and dev -> beta channel
Levi-Lesches Jan 13, 2025
ca1602f
CI: Replaced beta -> main channel
Levi-Lesches Jan 14, 2025
33640fa
Reworked native_assets_builder test helpers to remove workspace
Levi-Lesches Jan 14, 2025
58f28cd
Fixed more CI checks
Levi-Lesches Jan 14, 2025
f389a65
Removed extra pub gets from CI
Levi-Lesches Jan 14, 2025
bc7ec72
Added native_assets_cli/example/* to workspace
Levi-Lesches Jan 15, 2025
29c6eea
Added ffigen/example/* to the workspace
Levi-Lesches Jan 15, 2025
fbe5cd4
Merge branch 'main' into workspaces
Levi-Lesches Jan 15, 2025
b3f91b2
Merged main branch
Levi-Lesches Jan 15, 2025
e7e5adb
Bumped versions and added Dart 3.6 to changelogs
Levi-Lesches Jan 15, 2025
c4fe35c
Fix some more CIs
Levi-Lesches Jan 15, 2025
a2f412a
Fix even more CI
Levi-Lesches Jan 15, 2025
1d86663
Fix package:jni ffigen issues
HosseinYousefi Jan 21, 2025
bf5d11c
Merged main
Levi-Lesches Jan 21, 2025
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
11 changes: 5 additions & 6 deletions .github/workflows/ffi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ env:

jobs:
# Check code formatting and static analysis on a single OS (linux)
# against Dart dev.
analyze:
runs-on: ubuntu-latest
defaults:
Expand All @@ -29,10 +28,10 @@ jobs:
strategy:
fail-fast: false
matrix:
sdk: [dev]
sdk: [beta]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: ${{ matrix.sdk }}
- id: install
Expand All @@ -47,7 +46,7 @@ jobs:

# Run tests on a matrix consisting of two dimensions:
# 1. OS: ubuntu-latest, (macos-latest, windows-latest)
# 2. release channel: dev
# 2. release channel: beta
test:
needs: analyze
runs-on: ${{ matrix.os }}
Expand All @@ -59,10 +58,10 @@ jobs:
matrix:
# Add macos-latest and/or windows-latest if relevant for this package.
os: [ubuntu-latest]
sdk: [beta, dev]
sdk: [beta]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: ${{ matrix.sdk }}
- id: install
Expand Down
22 changes: 11 additions & 11 deletions .github/workflows/native.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
sdk: [stable, dev]
sdk: [stable, beta]
package: [native_assets_builder, native_assets_cli, native_toolchain_c]
# Breaking changes temporarily break the example run on the Dart SDK until native_assets_builder is rolled into the Dart SDK dev build.
breaking-change: [false]
Expand All @@ -46,7 +46,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: ${{ matrix.sdk }}

Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:

- run: dart pub get -C example/build/system_library/
if: ${{ matrix.package == 'native_assets_cli' }}

- run: dart pub get -C example/link/package_with_assets/
if: ${{ matrix.package == 'native_assets_cli' }}

Expand Down Expand Up @@ -156,32 +156,32 @@ jobs:
# TODO(https://github.com/dart-lang/native/issues/190): Enable on windows once
# https://github.com/dart-lang/sdk/commit/903eea6bfb8ee405587f0866a1d1e92eea45d29e
# has landed in dev channel.
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change && matrix.os != 'windows' }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change && matrix.os != 'windows' }}

- run: dart --enable-experiment=native-assets test
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

- run: dart --enable-experiment=native-assets run
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

- run: dart --enable-experiment=native-assets build bin/native_add_app.dart
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

- run: ./native_add_app.exe
working-directory: pkgs/${{ matrix.package }}/example/build/native_add_app/bin/native_add_app/
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

- run: dart --enable-experiment=native-assets test
working-directory: pkgs/${{ matrix.package }}/example/build/use_dart_api/
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

# TODO(https://github.com/dart-lang/native/issues/1879): Enable this when the fix has rolled into Dart.
# - run: dart --enable-experiment=native-assets test
# working-directory: pkgs/${{ matrix.package }}/example/build/system_library/
# if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'dev' && !matrix.breaking-change }}
# if: ${{ matrix.package == 'native_assets_cli' && matrix.sdk == 'beta' && !matrix.breaking-change }}

- name: Install coverage
run: dart pub global activate coverage
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/native_toolchain_c.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: ${{ matrix.sdk }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/package_download_asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683

- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: stable

Expand Down Expand Up @@ -61,7 +61,7 @@ jobs:
dart tool/build.dart -olinux -aia32
dart tool/build.dart -olinux -ariscv64
dart tool/build.dart -olinux -ax64

- name: Build MacOS host
if: matrix.os == 'macos'
run: |
Expand All @@ -70,15 +70,15 @@ jobs:
dart tool/build.dart -oios -iiphoneos -aarm64
dart tool/build.dart -oios -iiphonesimulator -aarm64
dart tool/build.dart -oios -iiphonesimulator -ax64

- name: Build Windows host
if: matrix.os == 'windows'
run: |
dart tool/build.dart -owindows -aarm
dart tool/build.dart -owindows -aarm64
dart tool/build.dart -owindows -aia32
dart tool/build.dart -owindows -ax64

- name: Upload artifacts
uses: actions/upload-artifact@b4b15b8c7c6ac21ea08fcf65892d2ee8f75cf882
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
pull-requests: write # Required for writing the pull request note
with:
write-comments: false
sdk: dev # use beta/stable after 3.3.0
sdk: stable
4 changes: 2 additions & 2 deletions .github/workflows/swift2objc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
fail-fast: false
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: stable
- id: install
Expand All @@ -50,7 +50,7 @@ jobs:
working-directory: pkgs/swift2objc/
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
- uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- uses: subosito/flutter-action@74af56c5ed2697ba4621264652728e8d217e53d3
with:
sdk: stable
- name: Install dependencies
Expand Down
42 changes: 42 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
errors:
todo: ignore

language:
strict-casts: true
strict-inference: true
strict-raw-types: true

exclude:
# ffigen excludes
# Exclude anything that uses package:objective_c, due to flutter dependency.
# https://github.com/dart-lang/native/issues/1068
- pkgs/ffigen/example/objective_c/**
- pkgs/ffigen/example/swift/**
- pkgs/ffigen/test_flutter/native_objc_test/**
- pkgs/ffigen/test/native_objc_test/**
- pkgs/ffigen/**/expected_bindings/**

# jni excludes
- pkgs/jni/build/**
- pkgs/jni/third_party/**

# jnigen excludes
- pkgs/jnigen/build/**
- pkgs/jnigen/example/**

# objective_c excludes
- pkgs/objective_c/tool/data/extra_methods.dart

linter:
rules:
prefer_final_locals: true
# ffigen rules
dangling_library_doc_comments: true
directives_ordering: true
prefer_final_in_for_each: true
use_super_parameters: true
# jni rules
prefer_const_declarations: true
13 changes: 0 additions & 13 deletions pkgs/ffi/analysis_options.yaml

This file was deleted.

2 changes: 1 addition & 1 deletion pkgs/ffi/example/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void main() {

// Use the Utf8 helper to encode zero-terminated UTF-8 strings in native
// memory.
final myString = '😎👿💬';
const myString = '😎👿💬';
final charPointer = myString.toNativeUtf8();
print('First byte is: ${charPointer.cast<Uint8>().value}');
print(charPointer.toDartString());
Expand Down
5 changes: 3 additions & 2 deletions pkgs/ffi/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ topics:
- codegen

environment:
sdk: '>=3.3.0 <4.0.0'
sdk: ^3.6.0

resolution: workspace
dev_dependencies:
dart_flutter_team_lints: ^2.0.0
dart_flutter_team_lints: ^3.2.0
test: ^1.21.2
4 changes: 2 additions & 2 deletions pkgs/ffi/test/allocation_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ void main() async {

test('testPointerAllocateTooLarge', () {
// Try to allocate something that doesn't fit in 64 bit address space.
final maxInt = 9223372036854775807; // 2^63 - 1
const maxInt = 9223372036854775807; // 2^63 - 1
expect(() => calloc<Uint8>(maxInt), throwsA(isA<ArgumentError>()));

// Try to allocate almost the full 64 bit address space.
final maxInt1_8 = 1152921504606846975; // 2^60 -1
const maxInt1_8 = 1152921504606846975; // 2^60 -1
expect(() => calloc<Uint8>(maxInt1_8), throwsA(isA<ArgumentError>()));
});

Expand Down
14 changes: 7 additions & 7 deletions pkgs/ffi/test/utf16_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import 'package:test/test.dart';

void main() {
test('toUtf16 ASCII', () {
final start = 'Hello World!\n';
const start = 'Hello World!\n';
final converted = start.toNativeUtf16().cast<Uint16>();
final end = converted.asTypedList(start.codeUnits.length + 1);
final matcher = equals(start.codeUnits.toList()..add(0));
Expand All @@ -18,7 +18,7 @@ void main() {
});

test('toUtf16 emoji', () {
final start = '😎';
const start = '😎';
final converted = start.toNativeUtf16().cast();
final length = start.codeUnits.length;
final end = converted.cast<Uint16>().asTypedList(length + 1);
Expand All @@ -28,38 +28,38 @@ void main() {
});

test('from Utf16 ASCII', () {
final string = 'Hello World!\n';
const string = 'Hello World!\n';
final utf16Pointer = string.toNativeUtf16();
final stringAgain = utf16Pointer.toDartString();
expect(stringAgain, string);
calloc.free(utf16Pointer);
});

test('from Utf16 emoji', () {
final string = '😎';
const string = '😎';
final utf16Pointer = string.toNativeUtf16();
final stringAgain = utf16Pointer.toDartString();
expect(stringAgain, string);
calloc.free(utf16Pointer);
});

test('zero bytes', () {
final string = 'Hello\x00World!\n';
const string = 'Hello\x00World!\n';
final utf16Pointer = string.toNativeUtf16();
final stringAgain = utf16Pointer.toDartString(length: 13);
expect(stringAgain, string);
calloc.free(utf16Pointer);
});

test('length', () {
final string = 'Hello';
const string = 'Hello';
final utf16Pointer = string.toNativeUtf16();
expect(utf16Pointer.length, 5);
calloc.free(utf16Pointer);
});

test('fromUtf8 with negative length', () {
final string = 'Hello';
const string = 'Hello';
final utf16 = string.toNativeUtf16();
expect(() => utf16.toDartString(length: -1), throwsRangeError);
calloc.free(utf16);
Expand Down
8 changes: 4 additions & 4 deletions pkgs/ffi/test/utf8_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pointer<Uint8> _bytesFromList(List<int> ints) {

void main() {
test('toUtf8 ASCII', () {
final start = 'Hello World!\n';
const start = 'Hello World!\n';
final converted = start.toNativeUtf8().cast<Uint8>();
final end = converted.asTypedList(start.length + 1);
final matcher = equals(
Expand All @@ -36,7 +36,7 @@ void main() {
});

test('toUtf8 emoji', () {
final start = '😎👿💬';
const start = '😎👿💬';
final converted = start.toNativeUtf8().cast<Utf8>();
final length = converted.length;
final end = converted.cast<Uint8>().asTypedList(length + 1);
Expand Down Expand Up @@ -100,7 +100,7 @@ void main() {
});

test('length', () {
final string = 'Hello';
const string = 'Hello';
final utf8Pointer = string.toNativeUtf8();
expect(utf8Pointer.length, 5);
calloc.free(utf8Pointer);
Expand All @@ -117,7 +117,7 @@ void main() {
});

test('zero terminated', () {
final string = 'Hello';
const string = 'Hello';
final utf8Pointer = string.toNativeUtf8();
final charPointer = utf8Pointer.cast<Char>();
expect(charPointer[utf8Pointer.length], 0);
Expand Down
Loading
Loading