From 495da659a7a21badbf47e6fcb68e51a6ef2bcef8 Mon Sep 17 00:00:00 2001 From: whitequark Date: Tue, 4 Jun 2019 11:33:51 +0000 Subject: [PATCH] build.plat: allow (easily) overriding with an empty string on Windows. --- nmigen/build/plat.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/nmigen/build/plat.py b/nmigen/build/plat.py index 82508e7..7ab2d7d 100644 --- a/nmigen/build/plat.py +++ b/nmigen/build/plat.py @@ -222,7 +222,11 @@ class TemplatedPlatform(Platform): def get_override(var): var_env = "NMIGEN_{}".format(var) if var_env in os.environ: - return os.environ[var_env] + # On Windows, there is no way to define an "empty but set" variable; it is tempting + # to use a quoted empty string, but it doesn't do what one would expect. Recognize + # this as a useful pattern anyway, and treat `set VAR=""` on Windows the same way + # `export VAR=` is treated on Linux. + return re.sub(r'^\"\"$', "", os.environ[var_env]) elif var in kwargs: return kwargs[var] else: -- 2.30.2