From 3e30939b089475dad88932acefd98ee64541552a Mon Sep 17 00:00:00 2001 From: Robert Bastian <4706271+robertbastian@users.noreply.github.com> Date: Thu, 18 Jul 2024 17:11:30 +0200 Subject: [PATCH] Make Dart build script feature-aware (#5264) --- ffi/dart/build.dart | 2 +- ffi/dart/tool/build_libs.dart | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/ffi/dart/build.dart b/ffi/dart/build.dart index d5e3a6f4122..dd027787c3e 100644 --- a/ffi/dart/build.dart +++ b/ffi/dart/build.dart @@ -19,7 +19,7 @@ void main(List 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: [ diff --git a/ffi/dart/tool/build_libs.dart b/ffi/dart/tool/build_libs.dart index 79f3a9d3293..929e79e1b4b 100644 --- a/ffi/dart/tool/build_libs.dart +++ b/ffi/dart/tool/build_libs.dart @@ -8,18 +8,19 @@ import 'dart:io'; Future main(List args) async { if (args.isEmpty) { print( - 'Usage: ${Platform.script.pathSegments.last} ()'); + 'Usage: ${Platform.script.pathSegments.last} '); 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 buildLib(Target target, LinkMode linkMode, String outName) async { +Future buildLib( + Target target, LinkMode linkMode, String cargoFeatures, String outName) async { var root = Platform.script.toFilePath().split('ffi')[0]; root = root.substring(0, root.length - 1); // trim trailing slash @@ -56,9 +57,9 @@ Future 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',