@@ -643,28 +643,55 @@ impl BuildOutput {
643
643
Ok ( line) => line. trim ( ) ,
644
644
Err ( ..) => continue ,
645
645
} ;
646
- let mut iter = line. splitn ( 2 , ':' ) ;
646
+ let mut new_syntax = true ;
647
+ let mut iter = line. splitn ( 2 , "::" ) ;
647
648
if iter. next ( ) != Some ( "cargo" ) {
648
- // skip this line since it doesn't start with "cargo:"
649
- continue ;
649
+ // For backwards compatibility, we also accept lines that start with "cargo:".
650
+ new_syntax = false ;
651
+ iter = line. splitn ( 2 , ":" ) ;
652
+ if iter. next ( ) != Some ( "cargo" ) {
653
+ // skip this line since it doesn't start with "cargo:" or "cargo::".
654
+ continue ;
655
+ }
650
656
}
651
657
let data = match iter. next ( ) {
652
658
Some ( val) => val,
653
659
None => continue ,
654
660
} ;
655
661
656
- // getting the `key=value` part of the line
657
- let mut iter = data. splitn ( 2 , '=' ) ;
662
+ // getting the `key=value` part of the line]
663
+ let n = if new_syntax {
664
+ // cargo::metadata=key=value
665
+ 3
666
+ } else {
667
+ // cargo:key=value
668
+ 2
669
+ } ;
670
+ let mut iter = data. splitn ( n, '=' ) ;
671
+ if new_syntax {
672
+ if iter. next ( ) != Some ( "metadata" ) {
673
+ // skip this line since it doesn't start with "cargo::metadata=".
674
+ bail ! ( "invalid output in {}: `{}`\n \
675
+ Expected a line with `cargo::metadata=key=value` but it did not start with `cargo::metadata=`.\n \
676
+ See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
677
+ for more information about build script outputs.", whence, line) ;
678
+ }
679
+ }
658
680
let key = iter. next ( ) ;
659
681
let value = iter. next ( ) ;
660
682
let ( key, value) = match ( key, value) {
661
683
( Some ( a) , Some ( b) ) => ( a, b. trim_end ( ) ) ,
662
- // Line started with `cargo:` but didn't match `key=value`.
684
+ // Line started with `cargo:` or `cargo::metadata=` but didn't match `key=value`.
663
685
_ => bail ! ( "invalid output in {}: `{}`\n \
664
- Expected a line with `cargo:key=value` with an `=` character, \
665
- but none was found.\n \
686
+ Expected a line with `{}` but it did not match `key=value`.\n \
666
687
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script \
667
- for more information about build script outputs.", whence, line) ,
688
+ for more information about build script outputs.", whence, line,
689
+ if new_syntax {
690
+ "cargo::metadata=key=value"
691
+ } else {
692
+ "cargo:key=value"
693
+ }
694
+ ) ,
668
695
} ;
669
696
670
697
// This will rewrite paths if the target directory has been moved.
0 commit comments