@@ -7,6 +7,7 @@ import 'dart:io';
7
7
import 'package:logging/logging.dart' ;
8
8
import 'package:native_assets_cli/code_assets.dart' ;
9
9
10
+ import '../../native_toolchain_c.dart' ;
10
11
import '../native_toolchain/android_ndk.dart' ;
11
12
import '../native_toolchain/apple_clang.dart' ;
12
13
import '../native_toolchain/clang.dart' ;
@@ -196,29 +197,36 @@ class CompilerResolver {
196
197
return null ;
197
198
}
198
199
199
- Future <Uri ?> toolchainEnvironmentScript (ToolInstance compiler) async {
200
- final fromInput = codeConfig.cCompiler? .envScript;
201
- if (fromInput != null ) {
202
- logger? .fine ('Using envScript from input: $fromInput ' );
203
- return fromInput;
200
+ Future <Map <String , String >> resolveEnvironment (ToolInstance compiler) async {
201
+ final envScriptFromConfig = codeConfig.cCompiler? .envScript;
202
+ if (envScriptFromConfig != null ) {
203
+ logger? .fine ('Using envScript from input: $envScriptFromConfig ' );
204
+ final vcvarsArgs = codeConfig.cCompiler? .envScriptArgs;
205
+ if (vcvarsArgs != null ) {
206
+ logger? .fine ('Using envScriptArgs from input: $vcvarsArgs ' );
207
+ }
208
+ return await environmentFromBatchFile (
209
+ envScriptFromConfig,
210
+ arguments: vcvarsArgs ?? [],
211
+ );
212
+ }
213
+
214
+ if (codeConfig.cCompiler? .compiler != null ) {
215
+ logger? .fine ('Compiler provided without envScript,'
216
+ ' assuming environment is already set up.' );
217
+ return {};
204
218
}
205
219
206
220
final compilerTool = compiler.tool;
207
221
assert (compilerTool == cl);
208
222
final vcvarsScript =
209
223
(await vcvars (compiler).defaultResolver! .resolve (logger: logger)).first;
210
- return vcvarsScript.uri;
211
- }
212
-
213
- List <String >? toolchainEnvironmentScriptArguments () {
214
- final fromInput = codeConfig.cCompiler? .envScriptArgs;
215
- if (fromInput != null ) {
216
- logger? .fine ('Using envScriptArgs from input: $fromInput ' );
217
- return fromInput;
218
- }
219
-
220
- // vcvars above already has x64 or x86 in the script name.
221
- return null ;
224
+ return await environmentFromBatchFile (
225
+ vcvarsScript.uri,
226
+ arguments: [
227
+ /* vcvarsScript already has x64 or x86 in the script name. */
228
+ ],
229
+ );
222
230
}
223
231
224
232
Future <ToolInstance > resolveLinker () async {
0 commit comments