Skip to content

Commit

Permalink
Improve vscode meson integration (MODFLOW-USGS#945)
Browse files Browse the repository at this point in the history
- Removes compile call. This is already done by install. Now it doesn't give a confusing message anymore.

- Print the commands it runs
  • Loading branch information
Hofer-Julian committed Jul 15, 2022
1 parent 8bd9546 commit 0f38a7f
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions .vscode/build_vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import os
import argparse
import shutil
import shlex

parser = argparse.ArgumentParser()
parser.add_argument("--compiler", type=str)
Expand All @@ -12,25 +13,30 @@
os.environ["FC"] = args.compiler
builddir = f"builddir_{args.compiler}_{args.buildtype}"


if args.action == "rebuild" and os.path.isdir(builddir):
shutil.rmtree(builddir)


if args.buildtype == "release":
setup_flag = ["-Doptimization=2"]
elif args.buildtype == "debug":
setup_flag = ["-Doptimization=0"]

if not os.path.isdir(builddir):
command = [
"meson",
"setup",
builddir,
"--prefix",
os.getcwd(),
"--libdir",
"bin",
] + setup_flag
print("Run:", shlex.join(command))
subprocess.run(
["meson", "setup", builddir, "--prefix", os.getcwd(), "--libdir", "bin"]
+ setup_flag,
command,
check=True,
)

subprocess.run(["meson", "compile", "-C", builddir], check=True)

# Remove all files from bin folder
bin_dir = os.path.join(os.getcwd(), "bin")
if os.path.isdir(bin_dir):
Expand All @@ -39,4 +45,6 @@
if os.path.isfile(path):
os.remove(path)

subprocess.run(["meson", "install", "-C", builddir], check=True)
command = ["meson", "install", "-C", builddir]
print("Run:", shlex.join(command))
subprocess.run(command, check=True)

0 comments on commit 0f38a7f

Please sign in to comment.