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

Add link hook to package:intl4x #866

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
Open
112 changes: 94 additions & 18 deletions .github/workflows/intl4x.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,34 @@ jobs:
matrix:
sdk: [dev]
os: [ubuntu-latest, windows-latest, macos-latest]
include:
- sdk: dev
run-tests: true

steps:
- uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9
with:
submodules: true

- uses: dart-lang/setup-dart@0a8a0fc875eb934c15d08629302413c671d3f672
with:
sdk: ${{matrix.sdk}}
sdk: ${{ matrix.sdk }}

- run: dart --enable-experiment=native-assets pub get

- run: dart --enable-experiment=native-assets analyze --fatal-infos

- run: dart --enable-experiment=native-assets format --output=none --set-exit-if-changed .
if: ${{matrix.run-tests}}

- run: dart --enable-experiment=native-assets test
if: ${{matrix.run-tests}}

- run: dart --enable-experiment=native-assets test -p chrome
if: ${{matrix.run-tests}}

#TODO: Enable for windows and mac https://github.com/dart-lang/native/issues/1376
- name: Compile and run example
if: matrix.os == 'ubuntu-latest'
run: |
cd example_native
dart --enable-experiment=native-assets pub get
dart --enable-experiment=native-assets build bin/example_native.dart
./bin/example_native/example_native.exe

build_fetch:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -84,11 +88,21 @@ jobs:

- run: dart --enable-experiment=native-assets test

#TODO: Enable for windows and mac https://github.com/dart-lang/native/issues/1376
- name: Compile and run example
if: matrix.os == 'ubuntu-latest'
run: |
cd example_native
dart --enable-experiment=native-assets pub get
dart --enable-experiment=native-assets build bin/example_native.dart
./bin/example_native/example_native.exe

build_local:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
compiletype: [ dynamic, static ]
runs-on: ${{ matrix.os }}

env:
Expand Down Expand Up @@ -120,7 +134,16 @@ jobs:
cd ffi/dart
dart pub get
cd ../..
dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64 dynamic icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data
dart run ffi/dart/tool/build_libs.dart bin/linux_x64 linux_x64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data

cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard

cd provider/datagen # avoid global feature resolution
rustup target add x86_64-unknown-linux-gnu
cargo build --release --bin icu4x-datagen --no-default-features --features bin,blob_exporter,blob_input,rayon,experimental_components --target x86_64-unknown-linux-gnu
cd ../..

cp target/x86_64-unknown-linux-gnu/release/icu4x-datagen bin/linux_x64-datagen

- name: Build Mac
if: matrix.os == 'macos-latest'
Expand All @@ -132,7 +155,16 @@ jobs:
cd ffi/dart
dart pub get
cd ../..
dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64 dynamic icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data
dart run ffi/dart/tool/build_libs.dart bin/macos_arm64 macos_arm64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data

cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard

cd provider/datagen # avoid global feature resolution
rustup target add x86_64-apple-darwin
cargo build --release --bin icu4x-datagen --no-default-features --features bin,blob_exporter,blob_input,rayon,experimental_components --target x86_64-apple-darwin
cd ../..

cp target/x86_64-apple-darwin/release/icu4x-datagen bin/macos_x64-datagen

- name: Build Windows
if: matrix.os == 'windows-latest'
Expand All @@ -144,18 +176,52 @@ jobs:
cd ffi/dart
dart pub get
cd ../..
dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64 dynamic icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data
dart run ffi/dart/tool/build_libs.dart bin/windows_x64 windows_x64 ${{ matrix.compiletype }} icu_collator,icu_datetime,icu_list,icu_decimal,icu_plurals,experimental_components,compiled_data

cargo run -p icu_datagen -- --locales full --keys all --format blob --out bin/full.postcard

- run: echo "LOCAL_ICU4X_BINARY=$(realpath submodules/icu4x/bin/linux_x64)" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest'
cd provider/datagen # avoid global feature resolution
rustup target add x86_64-pc-windows-msvc
cargo build --release --bin icu4x-datagen --no-default-features --features bin,blob_exporter,blob_input,rayon,experimental_components --target x86_64-pc-windows-msvc
cd ../..

- run: echo "LOCAL_ICU4X_BINARY=$(realpath submodules/icu4x/bin/macos_arm64)" >> $GITHUB_ENV
if: matrix.os == 'macos-latest'

- run: echo ("LOCAL_ICU4X_BINARY=" + (Get-Item submodules\icu4x\bin\windows_x64).FullName -replace '/', '\') >> $env:GITHUB_ENV
if: matrix.os == 'windows-latest'
cp target/x86_64-pc-windows-msvc/release/icu4x-datagen.exe bin/windows_x64-datagen.exe

- run: |
echo "LOCAL_ICU4X_BINARY_DYNAMIC=$(realpath submodules/icu4x/bin/linux_x64)" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest' && matrix.compiletype == 'dynamic'

- run: echo $LOCAL_ICU4X_BINARY
- run: |
echo "LOCAL_ICU4X_BINARY_STATIC=$(realpath submodules/icu4x/bin/linux_x64)" >> $GITHUB_ENV
echo "LOCAL_ICU4X_DATAGEN=$(realpath submodules/icu4x/bin/linux_x64-datagen)" >> $GITHUB_ENV
echo "LOCAL_ICU4X_POSTCARD=$(realpath submodules/icu4x/bin/full.postcard)" >> $GITHUB_ENV
if: matrix.os == 'ubuntu-latest' && matrix.compiletype == 'static'

- run: |
echo "LOCAL_ICU4X_BINARY_DYNAMIC=$(realpath submodules/icu4x/bin/macos_arm64)" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' && matrix.compiletype == 'dynamic'

- run: |
echo "LOCAL_ICU4X_BINARY_STATIC=$(realpath submodules/icu4x/bin/macos_arm64)" >> $GITHUB_ENV
echo "LOCAL_ICU4X_DATAGEN=$(realpath submodules/icu4x/bin/macos_x64-datagen)" >> $GITHUB_ENV
echo "LOCAL_ICU4X_POSTCARD=$(realpath submodules/icu4x/bin/full.postcard)" >> $GITHUB_ENV
if: matrix.os == 'macos-latest' && matrix.compiletype == 'static'

- run: |
echo ("LOCAL_ICU4X_BINARY_DYNAMIC=" + (Get-Item submodules\icu4x\bin\windows_x64).FullName -replace '/', '\') >> $env:GITHUB_ENV
if: matrix.os == 'windows-latest' && matrix.compiletype == 'dynamic'

- run: |
echo ("LOCAL_ICU4X_BINARY_STATIC=" + (Get-Item submodules\icu4x\bin\windows_x64).FullName -replace '/', '\') >> $env:GITHUB_ENV
echo ("LOCAL_ICU4X_DATAGEN=" + (Get-Item submodules\icu4x\bin\windows_x64-datagen.exe).FullName -replace '/', '\') >> $env:GITHUB_ENV
echo ("LOCAL_ICU4X_POSTCARD=" + (Get-Item submodules\icu4x\bin\full.postcard).FullName -replace '/', '\') >> $env:GITHUB_ENV
if: matrix.os == 'windows-latest' && matrix.compiletype == 'static'

- run: |
echo $LOCAL_ICU4X_BINARY_DYNAMIC
echo $LOCAL_ICU4X_BINARY_STATIC
echo $LOCAL_ICU4X_DATAGEN
echo $LOCAL_ICU4X_POSTCARD

- name: Display structure of downloaded files
run: ls -R
Expand All @@ -166,6 +232,16 @@ jobs:
dart pub get

- name: Run `dart test`
if: matrix.compiletype == 'dynamic'
run: |
cd pkgs/intl4x
dart --enable-experiment=native-assets test

#TODO: Enable for windows and mac https://github.com/dart-lang/native/issues/1376
- name: Compile and run example
if: matrix.os == 'ubuntu-latest' && matrix.compiletype == 'static'
run: |
cd pkgs/intl4x/example_native
dart --enable-experiment=native-assets pub get
dart --enable-experiment=native-assets build bin/example_native.dart
./bin/example_native/example_native.exe
4 changes: 4 additions & 0 deletions pkgs/intl4x/example_native/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# https://dart.dev/guides/libraries/private-files
# Created by `dart pub`
.dart_tool/
/bin/example_native/
2 changes: 2 additions & 0 deletions pkgs/intl4x/example_native/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
A sample command-line application with an entrypoint in `bin/`, library code
in `lib/`, and example unit test in `test/`.
30 changes: 30 additions & 0 deletions pkgs/intl4x/example_native/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This file configures the static analysis results for your project (errors,
# warnings, and lints).
#
# This enables the 'recommended' set of lints from `package:lints`.
# This set helps identify many issues that may lead to problems when running
# or consuming Dart code, and enforces writing Dart using a single, idiomatic
# style and format.
#
# If you want a smaller set of lints you can change this to specify
# 'package:lints/core.yaml'. These are just the most critical lints
# (the recommended set includes the core lints).
# The core lints are also what is used by pub.dev for scoring packages.

include: package:lints/recommended.yaml

# Uncomment the following section to specify additional rules.

# linter:
# rules:
# - camel_case_types

# analyzer:
# exclude:
# - path/to/excluded/files/**

# For more information about the core and recommended set of lints, see
# https://dart.dev/go/core-lints

# For additional information about configuring this file, see
# https://dart.dev/guides/language/analysis-options
10 changes: 10 additions & 0 deletions pkgs/intl4x/example_native/bin/example_native.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// 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.

import 'package:intl4x/intl4x.dart';

void main(List<String> arguments) {
final intl = Intl(locale: Locale(language: 'en'));
print('collation: ${intl.collation().compare('a', 'b')}!');
}
15 changes: 15 additions & 0 deletions pkgs/intl4x/example_native/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: example_native
description: A sample command-line application.

publish_to: none

environment:
sdk: ^3.6.0-78.0.dev

dependencies:
intl4x:
path: ../

dev_dependencies:
lints: ^4.0.0
test: ^1.24.0
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pkgs/intl4x/hook/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
1. Create PR.
2. Run `bash tools/regenerate_bindings.sh`, and fix resulting errors.
3. Update `const version` in `version.dart` to tag.
4. Regenerate hashes using `cd pkgs/intl4x/; dart --enable-experiment=native-assets run tool/regenerate_hashes.dart`.
4. Regenerate hashes using `cd pkgs/intl4x/; dart --enable-experiment=native-assets tool/regenerate_hashes.dart`.
5. Land PR.
Loading
Loading