Skip to content

Commit d71b2e8

Browse files
Respect --target flag
1 parent d0709c1 commit d71b2e8

File tree

3 files changed

+35
-28
lines changed

3 files changed

+35
-28
lines changed

Cargo.lock

+10-10
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cargo-appimage"
3-
version = "1.3.0"
3+
version = "1.3.1"
44
authors = ["Isaac Mills <rooster0055@protonmail.com>", "Jim Hessin <jhessin@gmail.com>"]
55
edition = "2018"
66
license = "GPL-3.0"

src/main.rs

+24-17
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,16 @@ fn main() -> Result<()> {
2424
.package
2525
.context("Cannot load metadata from Cargo.toml")?;
2626
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+
}
2735
let link_deps;
2836

29-
let multibins = meta.bin;
30-
3137
if let Some(meta) = pkg.metadata.as_ref() {
3238
match meta {
3339
Value::Table(t) => match t.get("appimage") {
@@ -65,9 +71,10 @@ fn main() -> Result<()> {
6571
link_deps = false;
6672
}
6773

68-
for currentbin in multibins {
74+
for currentbin in meta.bin {
6975
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());
7178
fs_extra::dir::create_all(appdirpath.join("usr"), true)
7279
.with_context(|| format!("Error creating {}", appdirpath.join("usr").display()))?;
7380

@@ -88,12 +95,12 @@ fn main() -> Result<()> {
8895
.context("Make sure you have awk on your system")?
8996
.write_all(
9097
&std::process::Command::new("ldd")
91-
.arg(format!("target/release/{}", name))
98+
.arg(format!("target/{}/{}", &target, &name))
9299
.output()
93100
.with_context(|| {
94101
format!(
95102
"Failed to run ldd on {}",
96-
format!("target/release/{}", name)
103+
format!("target/{}/{}", &target, &name)
97104
)
98105
})?
99106
.stdout,
@@ -160,10 +167,10 @@ fn main() -> Result<()> {
160167
}
161168

162169
std::fs::copy(
163-
format!("target/release/{}", name),
170+
format!("target/{}/{}", &target, &name),
164171
appdirpath.join("usr/bin/bin"),
165172
)
166-
.context("Cannot find binary file")?;
173+
.with_context(|| format!("Cannot find binary file at target/{}/{}", &target, &name))?;
167174
std::fs::copy("./icon.png", appdirpath.join("icon.png")).context("Cannot find icon.png")?;
168175
fs_extra::copy_items(
169176
&assets,
@@ -179,15 +186,15 @@ fn main() -> Result<()> {
179186
std::fs::write(
180187
appdirpath.join("cargo-appimage.desktop"),
181188
format!(
182-
"[Desktop Entry]\nName={}\nExec=bin\nIcon=icon\nType=Application\nCategories=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]\nName={}\nExec=bin\nIcon=icon\nType=Application\nCategories=Utility;", name
190+
),
191+
)
192+
.with_context(|| {
193+
format!(
194+
"Error writing desktop file {}",
195+
appdirpath.join("cargo-appimage.desktop").display()
196+
)
197+
})?;
191198
std::fs::copy(
192199
std::path::PathBuf::from(std::env::var("HOME")?)
193200
.join(".cargo/bin/cargo-appimage-runner"),

0 commit comments

Comments
 (0)