Skip to content

Commit

Permalink
Merge pull request #11809 from nix-windows/windows-build/meson-fixes
Browse files Browse the repository at this point in the history
Meson fixes for msys2 builds
  • Loading branch information
Ericson2314 authored Nov 5, 2024
2 parents ef84fa8 + f7abc29 commit dfd0033
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
30 changes: 17 additions & 13 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ subproject('libcmd')
subproject('nix')

# Docs
subproject('internal-api-docs')
subproject('external-api-docs')
if not meson.is_cross_build()
subproject('nix-manual')
if get_option('doc-gen')
subproject('internal-api-docs')
subproject('external-api-docs')
if not meson.is_cross_build()
subproject('nix-manual')
endif
endif

# External C wrapper libraries
Expand All @@ -35,17 +37,19 @@ subproject('libexpr-c')
subproject('libmain-c')

# Language Bindings
if not meson.is_cross_build()
if get_option('bindings') and not meson.is_cross_build()
subproject('perl')
endif

# Testing
subproject('libutil-test-support')
subproject('libutil-tests')
subproject('libstore-test-support')
subproject('libstore-tests')
subproject('libfetchers-tests')
subproject('libexpr-test-support')
subproject('libexpr-tests')
subproject('libflake-tests')
if get_option('unit-tests')
subproject('libutil-test-support')
subproject('libutil-tests')
subproject('libstore-test-support')
subproject('libstore-tests')
subproject('libfetchers-tests')
subproject('libexpr-test-support')
subproject('libexpr-tests')
subproject('libflake-tests')
endif
subproject('nix-functional-tests')
13 changes: 13 additions & 0 deletions meson.options
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# vim: filetype=meson

option('doc-gen', type : 'boolean', value : true,
description : 'Generate documentation',
)

option('unit-tests', type : 'boolean', value : true,
description : 'Build unit tests',
)

option('bindings', type : 'boolean', value : true,
description : 'Build language bindings (e.g. Perl)',
)
7 changes: 7 additions & 0 deletions src/libstore/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ subdir('build-utils-meson/subprojects')
run_command('ln', '-s',
meson.project_build_root() / '__nothing_link_target',
meson.project_build_root() / '__nothing_symlink',
# native doesn't allow dangling symlinks, which the tests require
env : { 'MSYS' : 'winsymlinks:lnk' },
check : true,
)
can_link_symlink = run_command('ln',
Expand Down Expand Up @@ -74,6 +76,11 @@ if host_machine.system() == 'darwin'
deps_other += [sandbox]
endif

if host_machine.system() == 'windows'
wsock32 = cxx.find_library('wsock32')
deps_other += [wsock32]
endif

subdir('build-utils-meson/threads')

boost = dependency(
Expand Down
4 changes: 4 additions & 0 deletions src/nix/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,8 @@ foreach linkname : nix_symlinks
t = custom_target(
command: ['ln', '-sf', fs.name(this_exe), '@OUTPUT@'],
output: linkname + executable_suffix,
# native doesn't allow dangling symlinks, but the target executable often doesn't exist at this time
env : { 'MSYS' : 'winsymlinks:lnk' },
# TODO(Ericson2314): Don't do this once we have the `meson.override_find_program` working)
build_by_default: true
)
Expand All @@ -248,6 +250,8 @@ install_symlink(
custom_target(
command: ['ln', '-sf', fs.name(this_exe), '@OUTPUT@'],
output: 'build-remote' + executable_suffix,
# native doesn't allow dangling symlinks, but the target executable often doesn't exist at this time
env : { 'MSYS' : 'winsymlinks:lnk' },
# TODO(Ericson2314): Don't do this once we have the `meson.override_find_program` working)
build_by_default: true
)
Expand Down
7 changes: 6 additions & 1 deletion tests/functional/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@ fs = import('fs')
nix = find_program('nix')
bash = find_program('bash', native : true)
busybox = find_program('busybox', native : true, required : false)
coreutils = find_program('coreutils', native : true)
if host_machine.system() == 'windows'
# Because of the state of symlinks on Windows, coreutils.exe doesn't usually exist, but things like ls.exe will
coreutils = find_program('ls', native : true)
else
coreutils = find_program('coreutils', native : true)
endif
dot = find_program('dot', native : true, required : false)

nix_bin_dir = fs.parent(nix.full_path())
Expand Down

0 comments on commit dfd0033

Please sign in to comment.