@@ -24,10 +24,16 @@ fn main() -> Result<()> {
24
24
. package
25
25
. context ( "Cannot load metadata from Cargo.toml" ) ?;
26
26
let assets;
27
+ let mut args = std:: env:: args ( ) . skip ( 2 ) ;
28
+ let mut target = args. find ( |f| f. contains ( "--target=" ) ) ;
29
+ if target. is_some ( ) {
30
+ target = Some ( format ! (
31
+ "{}/release" ,
32
+ target. unwrap( ) . split_at( 9 ) . 1 . to_string( )
33
+ ) ) ;
34
+ }
27
35
let link_deps;
28
36
29
- let multibins = meta. bin ;
30
-
31
37
if let Some ( meta) = pkg. metadata . as_ref ( ) {
32
38
match meta {
33
39
Value :: Table ( t) => match t. get ( "appimage" ) {
@@ -65,9 +71,10 @@ fn main() -> Result<()> {
65
71
link_deps = false ;
66
72
}
67
73
68
- for currentbin in multibins {
74
+ for currentbin in meta . bin {
69
75
let name = currentbin. name . unwrap_or ( pkg. name . clone ( ) ) ;
70
- let appdirpath = std:: path:: Path :: new ( "target/" ) . join ( & name) ;
76
+ let appdirpath = std:: path:: Path :: new ( "target/" ) . join ( name. clone ( ) + ".AppDir" ) ;
77
+ let target = target. clone ( ) . unwrap_or ( "release" . to_string ( ) ) ;
71
78
fs_extra:: dir:: create_all ( appdirpath. join ( "usr" ) , true )
72
79
. with_context ( || format ! ( "Error creating {}" , appdirpath. join( "usr" ) . display( ) ) ) ?;
73
80
@@ -88,12 +95,12 @@ fn main() -> Result<()> {
88
95
. context ( "Make sure you have awk on your system" ) ?
89
96
. write_all (
90
97
& std:: process:: Command :: new ( "ldd" )
91
- . arg ( format ! ( "target/release /{}" , name) )
98
+ . arg ( format ! ( "target/{} /{}" , & target , & name) )
92
99
. output ( )
93
100
. with_context ( || {
94
101
format ! (
95
102
"Failed to run ldd on {}" ,
96
- format!( "target/release /{}" , name)
103
+ format!( "target/{} /{}" , & target , & name)
97
104
)
98
105
} ) ?
99
106
. stdout ,
@@ -160,10 +167,10 @@ fn main() -> Result<()> {
160
167
}
161
168
162
169
std:: fs:: copy (
163
- format ! ( "target/release /{}" , name) ,
170
+ format ! ( "target/{} /{}" , & target , & name) ,
164
171
appdirpath. join ( "usr/bin/bin" ) ,
165
172
)
166
- . context ( "Cannot find binary file" ) ?;
173
+ . with_context ( || format ! ( "Cannot find binary file at target/{}/{}" , & target , & name ) ) ?;
167
174
std:: fs:: copy ( "./icon.png" , appdirpath. join ( "icon.png" ) ) . context ( "Cannot find icon.png" ) ?;
168
175
fs_extra:: copy_items (
169
176
& assets,
@@ -179,15 +186,15 @@ fn main() -> Result<()> {
179
186
std:: fs:: write (
180
187
appdirpath. join ( "cargo-appimage.desktop" ) ,
181
188
format ! (
182
- "[Desktop Entry]\n Name={}\n Exec=bin\n Icon=icon\n Type=Application\n Categories=Utility;" , name
183
- ) ,
184
- )
185
- . with_context ( || {
186
- format ! (
187
- "Error writing desktop file {}" ,
188
- appdirpath. join( "cargo-appimage.desktop" ) . display( )
189
- )
190
- } ) ?;
189
+ "[Desktop Entry]\n Name={}\n Exec=bin\n Icon=icon\n Type=Application\n Categories=Utility;" , name
190
+ ) ,
191
+ )
192
+ . with_context ( || {
193
+ format ! (
194
+ "Error writing desktop file {}" ,
195
+ appdirpath. join( "cargo-appimage.desktop" ) . display( )
196
+ )
197
+ } ) ?;
191
198
std:: fs:: copy (
192
199
std:: path:: PathBuf :: from ( std:: env:: var ( "HOME" ) ?)
193
200
. join ( ".cargo/bin/cargo-appimage-runner" ) ,
0 commit comments