Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions meson_scripts/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ def _extract_member(self, member, targetpath, pwd):

if not os.path.exists(filepath) and not os.path.exists(alt_filepath):
try:
urllib.request.urlretrieve(url, commit_sha + ".zip")
urllib.request.urlretrieve(url, filename)
except Exception as e:
print(e)
print("Download of module " + name + " failed.")
Expand All @@ -303,8 +303,8 @@ def _extract_member(self, member, targetpath, pwd):
filepath = alt_filepath

# Unzip file
zipf = MyZipFile(filepath)
zipf.extractall(target_dir)
with MyZipFile(filepath) as zipf:
zipf.extractall(target_dir)

# Remove directory if exists
if os.path.exists(alt_name):
Expand Down
16 changes: 10 additions & 6 deletions preconfigure.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def build_ninja():
# If we are on windows, we don't need to compile ninja, we just download the executable
if os.name == "nt":
ninja_exe_url = "https://github.com/ninja-build/ninja/releases/download/v1.13.0/ninja-win.zip"
ninja_zip_path = os.path.join(sys.path[0], "ninja-win.zip")

# Try to execute ninja, if it fails, download .exe from github
try:
Expand All @@ -48,18 +49,18 @@ def build_ninja():
except OSError:
print("Downloading ninja ... ")
try:
urllib.request.urlretrieve(ninja_exe_url, "ninja-win.zip")
except:
urllib.request.urlretrieve(ninja_exe_url, ninja_zip_path)
except Exception as e:
print(e)
print("Download of ninja executable failed.")
print("Get archive at " + ninja_exe_url)
print("extract ninja.exe in the source code root folder.")
print("Run meson.py again.")
sys.exit(1)

zipf = zipfile.ZipFile(sys.path[0] + os.path.sep + "ninja-win.zip")
zipf.extractall(sys.path[0])
remove_file(sys.path[0] + os.path.sep + "ninja-win.zip")
with zipfile.ZipFile(ninja_zip_path) as zipf:
zipf.extractall(sys.path[0])
remove_file(ninja_zip_path)
else:
ninjapath = sys.path[0] + os.path.sep + "externals" + os.path.sep + "ninja"
try:
Expand All @@ -75,7 +76,10 @@ def build_ninja():
subprocess.run(
["python3", "configure.py", "--bootstrap"], cwd=ninjapath, env=env
)
shutil.copy(ninjapath + os.path.sep + "ninja", ".")
shutil.copy(
os.path.join(ninjapath, "ninja"),
os.path.join(sys.path[0], "ninja"),
)


def run(
Expand Down
Loading