@@ -16,8 +16,14 @@ enum Commands {
1616 Check ,
1717 Clippy ,
1818 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+ } ,
2127 PrePush ,
2228}
2329
@@ -54,80 +60,22 @@ fn fmt() {
5460 run ( "cargo" , & [ "fmt" , "--" , "--check" ] ) ;
5561}
5662
57- fn build ( platform : & str ) {
63+ fn build ( target : & str ) {
5864 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+ ) ;
11370}
11471
115- fn test ( platform : Option < String > ) {
116- let Some ( platform ) = platform else {
72+ fn test ( target : Option < String > ) {
73+ let Some ( target ) = target else {
11774 run ( "cargo" , & [ "test" , "--workspace" ] ) ;
11875 return ;
11976 } ;
12077
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 ( ) ] ) ;
13179}
13280
13381fn pre_push ( ) {
@@ -143,8 +91,8 @@ fn main() {
14391 Some ( Commands :: Check ) => check ( ) ,
14492 Some ( Commands :: Clippy ) => clippy ( ) ,
14593 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 ) ,
14896 Some ( Commands :: PrePush ) => pre_push ( ) ,
14997 None => {
15098 panic ! ( "No command" ) ;
0 commit comments