Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build: modify meson build file to select the correct C/C++ runtime #1771

Draft
wants to merge 8 commits into
base: develop
Choose a base branch
from
Draft
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
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
38 changes: 19 additions & 19 deletions .vscode/build_vscode.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,13 @@
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"]
elif args.buildtype == "debug":
setup_flag = ["-Ddebug=true", "-Doptimization=0"]
setup_flag = [f"-Dbuildtype={args.buildtype}"]

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

if not os.path.isdir(builddir):
if args.action == "rebuild":
shutil.rmtree(builddir)
command = [
"meson",
"setup",
Expand All @@ -44,14 +42,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)

28 changes: 10 additions & 18 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,18 @@ project(
license: 'CC0',
meson_version: '>= 1.1.0',
default_options : [
'buildtype=release',
'b_vscrt=static_from_buildtype', # Link runtime libraries statically on Windows
'optimization=2',
'debug=false',
'fortran_std=f2008',
])

if get_option('optimization') == '3'
error('Only optimization levels <= 2 are supported')
endif

if get_option('optimization') == '2'
profile = 'release'
else
profile = 'develop'
endif
message('The used profile is:', profile)
build_type = get_option('buildtype')
message('The build type is:', build_type)

# parse compiler options
fc = meson.get_compiler('fortran')
fc_id = fc.get_id()
message('The fc_id is:', fc_id)
message('Fortran compiler id:', fc_id)
compile_args = []
link_args = []

Expand All @@ -43,11 +34,11 @@ if fc_id == 'gcc'
'-Wno-uninitialized',
]

# Options specific to profile
if profile == 'release'
compile_args += ['-ffpe-summary=overflow', '-ffpe-trap=overflow,zero,invalid']
elif profile == 'develop'
# Options specific to build_type
if build_type.startswith('debug')
compile_args += ['-fcheck=all', '-ffpe-trap=overflow,zero,invalid']
else
compile_args += ['-ffpe-summary=overflow', '-ffpe-trap=overflow,zero,invalid']
endif

# Define OS with gfortran for OS specific code
Expand Down Expand Up @@ -102,7 +93,6 @@ 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

# parallel build options
Expand Down Expand Up @@ -240,13 +230,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
Loading