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
28 changes: 27 additions & 1 deletion .github/workflows/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,10 @@ jobs:

# ci-job-test-dart
test-dart:
runs-on: ubuntu-latest
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
Expand All @@ -345,10 +348,33 @@ jobs:
- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672 # v1.6.5
with:
sdk: ${{ github.event_name != 'schedule' && '3.9.0-138.0.dev' || 'dev' }}
- name: Install yq if Windows
if: ${{ matrix.os == 'windows-latest' }}
run: choco install yq

# Actual job
- name: Run `cargo make ci-job-test-dart`
run: cargo make ci-job-test-dart

- name: Run `cargo make ci-job-test-dart` in local mode
run: |
cp ffi/dart/.dart_tool/native_assets/lib/* dylib
yq -i ".hooks.user_defines.icu4x.buildMode = \"local\"" ffi/dart/pubspec.yaml
yq -i ".hooks.user_defines.icu4x.localPath = \"file://$(realpath dylib)\"" ffi/dart/pubspec.yaml
yq -i ".hooks.user_defines.icu4x.buildMode = \"local\"" examples/dart/pubspec.yaml
yq -i ".hooks.user_defines.icu4x.localPath = \"file://$(realpath dylib)\"" examples/dart/pubspec.yaml
cargo make ci-job-test-dart
rm dylib

- name: Run `cargo make ci-job-test-dart` in fetch mode
# Only run if not PR, or if PR and skip_fetch is false
# TODO: Uncomment this after releasing artifacts.
# if: github.event_name != 'pull_request' || needs.check_skip_fetch.outputs.skip_fetch == 'false'
if: false
run: |
yq -i ".hooks.user_defines.icu4x.buildMode = \"fetch\"" ffi/dart/pubspec.yaml
yq -i ".hooks.user_defines.icu4x.buildMode = \"fetch\"" examples/dart/pubspec.yaml
cargo make ci-job-test-dart


# ci-job-nostd
Expand Down
1 change: 1 addition & 0 deletions examples/dart/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
bin/example/
14 changes: 7 additions & 7 deletions examples/dart/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ packages:
dependency: transitive
description:
name: code_assets
sha256: dd7ed641b7f642092092969f2dcd5845ab31c9f3efead0c06ca437bf9ce8a8b2
sha256: "7f42899e7b22f7810ea8c2b281c979add25555fbe391dde539621069e20b90b4"
url: "https://pub.dev"
source: hosted
version: "0.19.4"
version: "0.19.5"
collection:
dependency: transitive
description:
Expand Down Expand Up @@ -69,17 +69,17 @@ packages:
dependency: transitive
description:
name: hooks
sha256: "75363eae6c0c2db051c4f6b3b1fcdea8a09c4a596cc83bfff847661da6e80dfc"
sha256: "2bd640e4625fdfe5788ef33d825a8639797d44bce05695ab13543cde0ff9a078"
url: "https://pub.dev"
source: hosted
version: "0.19.5"
version: "0.20.0"
icu4x:
dependency: "direct main"
description:
path: "../../ffi/dart"
relative: true
source: path
version: "0.1.0-dev"
version: "2.0.0-dev.0"
logging:
dependency: transitive
description:
Expand All @@ -100,10 +100,10 @@ packages:
dependency: transitive
description:
name: native_toolchain_c
sha256: "74a0c80d877c519bc6bde2c4e27b6b01c1f93c9b480f65ceae8bedd3aba3c086"
sha256: "7e8358a4f6ec69a4f2d366bb971af298aca50d6c2e8a07be7c12d7f6d40460aa"
url: "https://pub.dev"
source: hosted
version: "0.16.8"
version: "0.17.1"
path:
dependency: transitive
description:
Expand Down
24 changes: 17 additions & 7 deletions ffi/dart/lib/src/hook_helpers/build_libs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,25 @@ Future<File> buildLib(

final isNoStd = _isNoStdTarget((targetOS, targetArchitecture));
final target = _asRustTarget(targetOS, targetArchitecture, isSimulator);
if (!isNoStd) {
final rustArguments = ['target', 'add', target];
await runProcess(
'rustup',
rustArguments,
workingDirectory: workingDirectory,
);

if (buildStatic || isNoStd) {
await runProcess('rustup', [
'toolchain',
'install',
'--no-self-update',
'nightly',
'--component',
'rust-src',
], workingDirectory: workingDirectory);
}

await runProcess('rustup', [
'target',
'add',
target,
if (buildStatic || isNoStd) ...['--toolchain', 'nightly'],
], workingDirectory: workingDirectory);

final additionalFeatures = isNoStd
? ['libc_alloc', 'looping_panic_handler']
: ['simple_logger'];
Expand Down
1 change: 0 additions & 1 deletion ffi/dart/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ dependencies:
dev_dependencies:
dart_flutter_team_lints: ^3.5.2
test: ^1.21.0
yaml_edit: ^2.2.2

hooks:
user_defines:
Expand Down
31 changes: 0 additions & 31 deletions ffi/dart/tool/write_option_file.dart

This file was deleted.

23 changes: 21 additions & 2 deletions tools/make/ffi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,32 @@ args = ["-C", "examples/js-tiny", "test"]
[tasks.test-dart]
description = "Run Dart tests"
category = "ICU4X Development"
cwd = "ffi/dart"
script_runner = "@duckscript"
script = '''
cd ffi/dart
exec --fail-on-error dart pub get
exec --fail-on-error dart format --set-exit-if-changed .
exec --fail-on-error dart analyze
exec --fail-on-error dart --enable-experiment=native-assets test
exec --fail-on-error dart --enable-experiment=native-assets --enable-experiment=record-use test
cd ../..

cd examples/dart
exec --fail-on-error dart pub get
exec --fail-on-error dart format --set-exit-if-changed .
exec --fail-on-error dart analyze
exec --fail-on-error dart --enable-experiment=native-assets --enable-experiment=record-use build bin/example.dart
exec --fail-on-error bin/example/example.exe
libs = glob_array ./bin/example/lib/*
lib = array_pop ${libs}
size = filesize ${lib}
println ${size} "bytes"
pubspec = readfile pubspec.yaml
is_local = contains ${pubspec} "buildMode: local"
if not ${is_local} # local dylib is not treeshaken
if greater_than ${size} 10000000
trigger_error "Dart example binary >10MB"
end
end
'''

# no_std tasks
Expand Down
Loading