@@ -719,6 +719,7 @@ impl BuildOutput {
719
719
whence : & str ,
720
720
line : & str ,
721
721
data : & ' a str ,
722
+ old_syntax : bool ,
722
723
) -> CargoResult < ( & ' a str , & ' a str ) > {
723
724
let mut iter = data. splitn ( 2 , "=" ) ;
724
725
let key = iter. next ( ) ;
@@ -727,9 +728,10 @@ impl BuildOutput {
727
728
( Some ( a) , Some ( b) ) => Ok ( ( a, b. trim_end ( ) ) ) ,
728
729
_ => bail ! (
729
730
"invalid output in {whence}: `{line}`\n \
730
- Expected a line with `cargo:: KEY=VALUE` with an `=` character, \
731
+ Expected a line with `{syntax} KEY=VALUE` with an `=` character, \
731
732
but none was found.\n \
732
733
{DOCS_LINK_SUGGESTION}",
734
+ syntax = if old_syntax { "cargo:" } else { "cargo::" } ,
733
735
) ,
734
736
}
735
737
}
@@ -738,6 +740,7 @@ impl BuildOutput {
738
740
whence : & str ,
739
741
line : & str ,
740
742
data : & ' a str ,
743
+ old_syntax : bool ,
741
744
) -> CargoResult < ( & ' a str , & ' a str ) > {
742
745
let mut iter = data. splitn ( 2 , "=" ) ;
743
746
let key = iter. next ( ) ;
@@ -746,9 +749,14 @@ impl BuildOutput {
746
749
( Some ( a) , Some ( b) ) => Ok ( ( a, b. trim_end ( ) ) ) ,
747
750
_ => bail ! (
748
751
"invalid output in {whence}: `{line}`\n \
749
- Expected a line with `cargo::metadata= KEY=VALUE` with an `=` character, \
752
+ Expected a line with `{syntax} KEY=VALUE` with an `=` character, \
750
753
but none was found.\n \
751
754
{DOCS_LINK_SUGGESTION}",
755
+ syntax = if old_syntax {
756
+ "cargo:"
757
+ } else {
758
+ "cargo::metadata="
759
+ } ,
752
760
) ,
753
761
}
754
762
}
@@ -758,16 +766,18 @@ impl BuildOutput {
758
766
Ok ( line) => line. trim ( ) ,
759
767
Err ( ..) => continue ,
760
768
} ;
769
+ let mut old_syntax = false ;
761
770
let ( key, value) = if let Some ( data) = line. strip_prefix ( "cargo::" ) {
762
771
// For instance, `cargo::rustc-flags=foo` or `cargo::metadata=foo=bar`.
763
- parse_directive ( whence. as_str ( ) , line, data) ?
772
+ parse_directive ( whence. as_str ( ) , line, data, old_syntax ) ?
764
773
} else if let Some ( data) = line. strip_prefix ( "cargo:" ) {
774
+ old_syntax = true ;
765
775
// For instance, `cargo:rustc-flags=foo`.
766
776
if RESERVED_PREFIXES
767
777
. iter ( )
768
778
. any ( |prefix| data. starts_with ( prefix) )
769
779
{
770
- parse_directive ( whence. as_str ( ) , line, data) ?
780
+ parse_directive ( whence. as_str ( ) , line, data, old_syntax ) ?
771
781
} else {
772
782
// For instance, `cargo:foo=bar`.
773
783
( "metadata" , data)
@@ -782,12 +792,14 @@ impl BuildOutput {
782
792
script_out_dir. to_str ( ) . unwrap ( ) ,
783
793
) ;
784
794
795
+ let syntax_prefix = if old_syntax { "cargo:" } else { "cargo::" } ;
785
796
macro_rules! check_and_add_target {
786
797
( $target_kind: expr, $is_target_kind: expr, $link_type: expr) => {
787
798
if !targets. iter( ) . any( |target| $is_target_kind( target) ) {
788
799
bail!(
789
- "invalid instruction `cargo:: {}` from {}\n \
800
+ "invalid instruction `{} {}` from {}\n \
790
801
The package {} does not have a {} target.",
802
+ syntax_prefix,
791
803
key,
792
804
whence,
793
805
pkg_descr,
@@ -810,14 +822,14 @@ impl BuildOutput {
810
822
"rustc-link-arg-cdylib" | "rustc-cdylib-link-arg" => {
811
823
if !targets. iter ( ) . any ( |target| target. is_cdylib ( ) ) {
812
824
warnings. push ( format ! (
813
- "cargo:: {} was specified in the build script of {}, \
825
+ "{} {} was specified in the build script of {}, \
814
826
but that package does not contain a cdylib target\n \
815
827
\n \
816
828
Allowing this was an unintended change in the 1.50 \
817
829
release, and may become an error in the future. \
818
830
For more information, see \
819
831
<https://github.com/rust-lang/cargo/issues/9562>.",
820
- key, pkg_descr
832
+ syntax_prefix , key, pkg_descr
821
833
) ) ;
822
834
}
823
835
linker_args. push ( ( LinkArgTarget :: Cdylib , value) )
@@ -828,11 +840,13 @@ impl BuildOutput {
828
840
"rustc-link-arg-bin" => {
829
841
let ( bin_name, arg) = value. split_once ( '=' ) . ok_or_else ( || {
830
842
anyhow:: format_err!(
831
- "invalid instruction `cargo::{}={}` from {}\n \
832
- The instruction should have the form cargo::{}=BIN=ARG",
843
+ "invalid instruction `{}{}={}` from {}\n \
844
+ The instruction should have the form {}{}=BIN=ARG",
845
+ syntax_prefix,
833
846
key,
834
847
value,
835
848
whence,
849
+ syntax_prefix,
836
850
key
837
851
)
838
852
} ) ?;
@@ -841,8 +855,9 @@ impl BuildOutput {
841
855
. any ( |target| target. is_bin ( ) && target. name ( ) == bin_name)
842
856
{
843
857
bail ! (
844
- "invalid instruction `cargo:: {}` from {}\n \
858
+ "invalid instruction `{} {}` from {}\n \
845
859
The package {} does not have a bin target with the name `{}`.",
860
+ syntax_prefix,
846
861
key,
847
862
whence,
848
863
pkg_descr,
@@ -871,7 +886,10 @@ impl BuildOutput {
871
886
if extra_check_cfg {
872
887
check_cfgs. push ( value. to_string ( ) ) ;
873
888
} else {
874
- warnings. push ( format ! ( "cargo::{} requires -Zcheck-cfg flag" , key) ) ;
889
+ warnings. push ( format ! (
890
+ "{}{} requires -Zcheck-cfg flag" ,
891
+ syntax_prefix, key
892
+ ) ) ;
875
893
}
876
894
}
877
895
"rustc-env" => {
@@ -929,7 +947,7 @@ impl BuildOutput {
929
947
"rerun-if-changed" => rerun_if_changed. push ( PathBuf :: from ( value) ) ,
930
948
"rerun-if-env-changed" => rerun_if_env_changed. push ( value. to_string ( ) ) ,
931
949
"metadata" => {
932
- let ( key, value) = parse_metadata ( whence. as_str ( ) , line, & value) ?;
950
+ let ( key, value) = parse_metadata ( whence. as_str ( ) , line, & value, old_syntax ) ?;
933
951
metadata. push ( ( key. to_owned ( ) , value. to_owned ( ) ) ) ;
934
952
}
935
953
_ => bail ! (
0 commit comments