diff options
| author | Dan Willemsen <dwillemsen@google.com> | 2020-06-11 19:13:51 -0700 |
|---|---|---|
| committer | Dan Willemsen <dwillemsen@google.com> | 2020-06-11 21:20:36 -0700 |
| commit | 648af95332dc851db83aecc053c56aa2d4695e7c (patch) | |
| tree | 416360687ffbd2e033f80996abb797f5d647724f | |
| parent | 546261a74b75581fb35721b8def124821f2edb53 (diff) | |
| download | platform_build_kati-648af95332dc851db83aecc053c56aa2d4695e7c.tar.gz platform_build_kati-648af95332dc851db83aecc053c56aa2d4695e7c.tar.bz2 platform_build_kati-648af95332dc851db83aecc053c56aa2d4695e7c.zip | |
Error out on empty variable names
In #83 we followed Make's example and accepted empty target-specific
variable names, but now, with Make 4.1, it's an error.
Test: run test suite on ubuntu 18.04 which has Make 4.1
Change-Id: I55211ca1130ce855e9242b6e03401a55b69d2a73
| -rw-r--r-- | eval.cc | 22 | ||||
| -rw-r--r-- | testcase/empty_target_specific_var.mk | 2 | ||||
| -rw-r--r-- | testcase/empty_target_specific_var2.mk | 2 |
3 files changed, 5 insertions, 21 deletions
@@ -300,26 +300,10 @@ void Evaluator::EvalRule(const RuleStmt* stmt) { return; } - // "test: =foo" is questionable but a valid rule definition (not a - // target specific variable). - // See https://github.com/google/kati/issues/83 - string buf; if (!separator_pos) { - KATI_WARN_LOC(loc_, - "defining a target which starts with `=', " - "which is not probably what you meant"); - buf = after_targets.as_string(); - if (stmt->sep == RuleStmt::SEP_SEMICOLON) { - buf += ';'; - } else if (stmt->sep == RuleStmt::SEP_EQ || - stmt->sep == RuleStmt::SEP_FINALEQ) { - buf += '='; - } - if (stmt->rhs) { - buf += stmt->rhs->Eval(this); - } - after_targets = buf; - separator_pos = string::npos; + // We used to make this a warning and otherwise accept it, but Make 4.1 + // calls this out as an error, so let's follow. + Error("*** empty variable name."); } Rule* rule = new Rule(); diff --git a/testcase/empty_target_specific_var.mk b/testcase/empty_target_specific_var.mk index fd9e6c1..5683eb2 100644 --- a/testcase/empty_target_specific_var.mk +++ b/testcase/empty_target_specific_var.mk @@ -4,4 +4,4 @@ test: =foo var==foo $(var): - echo PASS + echo FAIL diff --git a/testcase/empty_target_specific_var2.mk b/testcase/empty_target_specific_var2.mk index 6defb52..960a615 100644 --- a/testcase/empty_target_specific_var2.mk +++ b/testcase/empty_target_specific_var2.mk @@ -8,4 +8,4 @@ $(call var) eq_one:==1 $(eq_one): - echo PASS + echo FAIL |
