mirror of
https://github.com/flutter/packages.git
synced 2025-07-04 17:49:50 +08:00
[Pigeon] Add the optional sdkPath parameter for specifying Dart SDK path (#434)
This commit is contained in:
@ -9,6 +9,7 @@
|
||||
* Fixed NPE in java generated code for nested types.
|
||||
* Started supporting generics' type arguments for fields in classes.
|
||||
* Generics (class fields and primitives)
|
||||
* Added the optional sdkPath parameter for specifying Dart SDK path.
|
||||
|
||||
## 0.3.0
|
||||
|
||||
|
@ -8,6 +8,8 @@ import 'package:pigeon/pigeon_lib.dart';
|
||||
/// This is the main entrypoint for the command-line tool. [args] are the
|
||||
/// commmand line arguments and there is an optional [packageConfig] to
|
||||
/// accomodate users that want to integrate pigeon with other build systems.
|
||||
Future<int> runCommandLine(List<String> args, {Uri? packageConfig}) async {
|
||||
/// [sdkPath] for specifying an optional Dart SDK path.
|
||||
Future<int> runCommandLine(List<String> args,
|
||||
{Uri? packageConfig, String? sdkPath}) async {
|
||||
return Pigeon.run(args);
|
||||
}
|
||||
|
@ -808,12 +808,16 @@ class Pigeon {
|
||||
|
||||
/// Reads the file located at [path] and generates [ParseResults] by parsing
|
||||
/// it. [types] optionally filters out what datatypes are actually parsed.
|
||||
ParseResults parseFile(String inputPath) {
|
||||
/// [sdkPath] for specifying the Dart SDK path for
|
||||
/// [AnalysisContextCollection].
|
||||
ParseResults parseFile(String inputPath, {String? sdkPath}) {
|
||||
final List<String> includedPaths = <String>[
|
||||
path.absolute(path.normalize(inputPath))
|
||||
];
|
||||
final AnalysisContextCollection collection =
|
||||
AnalysisContextCollection(includedPaths: includedPaths);
|
||||
final AnalysisContextCollection collection = AnalysisContextCollection(
|
||||
includedPaths: includedPaths,
|
||||
sdkPath: sdkPath,
|
||||
);
|
||||
|
||||
final List<Error> compilationErrors = <Error>[];
|
||||
final _RootBuilder rootBuilder =
|
||||
@ -941,9 +945,10 @@ options:
|
||||
|
||||
/// The 'main' entrypoint used by the command-line tool. [args] are the
|
||||
/// command-line arguments. The optional parameter [generators] allows you to
|
||||
/// customize the generators that pigeon will use.
|
||||
/// customize the generators that pigeon will use. The optional parameter
|
||||
/// [sdkPath] allows you to specify the Dart SDK path.
|
||||
static Future<int> run(List<String> args,
|
||||
{List<Generator>? generators}) async {
|
||||
{List<Generator>? generators, String? sdkPath}) async {
|
||||
final Pigeon pigeon = Pigeon.setup();
|
||||
PigeonOptions options = Pigeon.parseArgs(args);
|
||||
final List<Generator> safeGenerators = generators ??
|
||||
@ -969,7 +974,8 @@ options:
|
||||
ObjcOptions(header: path.basename(options.objcHeaderOut!)))));
|
||||
}
|
||||
|
||||
final ParseResults parseResults = pigeon.parseFile(options.input!);
|
||||
final ParseResults parseResults =
|
||||
pigeon.parseFile(options.input!, sdkPath: sdkPath);
|
||||
if (parseResults.pigeonOptions != null) {
|
||||
options = PigeonOptions.fromMap(
|
||||
mergeMaps(options.toMap(), parseResults.pigeonOptions!));
|
||||
|
Reference in New Issue
Block a user