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

Make Dart build script feature-aware #5264

Merged
merged 6 commits into from
Jul 18, 2024
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
2 changes: 1 addition & 1 deletion ffi/dart/build.dart
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void main(List<String> args) async {

final path = '${config.outDir.path}/icu4x';

await buildLib(target, linkMode, path);
await buildLib(target, linkMode, 'default_components,experimental_components', path);

await BuildOutput(
assets: [
Expand Down
15 changes: 8 additions & 7 deletions ffi/dart/tool/build_libs.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ import 'dart:io';
Future<void> main(List<String> args) async {
if (args.isEmpty) {
print(
'Usage: ${Platform.script.pathSegments.last} <out_dir> <target:${Target.values}> (<link mode: ${LinkMode.values}>)');
'Usage: ${Platform.script.pathSegments.last} <out_dir> <target:${Target.values}> <link mode: ${LinkMode.values}> <cargo features>');
exit(1);
}
final out = Uri.file(args[0]).toFilePath();
final target = Target.values.firstWhere((t) => t.toString() == args[1]);
final linkMode = LinkMode.values.firstWhere(
(l) => l.toString() == (args.elementAtOrNull(2) ?? 'dynamic'));
final linkMode = LinkMode.values.firstWhere((l) => l.toString() == args[2]);
final cargoFeatures = args.elementAtOrNull(3) ?? 'default_components';

await buildLib(target, linkMode, out);
await buildLib(target, linkMode, cargoFeatures, out);
}

Future<void> buildLib(Target target, LinkMode linkMode, String outName) async {
Future<void> buildLib(
Target target, LinkMode linkMode, String cargoFeatures, String outName) async {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: Trailing comma would result in nicer formatting

var root = Platform.script.toFilePath().split('ffi')[0];
root = root.substring(0, root.length - 1); // trim trailing slash

Expand Down Expand Up @@ -56,9 +57,9 @@ Future<void> buildLib(Target target, LinkMode linkMode, String outName) async {
'--config=profile.release.codegen-units=1',
'--no-default-features',
if (!isNoStd)
'--features=default_components,compiled_data,buffer_provider,logging,simple_logger',
'--features=compiled_data,buffer_provider,logging,simple_logger,$cargoFeatures',
if (isNoStd)
'--features=default_components,compiled_data,buffer_provider,libc-alloc,panic-handler',
'--features=compiled_data,buffer_provider,libc-alloc,panic-handler,$cargoFeatures',
if (isNoStd) '-Zbuild-std=core,alloc',
if (isNoStd) '-Zbuild-std-features=panic_immediate_abort',
'--target=$rustTarget',
Expand Down