Skip to content
This repository was archived by the owner on Jun 17, 2022. It is now read-only.

Commit 014be6f

Browse files
committed
remove features
using c conditionals is more consistent, and the variants never really worked anyway across library boundaries
1 parent e37b09f commit 014be6f

File tree

6 files changed

+27
-113
lines changed

6 files changed

+27
-113
lines changed

src/lib.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,12 @@ pub fn build(buildset: BuildSet, variant: &str, stage: make::Stage, _slow: bool)
8181
]);
8282

8383
let mut modules = HashMap::new();
84-
let features = project
85-
.features(variant)
86-
.into_iter()
87-
.map(|(n, (e, _))| (n, e))
88-
.collect();
8984
if root.join("src").exists() {
9085
loader::load(
9186
&mut modules,
9287
&project.project,
9388
&project_name,
9489
&root.join("src"),
95-
&features,
9690
&stage,
9791
);
9892
}
@@ -102,7 +96,6 @@ pub fn build(buildset: BuildSet, variant: &str, stage: make::Stage, _slow: bool)
10296
&project.project,
10397
&project_tests_name,
10498
&root.join("tests").canonicalize().unwrap(),
105-
&features,
10699
&stage,
107100
);
108101
}
@@ -197,17 +190,11 @@ fn getdep(
197190
let (root, project) = project::load(&found);
198191
let project_name = Name(vec![String::new(), project.project.name.clone()]);
199192
if found.join("src").exists() {
200-
let features = project
201-
.features("default")
202-
.into_iter()
203-
.map(|(n, (e, _))| (n, e))
204-
.collect();
205193
loader::load(
206194
modules,
207195
&project.project,
208196
&project_name,
209197
&found.join("src"),
210-
&features,
211198
&stage,
212199
);
213200
}
@@ -238,7 +225,6 @@ fn getdep(
238225
rootproj.pkgconfig.push(i.to_string_lossy().into());
239226
}
240227
rootproj.cflags.extend(project.project.cflags);
241-
rootproj.lflags.extend(project.project.lflags);
242228

243229
if let Some(deps) = &project.dependencies {
244230
for (name, dep) in deps {

src/loader.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ pub fn load(
2222
project: &super::project::Project,
2323
artifact_name: &Name,
2424
src: &Path,
25-
features: &HashMap<String, bool>,
2625
stage: &Stage,
2726
) {
2827
let mut files = Vec::new();
@@ -93,7 +92,7 @@ pub fn load(
9392
if !silent {
9493
pb.lock().unwrap().message(&format!("parsing {:?} ", path));
9594
}
96-
let mut m = parser::parse(&path, features, stage);
95+
let mut m = parser::parse(&path, stage);
9796
m.name = module_name;
9897

9998
debug!("loaded {:?} as {}", path, m.name);

src/make.rs

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ pub struct Make {
129129

130130
impl Make {
131131
pub fn new(mut config: Config, variant: &str, stage: Stage, artifact: Artifact) -> Self {
132-
let features = config.features(variant);
133-
134132
let mut cflags: Vec<String> =
135133
match std::env::var("TARGET_CFLAGS").or(std::env::var("CFLAGS")) {
136134
Err(_) => Vec::new(),
@@ -170,22 +168,10 @@ impl Make {
170168
cxx = "afl-clang++".to_string();
171169
}
172170

173-
let mut cincludes = config.project.cincludes.clone();
174-
let mut pkgconfig = config.project.pkgconfig.clone();
175-
let mut cobjects = std::mem::replace(&mut config.project.cobjects, Vec::new());
176-
let mut user_cflags = config.project.cflags.clone();
177-
let mut user_lflags = config.project.lflags.clone();
178-
179-
for (_, (enabled, feature)) in &features {
180-
if !enabled {
181-
continue;
182-
}
183-
cincludes.extend(feature.cincludes.clone());
184-
pkgconfig.extend(feature.pkgconfig.clone());
185-
cobjects.extend(feature.cobjects.clone());
186-
user_cflags.extend(feature.cflags.clone());
187-
user_lflags.extend(feature.lflags.clone());
188-
}
171+
let cincludes = config.project.cincludes.clone();
172+
let pkgconfig = config.project.pkgconfig.clone();
173+
let cobjects = std::mem::replace(&mut config.project.cobjects, Vec::new());
174+
let user_cflags = config.project.cflags.clone();
189175

190176
for cinc in &cincludes {
191177
cflags.push("-I".into());
@@ -223,7 +209,6 @@ impl Make {
223209
cflags.push("-fvisibility=hidden".to_string());
224210

225211
cflags.extend(user_cflags);
226-
lflags.extend(user_lflags);
227212

228213
let mut stage = stage.clone();
229214
if let Ok(_) = std::env::var("ZZ_BUILD_NO_PIC") {

src/makro.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ pub fn stm(
138138
None => break,
139139
Some(v) => v,
140140
};
141-
for stm2 in parser::parse_block(&path, &HashMap::new(), &super::make::Stage::release(), pp)
141+
for stm2 in parser::parse_block(&path, &super::make::Stage::release(), pp)
142142
.statements
143143
{
144144
statements.push(stm2);

src/parser.rs

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub struct ZZParser;
1313

1414
pub static ERRORS_AS_JSON: AtomicBool = AtomicBool::new(false);
1515

16-
pub fn parse(n: &Path, features: &HashMap<String, bool>, stage: &Stage) -> Module {
17-
match p(&n, features, stage) {
16+
pub fn parse(n: &Path, stage: &Stage) -> Module {
17+
match p(&n, stage) {
1818
Err(e) => {
1919
let e = e.with_path(&n.to_string_lossy().to_string());
2020
if ERRORS_AS_JSON.load(Ordering::SeqCst) {
@@ -49,7 +49,6 @@ pub fn parse(n: &Path, features: &HashMap<String, bool>, stage: &Stage) -> Modul
4949

5050
fn p(
5151
n: &Path,
52-
features: &HashMap<String, bool>,
5352
stage: &Stage,
5453
) -> Result<Module, pest::error::Error<Rule>> {
5554
let mut module = Module::default();
@@ -101,7 +100,7 @@ fn p(
101100
}
102101
}
103102
Rule::block if body.is_none() => {
104-
body = Some(parse_block(&n, features, stage, part));
103+
body = Some(parse_block(&n, stage, part));
105104
}
106105
e => panic!("unexpected rule {:?} in macro ", e),
107106
}
@@ -205,20 +204,20 @@ fn p(
205204
let part = stm.next().unwrap();
206205
let expr = parse_expr(n, part);
207206
let part = stm.next().unwrap();
208-
let body2 = parse_block(n, features, stage, part);
207+
let body2 = parse_block(n, stage, part);
209208
body.branches.push((loc.clone(), Some(expr), body2));
210209
}
211210
Rule::else_stm => {
212211
let mut stm = branch.into_inner();
213212
let part = stm.next().unwrap();
214-
let body2 = parse_block(n, features, stage, part);
213+
let body2 = parse_block(n, stage, part);
215214
body.branches.push((loc.clone(), None, body2));
216215
}
217216
Rule::block => {
218217
body.branches = vec![(
219218
loc.clone(),
220219
None,
221-
parse_block(n, features, stage, branch),
220+
parse_block(n, stage, branch),
222221
)];
223222
}
224223
e => panic!("unexpected rule {:?} in gblock", e),
@@ -657,20 +656,20 @@ fn p(
657656
let part = stm.next().unwrap();
658657
let expr = parse_expr(n, part);
659658
let part = stm.next().unwrap();
660-
let body2 = parse_block(n, features, stage, part);
659+
let body2 = parse_block(n, stage, part);
661660
body.branches.push((loc.clone(), Some(expr), body2));
662661
}
663662
Rule::else_stm => {
664663
let mut stm = branch.into_inner();
665664
let part = stm.next().unwrap();
666-
let body2 = parse_block(n, features, stage, part);
665+
let body2 = parse_block(n, stage, part);
667666
body.branches.push((loc.clone(), None, body2));
668667
}
669668
Rule::block => {
670669
body.branches = vec![(
671670
loc.clone(),
672671
None,
673-
parse_block(n, features, stage, branch),
672+
parse_block(n, stage, branch),
674673
)];
675674
}
676675
e => panic!("unexpected rule {:?} in gblock", e),
@@ -1102,7 +1101,6 @@ pub(crate) fn parse_expr_inner(n: &str, expr: pest::iterators::Pair<'static, Rul
11021101

11031102
pub(crate) fn parse_statement(
11041103
n: &str,
1105-
features: &HashMap<String, bool>,
11061104
stage: &Stage,
11071105
stm: pest::iterators::Pair<'static, Rule>,
11081106
into: &mut Vec<Box<Statement>>,
@@ -1141,7 +1139,7 @@ pub(crate) fn parse_statement(
11411139
into.push(Box::new(Statement::Break { loc }));
11421140
}
11431141
Rule::block => into.push(Box::new(Statement::Block(Box::new(parse_block(
1144-
n, features, stage, stm,
1142+
n, stage, stm,
11451143
))))),
11461144
Rule::return_stm => {
11471145
let mut stm = stm.into_inner();
@@ -1174,15 +1172,15 @@ pub(crate) fn parse_statement(
11741172
let part = stm.next().unwrap();
11751173
let expr = parse_expr(n, part);
11761174
let part = stm.next().unwrap();
1177-
let body = parse_block(n, features, stage, part);
1175+
let body = parse_block(n, stage, part);
11781176
into.push(Box::new(Statement::While { expr, body }));
11791177
}
11801178
Rule::if_stm => {
11811179
let mut stm = stm.into_inner();
11821180
let part = stm.next().unwrap();
11831181
let expr = parse_expr(n, part);
11841182
let part = stm.next().unwrap();
1185-
let body = parse_block(n, features, stage, part);
1183+
let body = parse_block(n, stage, part);
11861184
*current_if_statement = Some(into.len());
11871185
into.push(Box::new(Statement::If {
11881186
branches: vec![(loc.clone(), Some(expr), body)],
@@ -1193,7 +1191,7 @@ pub(crate) fn parse_statement(
11931191
let part = stm.next().unwrap();
11941192
let expr = parse_expr(n, part);
11951193
let part = stm.next().unwrap();
1196-
let body = parse_block(n, features, stage, part);
1194+
let body = parse_block(n, stage, part);
11971195
match *current_if_statement {
11981196
None => {
11991197
emit_error(
@@ -1215,7 +1213,7 @@ pub(crate) fn parse_statement(
12151213
Rule::else_stm => {
12161214
let mut stm = stm.into_inner();
12171215
let part = stm.next().unwrap();
1218-
let body = parse_block(n, features, stage, part);
1216+
let body = parse_block(n, stage, part);
12191217
match *current_if_statement {
12201218
None => {
12211219
emit_error(
@@ -1251,18 +1249,18 @@ pub(crate) fn parse_statement(
12511249
cur += 1;
12521250
}
12531251
Rule::block if cur == 3 && block.is_none() => {
1254-
block = Some(parse_block(n, features, stage, part));
1252+
block = Some(parse_block(n, stage, part));
12551253
}
12561254
_ if cur == 1 => {
12571255
let mut cif = None;
1258-
parse_statement(n, features, stage, part, &mut expr1, &mut cif);
1256+
parse_statement(n, stage, part, &mut expr1, &mut cif);
12591257
}
12601258
_ if cur == 2 => {
12611259
expr2 = Some(parse_expr(n, part));
12621260
}
12631261
_ if cur == 3 => {
12641262
let mut cif = None;
1265-
parse_statement(n, features, stage, part, &mut expr3, &mut cif);
1263+
parse_statement(n, stage, part, &mut expr3, &mut cif);
12661264
}
12671265
e => panic!("unexpected rule {:?} in for ", e),
12681266
}
@@ -1367,15 +1365,15 @@ pub(crate) fn parse_statement(
13671365
emit_error("multiple default cases", &[(loc.clone(), "in this switch")]);
13681366
std::process::exit(9);
13691367
} else {
1370-
default = Some(parse_block(n, features, stage, part.next().unwrap()));
1368+
default = Some(parse_block(n, stage, part.next().unwrap()));
13711369
}
13721370
} else {
13731371
let mut case_cond = Vec::new();
13741372
for case in ppart.into_inner() {
13751373
case_cond.push(parse_expr(n, case));
13761374
}
13771375

1378-
let block = parse_block(n, features, stage, part.next().unwrap());
1376+
let block = parse_block(n, stage, part.next().unwrap());
13791377
cases.push((case_cond, block));
13801378
}
13811379
}
@@ -1390,7 +1388,6 @@ pub(crate) fn parse_statement(
13901388
Rule::unsafe_block => {
13911389
into.push(Box::new(Statement::Unsafe(Box::new(parse_block(
13921390
n,
1393-
features,
13941391
stage,
13951392
stm.into_inner().next().unwrap(),
13961393
)))));
@@ -1423,7 +1420,6 @@ pub(crate) fn parse_statement(
14231420

14241421
pub(crate) fn parse_block(
14251422
n: &str,
1426-
features: &HashMap<String, bool>,
14271423
stage: &Stage,
14281424
decl: pest::iterators::Pair<'static, Rule>,
14291425
) -> Block {
@@ -1445,7 +1441,7 @@ pub(crate) fn parse_block(
14451441
let mut statements = Vec::new();
14461442
let mut cif_state = None;
14471443
for stm in decl.into_inner() {
1448-
parse_statement(n, features, stage, stm, &mut statements, &mut cif_state)
1444+
parse_statement(n, stage, stm, &mut statements, &mut cif_state)
14491445
}
14501446
Block {
14511447
statements,

0 commit comments

Comments
 (0)