Skip to content

Commit 07c0e6c

Browse files
committed
Only use strip if on rust 1.59 or later
1 parent d8b3aea commit 07c0e6c

File tree

4 files changed

+67
-30
lines changed

4 files changed

+67
-30
lines changed

Cargo.lock

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ lazy_static = "1"
2727
log = "0.4"
2828
pulldown-cmark = "0.8"
2929
regex = "1"
30+
rustversion = "1.0"
3031
serde = { version = "1", features = ["derive"] }
3132
serde_json = "1"
3233
sha-1 = "0.9"

src/consts.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ pub const MANI_FILE_SUB: &str = "file";
141141
/**
142142
The default manifest used for packages.
143143
*/
144+
#[rustversion::before(1.59)]
145+
pub const DEFAULT_MANIFEST: &str = r##"
146+
[package]
147+
name = "#{name}"
148+
version = "0.1.0"
149+
authors = ["Anonymous"]
150+
edition = "2018"
151+
152+
[[bin]]
153+
name = "#{bin_name}"
154+
path = "#{file}.rs"
155+
"##;
156+
#[rustversion::since(1.59)]
144157
pub const DEFAULT_MANIFEST: &str = r##"
145158
[package]
146159
name = "#{name}"

src/manifest.rs

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,16 @@ pub fn split_input(
125125
Ok((mani_str, source))
126126
}
127127

128+
#[rustversion::before(1.59)]
129+
#[cfg(test)]
130+
pub const STRIP_SECTION: &str = "";
131+
#[rustversion::since(1.59)]
132+
#[cfg(test)]
133+
pub const STRIP_SECTION: &str = r##"
134+
[profile.release]
135+
strip = true
136+
"##;
137+
128138
#[test]
129139
fn test_split_input() {
130140
let input_id = OsString::from("input_id");
@@ -147,7 +157,9 @@ fn test_split_input() {
147157
assert_eq!(
148158
si!(f(r#"fn main() {}"#)),
149159
r!(
150-
r#"[[bin]]
160+
format!(
161+
"{}{}",
162+
r#"[[bin]]
151163
name = "n_input_id"
152164
path = "n.rs"
153165
@@ -157,10 +169,9 @@ path = "n.rs"
157169
authors = ["Anonymous"]
158170
edition = "2018"
159171
name = "n"
160-
version = "0.1.0"
161-
[profile.release]
162-
strip = true
163-
"#,
172+
version = "0.1.0""#,
173+
STRIP_SECTION
174+
),
164175
r#"fn main() {}"#
165176
)
166177
);
@@ -172,7 +183,9 @@ strip = true
172183
fn main() {}
173184
"#)),
174185
r!(
175-
r#"[[bin]]
186+
format!(
187+
"{}{}",
188+
r#"[[bin]]
176189
name = "n_input_id"
177190
path = "n.rs"
178191
@@ -182,10 +195,9 @@ path = "n.rs"
182195
authors = ["Anonymous"]
183196
edition = "2018"
184197
name = "n"
185-
version = "0.1.0"
186-
[profile.release]
187-
strip = true
188-
"#,
198+
version = "0.1.0""#,
199+
STRIP_SECTION
200+
),
189201
r#"
190202
---
191203
fn main() {}
@@ -200,7 +212,9 @@ time="0.1.25"
200212
fn main() {}
201213
"#)),
202214
r!(
203-
r#"[[bin]]
215+
format!(
216+
"{}{}",
217+
r#"[[bin]]
204218
name = "n_input_id"
205219
path = "n.rs"
206220
@@ -210,10 +224,9 @@ path = "n.rs"
210224
authors = ["Anonymous"]
211225
edition = "2018"
212226
name = "n"
213-
version = "0.1.0"
214-
[profile.release]
215-
strip = true
216-
"#,
227+
version = "0.1.0""#,
228+
STRIP_SECTION
229+
),
217230
r#"[dependencies]
218231
time="0.1.25"
219232
---
@@ -228,7 +241,9 @@ fn main() {}
228241
fn main() {}
229242
"#)),
230243
r!(
231-
r#"[[bin]]
244+
format!(
245+
"{}{}",
246+
r#"[[bin]]
232247
name = "n_input_id"
233248
path = "n.rs"
234249
@@ -239,10 +254,9 @@ time = "0.1.25"
239254
authors = ["Anonymous"]
240255
edition = "2018"
241256
name = "n"
242-
version = "0.1.0"
243-
[profile.release]
244-
strip = true
245-
"#,
257+
version = "0.1.0""#,
258+
STRIP_SECTION
259+
),
246260
r#"
247261
// Cargo-Deps: time="0.1.25"
248262
fn main() {}
@@ -256,7 +270,9 @@ fn main() {}
256270
fn main() {}
257271
"#)),
258272
r!(
259-
r#"[[bin]]
273+
format!(
274+
"{}{}",
275+
r#"[[bin]]
260276
name = "n_input_id"
261277
path = "n.rs"
262278
@@ -268,10 +284,9 @@ time = "0.1.25"
268284
authors = ["Anonymous"]
269285
edition = "2018"
270286
name = "n"
271-
version = "0.1.0"
272-
[profile.release]
273-
strip = true
274-
"#,
287+
version = "0.1.0""#,
288+
STRIP_SECTION
289+
),
275290
r#"
276291
// Cargo-Deps: time="0.1.25", libc="0.2.5"
277292
fn main() {}
@@ -292,7 +307,9 @@ time = "0.1.25"
292307
fn main() {}
293308
"#)),
294309
r!(
295-
r#"[[bin]]
310+
format!(
311+
"{}{}",
312+
r#"[[bin]]
296313
name = "n_input_id"
297314
path = "n.rs"
298315
@@ -303,10 +320,9 @@ time = "0.1.25"
303320
authors = ["Anonymous"]
304321
edition = "2018"
305322
name = "n"
306-
version = "0.1.0"
307-
[profile.release]
308-
strip = true
309-
"#,
323+
version = "0.1.0""#,
324+
STRIP_SECTION
325+
),
310326
r#"
311327
/*!
312328
Here is a manifest:

0 commit comments

Comments
 (0)