Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/nmigen
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 39ca0e6fa680
Choose a base ref
...
head repository: m-labs/nmigen
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 3adce21ce3bb
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jun 4, 2019

  1. Copy the full SHA
    1d3e9c8 View commit details
  2. Copy the full SHA
    63c4123 View commit details
  3. build.run: fix product extraction to work on Windows.

    Before this commit, it would fail with a "Permission denied" error.
    whitequark committed Jun 4, 2019
    Copy the full SHA
    3adce21 View commit details
Showing with 13 additions and 3 deletions.
  1. +6 −1 nmigen/build/plat.py
  2. +7 −2 nmigen/build/run.py
7 changes: 6 additions & 1 deletion nmigen/build/plat.py
Original file line number Diff line number Diff line change
@@ -188,6 +188,7 @@ class TemplatedPlatform(Platform):
""",
"build_{{name}}.bat": """
@rem {{autogenerated}}
{{quiet("@echo off")}}
{{emit_commands("bat")}}
""",
}
@@ -222,7 +223,11 @@ def get_tool(tool):
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:
9 changes: 7 additions & 2 deletions nmigen/build/run.py
Original file line number Diff line number Diff line change
@@ -68,9 +68,14 @@ def extract(self, *filenames):
files = []
try:
for filename in filenames:
file = tempfile.NamedTemporaryFile(prefix="nmigen_", suffix="_" + filename)
# On Windows, a named temporary file (as created by Python) is not accessible to
# others if it's still open within the Python process, so we close it and delete
# it manually.
file = tempfile.NamedTemporaryFile(prefix="nmigen_", suffix="_" + filename,
delete=False)
files.append(file)
file.write(self.get(filename))
file.close()

if len(files) == 0:
return (yield)
@@ -80,4 +85,4 @@ def extract(self, *filenames):
return (yield [file.name for file in files])
finally:
for file in files:
file.close()
os.unlink(file.name)