@@ -3304,3 +3304,57 @@ fn init_and_add_inner_target(p: ProjectBuilder) -> ProjectBuilder {
3304
3304
. file ( "derp/target/foo.txt" , "" )
3305
3305
. file ( "derp/not_target/foo.txt" , "" )
3306
3306
}
3307
+
3308
+ #[ cargo_test]
3309
+ fn custom_build_warning ( ) {
3310
+ let p = project ( )
3311
+ . file (
3312
+ "Cargo.toml" ,
3313
+ r#"
3314
+ [package]
3315
+ name = "foo"
3316
+ version = "0.0.1"
3317
+ license = "MIT"
3318
+ description = "foo"
3319
+ authors = []
3320
+ build = "../t_custom_build/custom_build.rs"
3321
+ "# ,
3322
+ )
3323
+ . file ( "src/main.rs" , "fn main() {}" )
3324
+ . build ( ) ;
3325
+ p. cargo ( "package -l" )
3326
+ . with_stderr ( format ! (
3327
+ "\
3328
+ warning: manifest has no documentation, homepage or repository.
3329
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
3330
+ warning: build `{}/../t_custom_build/custom_build.rs` does not appear to exist.
3331
+ Please update the build setting in the manifest at `{}/Cargo.toml`
3332
+ This may become a hard error in the future.
3333
+ " ,
3334
+ p. root( ) . display( ) ,
3335
+ p. root( ) . display( )
3336
+ ) )
3337
+ . run ( ) ;
3338
+
3339
+ // crate custom_build.rs outside the package root
3340
+ let custom_build_root = p. root ( ) . parent ( ) . unwrap ( ) . join ( "t_custom_build" ) ;
3341
+ _ = fs:: create_dir ( & custom_build_root) . unwrap ( ) ;
3342
+ _ = fs:: write ( & custom_build_root. join ( "custom_build.rs" ) , "fn main() {}" ) ;
3343
+
3344
+ p. cargo ( "package -l" )
3345
+ . with_stderr ( format ! (
3346
+ "\
3347
+ warning: manifest has no documentation, homepage or repository.
3348
+ See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
3349
+ warning: the source file of \" custom-build\" target `build-script-custom_build` doesn't appear to be a path inside of the package.
3350
+ It is at {}/t_custom_build/custom_build.rs, whereas the root the package is {}.
3351
+ This may cause issue during packaging, as modules resolution and resources included via macros are often relative to the path of source files.
3352
+ Please update the `build` setting in the manifest at `{}/Cargo.toml` and point to a path inside the root of the package.
3353
+ " ,
3354
+ p. root( ) . parent( ) . unwrap( ) . display( ) ,
3355
+ p. root( ) . display( ) ,
3356
+ p. root( ) . display( )
3357
+ ) )
3358
+ . run ( ) ;
3359
+ _ = fs:: remove_dir_all ( & custom_build_root) . unwrap ( ) ;
3360
+ }
0 commit comments