@@ -16,8 +16,14 @@ enum Commands {
16
16
Check ,
17
17
Clippy ,
18
18
Fmt ,
19
- Build { platform : String } ,
20
- Test { platform : Option < String > } ,
19
+ Build {
20
+ #[ arg( short, long) ]
21
+ target : String ,
22
+ } ,
23
+ Test {
24
+ #[ arg( short, long) ]
25
+ target : Option < String > ,
26
+ } ,
21
27
PrePush ,
22
28
}
23
29
@@ -54,80 +60,22 @@ fn fmt() {
54
60
run ( "cargo" , & [ "fmt" , "--" , "--check" ] ) ;
55
61
}
56
62
57
- fn build ( platform : & str ) {
63
+ fn build ( target : & str ) {
58
64
env:: set_var ( "RUSTFLAGS" , "-C target-feature=+crt-static" ) ;
59
- if platform == "windows" {
60
- run ( "rustup" , & [ "target" , "add" , "x86_64-pc-windows-msvc" ] ) ;
61
- run (
62
- "cargo" ,
63
- & [
64
- "build" ,
65
- "-p" ,
66
- "kill_tree_cli" ,
67
- "-r" ,
68
- "--target" ,
69
- "x86_64-pc-windows-msvc" ,
70
- ] ,
71
- ) ;
72
- } else if platform == "linux" {
73
- run ( "rustup" , & [ "target" , "add" , "x86_64-unknown-linux-musl" ] ) ;
74
- run (
75
- "cargo" ,
76
- & [
77
- "build" ,
78
- "-p" ,
79
- "kill_tree_cli" ,
80
- "-r" ,
81
- "--target" ,
82
- "x86_64-unknown-linux-musl" ,
83
- ] ,
84
- ) ;
85
- } else if platform == "macos" {
86
- run ( "rustup" , & [ "target" , "add" , "aarch64-apple-darwin" ] ) ;
87
- run ( "rustup" , & [ "target" , "add" , "x86_64-apple-darwin" ] ) ;
88
- run (
89
- "cargo" ,
90
- & [
91
- "build" ,
92
- "-p" ,
93
- "kill_tree_cli" ,
94
- "-r" ,
95
- "--target" ,
96
- "aarch64-apple-darwin" ,
97
- ] ,
98
- ) ;
99
- run (
100
- "cargo" ,
101
- & [
102
- "build" ,
103
- "-p" ,
104
- "kill_tree_cli" ,
105
- "-r" ,
106
- "--target" ,
107
- "x86_64-apple-darwin" ,
108
- ] ,
109
- ) ;
110
- } else {
111
- panic ! ( "Unsupported platform: {platform}" ) ;
112
- }
65
+ run ( "rustup" , & [ "target" , "add" , target] ) ;
66
+ run (
67
+ "cargo" ,
68
+ & [ "build" , "-p" , "kill_tree_cli" , "-r" , "--target" , target] ,
69
+ ) ;
113
70
}
114
71
115
- fn test ( platform : Option < String > ) {
116
- let Some ( platform ) = platform else {
72
+ fn test ( target : Option < String > ) {
73
+ let Some ( target ) = target else {
117
74
run ( "cargo" , & [ "test" , "--workspace" ] ) ;
118
75
return ;
119
76
} ;
120
77
121
- if platform == "windows" {
122
- run ( "cargo" , & [ "test" , "--target" , "x86_64-pc-windows-msvc" ] ) ;
123
- } else if platform == "linux" {
124
- run ( "cargo" , & [ "test" , "--target" , "x86_64-unknown-linux-musl" ] ) ;
125
- } else if platform == "macos" {
126
- run ( "cargo" , & [ "test" , "--target" , "aarch64-apple-darwin" ] ) ;
127
- run ( "cargo" , & [ "test" , "--target" , "x86_64-apple-darwin" ] ) ;
128
- } else {
129
- panic ! ( "Unsupported platform: {platform}" ) ;
130
- }
78
+ run ( "cargo" , & [ "test" , "--target" , target. as_str ( ) ] ) ;
131
79
}
132
80
133
81
fn pre_push ( ) {
@@ -143,8 +91,8 @@ fn main() {
143
91
Some ( Commands :: Check ) => check ( ) ,
144
92
Some ( Commands :: Clippy ) => clippy ( ) ,
145
93
Some ( Commands :: Fmt ) => fmt ( ) ,
146
- Some ( Commands :: Build { platform } ) => build ( & platform ) ,
147
- Some ( Commands :: Test { platform } ) => test ( platform ) ,
94
+ Some ( Commands :: Build { target } ) => build ( & target ) ,
95
+ Some ( Commands :: Test { target } ) => test ( target ) ,
148
96
Some ( Commands :: PrePush ) => pre_push ( ) ,
149
97
None => {
150
98
panic ! ( "No command" ) ;
0 commit comments