From f87d49e41a5dd57733d02f3990c91dc38e557dad Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Thu, 29 Sep 2016 20:09:47 -0700 Subject: Support marking variables as readonly When the magic variable .KATI_READONLY is set to a variable name, any further attempts to modify the named variable will result in an error. FOO := bar .KATI_READONLY := FOO FOO := baz # Error! This is useful to make some global configuration readonly so that another makefile cannot change it. In Android, we emulated this by backing up some global configuration before including the Android.mk files, then comparing the current values to the backed up values after they've been included. But this means we don't know the location that modified the variable, just that something did. And it's not perfect, since the backup can also be changed. Something similar to this could be implemented with `override`, but then setting the variable silently fails, and it still could be overriden with another override. --- symtab.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'symtab.h') diff --git a/symtab.h b/symtab.h index e7e71d5..7e39be9 100644 --- a/symtab.h +++ b/symtab.h @@ -56,7 +56,7 @@ class Symbol { bool IsValid() const { return v_ >= 0; } Var* GetGlobalVar() const; - void SetGlobalVar(Var* v, bool is_override = false) const; + void SetGlobalVar(Var* v, bool is_override = false, bool* readonly = nullptr) const; private: explicit Symbol(int v); -- cgit v1.2.3