@@ -63,7 +63,9 @@ fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
6363 Ok ( ( ) )
6464}
6565
66- #[ cfg( target_os = "linux" ) ]
66+ /// This ensures that in sandboxed environments, such as Nix, permissions from other sources don't
67+ /// propagate into OUT_DIR. If not present, when trying to rewrite a file, a `Permission denied`
68+ /// error will occur.
6769fn copy_with_cp ( src : impl AsRef < Path > , dst : impl AsRef < Path > ) -> io:: Result < ( ) > {
6870 let status = Command :: new ( "cp" )
6971 . arg ( "--no-preserve=mode,ownership" )
@@ -82,24 +84,6 @@ fn copy_with_cp(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> io::Result<()>
8284 }
8385}
8486
85- #[ cfg( target_os = "macos" ) ]
86- fn copy_with_cp ( src : impl AsRef < Path > , dst : impl AsRef < Path > ) -> io:: Result < ( ) > {
87- let status = Command :: new ( "cp" )
88- . arg ( "-R" )
89- . arg ( src. as_ref ( ) . to_str ( ) . unwrap ( ) )
90- . arg ( dst. as_ref ( ) . to_str ( ) . unwrap ( ) )
91- . status ( ) ?;
92-
93- if !status. success ( ) {
94- Err ( io:: Error :: new (
95- io:: ErrorKind :: Other ,
96- "Failed to copy using cp" ,
97- ) )
98- } else {
99- Ok ( ( ) )
100- }
101- }
102-
10387fn make_amalgamation ( ) {
10488 let flags = [ "-DSQLITE_ENABLE_COLUMN_METADATA=1" ] ;
10589
@@ -195,7 +179,7 @@ pub fn build_bundled(out_dir: &str, out_path: &Path) {
195179 }
196180
197181 let dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
198- std :: fs :: copy ( format ! ( "{dir}/{bindgen_rs_path}" ) , out_path) . unwrap ( ) ;
182+ copy_with_cp ( format ! ( "{dir}/{bindgen_rs_path}" ) , out_path) . unwrap ( ) ;
199183
200184 let mut cfg = cc:: Build :: new ( ) ;
201185 cfg. flag ( "-std=c11" )
@@ -494,7 +478,12 @@ fn build_multiple_ciphers(target: &str, out_path: &Path) {
494478
495479 cmake_opts. push ( & cmake_toolchain_opt) ;
496480 writeln ! ( toolchain_file, "set(CMAKE_SYSTEM_NAME \" {}\" )" , system_name) . unwrap ( ) ;
497- writeln ! ( toolchain_file, "set(CMAKE_SYSTEM_PROCESSOR \" {}\" )" , system_processor) . unwrap ( ) ;
481+ writeln ! (
482+ toolchain_file,
483+ "set(CMAKE_SYSTEM_PROCESSOR \" {}\" )" ,
484+ system_processor
485+ )
486+ . unwrap ( ) ;
498487 writeln ! ( toolchain_file, "set(CMAKE_C_COMPILER {})" , cc) . unwrap ( ) ;
499488 }
500489
0 commit comments