Commit 00986fe 1 parent 978351c commit 00986fe Copy full SHA for 00986fe
File tree 1 file changed +34
-2
lines changed
1 file changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -443,10 +443,42 @@ fn build_tree_sitter_library(
443
443
. arg ( header_path)
444
444
. arg ( "/Od" )
445
445
. arg ( "/utf-8" )
446
- . arg ( "/std:c++14" )
447
446
. arg ( "/std:c11" ) ;
448
447
if let Some ( scanner_path) = scanner_path. as_ref ( ) {
449
- command. arg ( scanner_path) ;
448
+ if scanner_path. extension ( ) == Some ( "c" . as_ref ( ) ) {
449
+ command. arg ( scanner_path) ;
450
+ } else {
451
+ let mut cpp_command = Command :: new ( compiler. path ( ) ) ;
452
+ cpp_command. current_dir ( src_path) ;
453
+ for ( key, value) in compiler. env ( ) {
454
+ cpp_command. env ( key, value) ;
455
+ }
456
+ cpp_command. args ( compiler. args ( ) ) ;
457
+ let object_file =
458
+ library_path. with_file_name ( format ! ( "{}_scanner.o" , & grammar. grammar_id) ) ;
459
+ cpp_command
460
+ . args ( [ "/nologo" , "/LD" , "/I" ] )
461
+ . arg ( header_path)
462
+ . arg ( "/Od" )
463
+ . arg ( "/utf-8" )
464
+ . arg ( "/std:c++14" )
465
+ . arg ( "/o" )
466
+ . arg ( & object_file)
467
+ . arg ( "/c" )
468
+ . arg ( scanner_path) ;
469
+ let output = cpp_command
470
+ . output ( )
471
+ . context ( "Failed to execute C++ compiler" ) ?;
472
+ if !output. status . success ( ) {
473
+ return Err ( anyhow ! (
474
+ "Parser compilation failed.\n Stdout: {}\n Stderr: {}" ,
475
+ String :: from_utf8_lossy( & output. stdout) ,
476
+ String :: from_utf8_lossy( & output. stderr)
477
+ ) ) ;
478
+ }
479
+ command. arg ( & object_file) ;
480
+ _path_guard = TempPath :: from_path ( object_file) ;
481
+ }
450
482
}
451
483
452
484
command
You can’t perform that action at this time.
0 commit comments