Skip to content

Commit

Permalink
build: modify meson build file to select the correct C/C++ runtime
Browse files Browse the repository at this point in the history
* add compiler option (-co) test to meson tests
* update ci workflow to run meson tests
  • Loading branch information
jdhughes-usgs committed May 3, 2024
1 parent 574f1f3 commit 0e1ba14
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,7 @@ jobs:
run: |
pixi run setup builddir
pixi run build builddir
pixi run test builddir
- name: Show build log
if: failure()
Expand Down
34 changes: 18 additions & 16 deletions .vscode/build_vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
if os.environ["BUILD_PARALLEL_MF6"] == '1':
arg_parallel = "-Dparallel=true"

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

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

if args.action == "rebuild":
setup_flag += ["--wipe"]

if not os.path.isdir(builddir):
if args.action == "rebuild":
command = [
"meson",
"setup",
Expand All @@ -44,14 +44,16 @@
check=True,
)

# Remove all files from bin folder
bin_dir = os.path.join(os.getcwd(), "bin")
if os.path.isdir(bin_dir):
for dir_entry in os.scandir(bin_dir):
path = dir_entry.path
if os.path.isfile(path):
os.remove(path)

command = ["meson", "install", "-C", builddir]
print("Run:", shlex.join(command))
subprocess.run(command, check=True)
if args.action == "rebuild" or args.action == "build":
# Remove all files from bin folder
bin_dir = os.path.join(os.getcwd(), "bin")
if os.path.isdir(bin_dir):
for dir_entry in os.scandir(bin_dir):
path = dir_entry.path
if os.path.isfile(path):
os.remove(path)

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

10 changes: 10 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,15 @@ elif fc_id == 'intel-llvm-cl'
link_args += ['/ignore:4217', # access through ddlimport might be inefficient
'/ignore:4286' # same as 4217, but more general
]
endif

# add the correct C/C++ CRT runtime on Windows based on profile
if build_machine.system() == 'windows'
if get_option('debug') == 'true'
compile_args += ['/MTd']
else
compile_args += ['/MT']
endif
endif

# parallel build options
Expand Down Expand Up @@ -240,13 +248,15 @@ if with_mpi
if mpiexec.found()
test('Parallel version command line test', mpiexec, args : ['-n', '2', mf6exe, '-v', '-p'], is_parallel : false)
test('Parallel compiler command line test', mpiexec, args : ['-n', '2', mf6exe, '-c', '-p'], is_parallel : false)
test('Parallel compiler options command line test', mpiexec, args : ['-n', '2', mf6exe, '-co', '-p'], is_parallel : false)
test('Serial simulation test', mf6exe, workdir : testdir, is_parallel : false)
test('Parallel simulation test - 1 core', mpiexec, workdir : testdir, args : ['-n', '1', mf6exe, '-p'], is_parallel : false)
test('Parallel simulation test - 2 cores', mpiexec, workdir : testdir, args : ['-n', '2', mf6exe, '-p'], is_parallel : false)
endif
else
test('Version command line test', mf6exe, args : ['-v',])
test('Compiler command line test', mf6exe, args : ['-c',])
test('Compiler options command line test', mf6exe, args : ['-co',])
test('Test installation help', mf6exe, args : ['-h',])
test('Serial simulation test', mf6exe, workdir : testdir)
endif

0 comments on commit 0e1ba14

Please sign in to comment.