@@ -9,12 +9,11 @@ fn main() {
9
9
10
10
if !contracts_out. exists ( ) {
11
11
match std:: process:: Command :: new ( "forge" ) . arg ( "build" ) . output ( ) {
12
- Ok ( res) if res. status . success ( ) => {
13
- println ! ( "cargo::warning=Successfully built contracts" )
14
- }
15
12
Ok ( res) => {
16
- println ! ( "cargo::error=Building contracts failed: {res:?}" ) ;
17
- return ;
13
+ if !res. status . success ( ) {
14
+ println ! ( "cargo::error=Building contracts failed: {res:?}" ) ;
15
+ return ;
16
+ }
18
17
}
19
18
Err ( e) => {
20
19
println ! ( "cargo::error=Failed to run `forge build` command: {e}" ) ;
@@ -36,11 +35,6 @@ fn main() {
36
35
return ;
37
36
}
38
37
39
- println ! (
40
- "cargo::warning=Found {} contract artifacts" ,
41
- contract_artifacts. len( )
42
- ) ;
43
-
44
38
// Generate bindings for each contract
45
39
for ( contract_name, json_path) in & contract_artifacts {
46
40
generate_contract_binding ( contract_name, json_path, bindings_dir) ;
@@ -50,15 +44,17 @@ fn main() {
50
44
generate_bindings_module ( & contract_artifacts, bindings_dir) ;
51
45
52
46
// Format the generated bindings
53
- match std:: process:: Command :: new ( "just" ) . arg ( "fmt" ) . output ( ) {
54
- Ok ( result ) if result . status . success ( ) => {
55
- println ! ( "cargo::warning=Successfully formatted generated bindings" ) ;
56
- }
47
+ match std:: process:: Command :: new ( "just" )
48
+ . args ( [ "fmt" , "-p" , env ! ( "CARGO_PKG_NAME" ) ] )
49
+ . output ( )
50
+ {
57
51
Ok ( result) => {
58
- println ! (
59
- "cargo::error=Format command failed with exit code: {:?}" ,
60
- result. status. code( )
61
- ) ;
52
+ if !result. status . success ( ) {
53
+ println ! (
54
+ "cargo::error=Format command failed with exit code: {:?}" ,
55
+ result. status. code( )
56
+ ) ;
57
+ }
62
58
}
63
59
Err ( e) => {
64
60
println ! ( "cargo::error=Failed to run format command: {e}" ) ;
@@ -117,8 +113,6 @@ fn walk_directory(dir: &Path, callback: &mut dyn FnMut(&Path)) {
117
113
}
118
114
119
115
fn generate_contract_binding ( contract_name : & str , json_path : & Path , bindings_dir : & Path ) {
120
- println ! ( "cargo::warning=Generating bindings for {contract_name} from JSON artifact" ) ;
121
-
122
116
// Create the relative path from the binding file to the JSON artifact
123
117
let json_path_str = json_path. display ( ) . to_string ( ) . replace ( '\\' , "/" ) ;
124
118
@@ -129,8 +123,6 @@ fn generate_contract_binding(contract_name: &str, json_path: &Path, bindings_dir
129
123
let output_path = bindings_dir. join ( format ! ( "{}.rs" , contract_name. to_lowercase( ) ) ) ;
130
124
fs:: write ( & output_path, bindings)
131
125
. unwrap_or_else ( |_| panic ! ( "Failed to write {contract_name} bindings" ) ) ;
132
-
133
- println ! ( "cargo::warning={contract_name} bindings written to {output_path:?}" ) ;
134
126
}
135
127
136
128
fn generate_bindings_module ( contract_artifacts : & [ ( String , PathBuf ) ] , bindings_dir : & Path ) {
@@ -151,6 +143,4 @@ fn generate_bindings_module(contract_artifacts: &[(String, PathBuf)], bindings_d
151
143
152
144
let bindings_module_path = bindings_dir. join ( "mod.rs" ) ;
153
145
fs:: write ( & bindings_module_path, module_content) . expect ( "Failed to write bindings module" ) ;
154
-
155
- println ! ( "cargo::warning=Bindings module written to {bindings_module_path:?}" ) ;
156
146
}
0 commit comments