From 53c86e34f4f8c3c45d2dccd5e8eb7fa953de8cdd Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 30 Nov 2015 13:33:39 +0100 Subject: [PATCH] build: ensure we return to working directory after building --- litex/build/altera/quartus.py | 3 ++- litex/build/lattice/diamond.py | 3 ++- litex/build/xilinx/vivado.py | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/litex/build/altera/quartus.py b/litex/build/altera/quartus.py index d5eda886f..cdab36be3 100644 --- a/litex/build/altera/quartus.py +++ b/litex/build/altera/quartus.py @@ -114,6 +114,7 @@ quartus_sta {build_name} -c {build_name} class AlteraQuartusToolchain: def build(self, platform, fragment, build_dir="build", build_name="top", toolchain_path="/opt/Altera", run=True): + cwd = os.getcwd() tools.mkdir_noerror(build_dir) os.chdir(build_dir) @@ -135,7 +136,7 @@ class AlteraQuartusToolchain: if run: _run_quartus(build_name, toolchain_path) - os.chdir("..") + os.chdir(cwd) return v_output.ns diff --git a/litex/build/lattice/diamond.py b/litex/build/lattice/diamond.py index cd169fdbc..857fef021 100644 --- a/litex/build/lattice/diamond.py +++ b/litex/build/lattice/diamond.py @@ -78,6 +78,7 @@ class LatticeDiamondToolchain: def build(self, platform, fragment, build_dir="build", build_name="top", toolchain_path="/opt/Diamond", run=True): tools.mkdir_noerror(build_dir) + cwd = os.getcwd() os.chdir(build_dir) if not isinstance(fragment, _Fragment): @@ -96,7 +97,7 @@ class LatticeDiamondToolchain: if run: _run_diamond(build_name, toolchain_path) - os.chdir("..") + os.chdir(cwd) return v_output.ns diff --git a/litex/build/xilinx/vivado.py b/litex/build/xilinx/vivado.py index 18474d3d2..557016e72 100644 --- a/litex/build/xilinx/vivado.py +++ b/litex/build/xilinx/vivado.py @@ -114,6 +114,7 @@ class XilinxVivadoToolchain: def build(self, platform, fragment, build_dir="build", build_name="top", toolchain_path="/opt/Xilinx/Vivado", source=True, run=True): tools.mkdir_noerror(build_dir) + cwd = os.getcwd() os.chdir(build_dir) if not isinstance(fragment, _Fragment): @@ -129,7 +130,7 @@ class XilinxVivadoToolchain: if run: _run_vivado(build_name, toolchain_path, source) - os.chdir("..") + os.chdir(cwd) return v_output.ns