@@ -11,13 +11,19 @@ const GHC_VARIANT: &str = "aarch64-osx";
1111
1212#[ cfg( not( feature = "static" ) ) ]
1313fn command_output ( cmd : & mut Command ) -> String {
14- str:: from_utf8 ( & cmd. output ( ) . unwrap ( ) . stdout ) . unwrap ( ) . trim_end ( ) . to_string ( )
14+ str:: from_utf8 ( & cmd. output ( ) . unwrap ( ) . stdout )
15+ . unwrap ( )
16+ . trim_end ( )
17+ . to_string ( )
1518}
1619
1720fn main ( ) -> std:: io:: Result < ( ) > {
1821 let cargo_dir = env ! ( "CARGO_MANIFEST_DIR" ) ;
1922 // Compile the flatbuffers schema
20- println ! ( "cargo:rerun-if-changed={}/src/network/serialization/schema.fbs" , cargo_dir) ;
23+ println ! (
24+ "cargo:rerun-if-changed={}/src/network/serialization/schema.fbs" ,
25+ cargo_dir
26+ ) ;
2127 flatc_rust:: run ( flatc_rust:: Args {
2228 inputs : & [ Path :: new ( "src/network/serialization/schema.fbs" ) ] ,
2329 out_dir : Path :: new ( "target/" ) ,
@@ -45,7 +51,10 @@ fn main() -> std::io::Result<()> {
4551 let stack_install_root = Path :: new ( & stack_install_root_command) ;
4652 let dll_location = stack_install_root. join ( "lib" ) ;
4753
48- println ! ( "cargo:rustc-link-search=native={}" , dll_location. to_string_lossy( ) ) ;
54+ println ! (
55+ "cargo:rustc-link-search=native={}" ,
56+ dll_location. to_string_lossy( )
57+ ) ;
4958 println ! ( "cargo:rustc-link-lib=dylib=concordium-consensus" ) ;
5059 }
5160 #[ cfg( not( windows) ) ]
@@ -76,7 +85,10 @@ fn main() -> std::io::Result<()> {
7685 let stack_install_root = Path :: new ( & stack_install_root_command) ;
7786 let stack_install_lib = stack_install_root. join ( "lib" ) ;
7887
79- println ! ( "cargo:rustc-link-search={}" , stack_install_lib. to_string_lossy( ) ) ;
88+ println ! (
89+ "cargo:rustc-link-search={}" ,
90+ stack_install_lib. to_string_lossy( )
91+ ) ;
8092 println ! ( "cargo:rustc-link-lib=dylib=concordium-consensus" ) ;
8193
8294 // Find the first subdirectory of <stack_install_lib> whose filename has
@@ -91,8 +103,9 @@ fn main() -> std::io::Result<()> {
91103 // `.DYLIB_EXTENSION` to the linked libraries list.
92104 for dir_entry in dir {
93105 let path = dir_entry?. path ( ) ;
94- if let Some ( true ) =
95- path. extension ( ) . map ( |ext| ext. to_string_lossy ( ) == DYLIB_EXTENSION )
106+ if let Some ( true ) = path
107+ . extension ( )
108+ . map ( |ext| ext. to_string_lossy ( ) == DYLIB_EXTENSION )
96109 // FIXME: On a mac we should ignore case, but not on linux
97110 {
98111 let name = path
@@ -139,7 +152,10 @@ fn build_grpc2(proto_root_input: &str) -> std::io::Result<()> {
139152 {
140153 let types = format ! ( "{}/v2/concordium/types.proto" , proto_root_input) ;
141154 println ! ( "cargo:rerun-if-changed={}" , types) ;
142- let plts = format ! ( "{}/v2/concordium/protocol-level-tokens.proto" , proto_root_input) ;
155+ let plts = format ! (
156+ "{}/v2/concordium/protocol-level-tokens.proto" ,
157+ proto_root_input
158+ ) ;
143159 println ! ( "cargo:rerun-if-changed={}" , plts) ;
144160 let kernel = format ! ( "{}/v2/concordium/kernel.proto" , proto_root_input) ;
145161 println ! ( "cargo:rerun-if-changed={}" , kernel) ;
@@ -763,7 +779,9 @@ fn build_grpc2(proto_root_input: &str) -> std::io::Result<()> {
763779 // Due to the slightly hacky nature of the RawCodec (i.e., it does not support
764780 // deserialization) we cannot build the client. But we also don't need it in the
765781 // node.
766- tonic_build:: manual:: Builder :: new ( ) . build_client ( false ) . compile ( & [ query_service] ) ;
782+ tonic_build:: manual:: Builder :: new ( )
783+ . build_client ( false )
784+ . compile ( & [ query_service] ) ;
767785
768786 {
769787 let health = format ! ( "{}/v2/concordium/health.proto" , proto_root_input) ;
@@ -819,7 +837,10 @@ fn link_ghc_libs() -> std::io::Result<std::path::PathBuf> {
819837 ] ) )
820838 } ) ;
821839 let rts_dir = ghc_variant ( Path :: new ( & ghc_lib_dir) ) ?;
822- println ! ( "cargo:rustc-link-search=native={}" , rts_dir. to_string_lossy( ) ) ;
840+ println ! (
841+ "cargo:rustc-link-search=native={}" ,
842+ rts_dir. to_string_lossy( )
843+ ) ;
823844 for item in std:: fs:: read_dir ( & rts_dir) ?. filter_map ( Result :: ok) {
824845 let path = item. path ( ) ;
825846 let file_stem = path. file_stem ( ) . unwrap ( ) . to_string_lossy ( ) ;
@@ -842,31 +863,36 @@ fn link_static_libs() -> std::io::Result<()> {
842863 #[ cfg( feature = "profiling" ) ]
843864 let path = format ! ( "{}/deps/static-libs/linux/profiling" , out_dir) ;
844865
845- [ "concordium" , "dependencies" , "ghc" ] . iter ( ) . for_each ( |subdir| {
846- println ! ( "cargo:rustc-link-search=native={}/{}" , path, subdir) ;
847- let walker = walkdir:: WalkDir :: new ( Path :: new ( & format ! ( "{}/{}" , path, subdir) ) )
848- . into_iter ( )
849- . filter_map ( Result :: ok) ;
850- for item in walker {
851- match item. file_name ( ) . to_str ( ) {
852- Some ( lib_file) => {
853- // We link with all the libraries, but exclude the non-threaded Haskell RTS.
854- if lib_file. starts_with ( "lib" )
855- && lib_file. ends_with ( ".a" )
856- && ( !lib_file. starts_with ( "libHSrts" ) || lib_file. contains ( "_thr" ) )
857- {
858- println ! (
859- "cargo:rustc-link-lib=static={}" ,
860- & lib_file[ 3 ..lib_file. len( ) - 2 ]
861- ) ;
866+ [ "concordium" , "dependencies" , "ghc" ]
867+ . iter ( )
868+ . for_each ( |subdir| {
869+ println ! ( "cargo:rustc-link-search=native={}/{}" , path, subdir) ;
870+ let walker = walkdir:: WalkDir :: new ( Path :: new ( & format ! ( "{}/{}" , path, subdir) ) )
871+ . into_iter ( )
872+ . filter_map ( Result :: ok) ;
873+ for item in walker {
874+ match item. file_name ( ) . to_str ( ) {
875+ Some ( lib_file) => {
876+ // We link with all the libraries, but exclude the non-threaded Haskell RTS.
877+ if lib_file. starts_with ( "lib" )
878+ && lib_file. ends_with ( ".a" )
879+ && ( !lib_file. starts_with ( "libHSrts" ) || lib_file. contains ( "_thr" ) )
880+ {
881+ println ! (
882+ "cargo:rustc-link-lib=static={}" ,
883+ & lib_file[ 3 ..lib_file. len( ) - 2 ]
884+ ) ;
885+ }
862886 }
887+ _ => panic ! ( "Unable to link ghc libs" ) ,
863888 }
864- _ => panic ! ( "Unable to link ghc libs" ) ,
865889 }
866- }
867- } ) ;
890+ } ) ;
868891
869- println ! ( "cargo:rustc-link-search=native={}/deps/static-libs/linux/rust" , out_dir) ;
892+ println ! (
893+ "cargo:rustc-link-search=native={}/deps/static-libs/linux/rust" ,
894+ out_dir
895+ ) ;
870896 println ! ( "cargo:rustc-link-lib=static=Rcrypto" ) ;
871897 println ! ( "cargo:rustc-link-lib=static=concordium_smart_contract_engine" ) ;
872898
@@ -895,7 +921,10 @@ fn ghc_variant(stack_install_lib: &Path) -> std::io::Result<std::path::PathBuf>
895921 match ghc_variant_dir {
896922 Some ( path) => Ok ( path) ,
897923 None => {
898- eprintln ! ( "No subdirectory in {:?} with prefix {}" , stack_install_lib, GHC_VARIANT ) ;
924+ eprintln ! (
925+ "No subdirectory in {:?} with prefix {}" ,
926+ stack_install_lib, GHC_VARIANT
927+ ) ;
899928 Err ( std:: io:: Error :: new (
900929 std:: io:: ErrorKind :: NotFound ,
901930 "GHC_VARIANT directory not found" ,
0 commit comments