Skip to content

[native_assets_cli] Is there any way to pass environment variables/command line arguments to hook/build.dart? #2078

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

Closed
nmfisher opened this issue Mar 7, 2025 · 2 comments

Comments

@nmfisher
Copy link
Contributor

nmfisher commented Mar 7, 2025

It would be nice to read environment variables to set build-time parameters. Log levels are a good example, like:

    final cbuilder = CBuilder.library(
      defines:{"TRACE":Process.environment["TRACE"]}

or from CLI parameters, ala:

dart --enable-experiment run lib/app.dart --trace=1

Is this currently possible? All of the following seem to have stripped anything relevant:

const trace = String.fromEnvironment("TRACE");
Platform.executableArguments
Platform.environment
@mkustermann
Copy link
Member

This may be a duplicate of #39

Generally our thinking was that we'd want to do this in more controlled fashion. A package's hook can decide flags it offers and end-users could configure that particular package's flag when building. e.g.

% dart run \
  -B package.<pkgfoo>.debug=true \
  -B package.<pkgbar>.cppAsserts=true \
  ... \
  foo.dart

Possibly allowing to persist such flags for an application package in pubspec or other file.

/cc @dcharkes

@dcharkes
Copy link
Collaborator

dcharkes commented Mar 7, 2025

Yes, closing this as duplicate of #39.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants