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

external_project: workaround for MinGW #13886

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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 mesonbuild/modules/external_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from ..interpreter.type_checking import ENV_KW, DEPENDS_KW
from ..interpreterbase.decorators import ContainerTypeInfo, KwargInfo, typed_kwargs, typed_pos_args
from ..mesonlib import (EnvironmentException, MesonException, Popen_safe, MachineChoice,
get_variable_regex, do_replacement, join_args)
get_variable_regex, do_replacement, join_args, relpath)
from ..options import OptionKey

if T.TYPE_CHECKING:
Expand Down Expand Up @@ -93,10 +93,10 @@ def __init__(self,
# will install files into "c:/bar/c:/foo" which is an invalid path.
# Work around that issue by removing the drive from prefix.
if self.prefix.drive:
self.prefix = self.prefix.relative_to(self.prefix.drive)
self.prefix = Path(relpath(str(self.prefix), str(self.prefix.drive)))

# self.prefix is an absolute path, so we cannot append it to another path.
self.rel_prefix = self.prefix.relative_to(self.prefix.root)
self.rel_prefix = Path(relpath(str(self.prefix), str(self.prefix.root)))

self._configure(state)

Expand Down
10 changes: 10 additions & 0 deletions test cases/common/33 run program/check-mingw.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python3

import os, sys, re

if 'MSYSTEM' in os.environ and os.environ['MSYSTEM'] != '':
print(os.environ['MSYSTEM'])
else:
match = re.search('[\\\\/](mingw32|mingw64|clang32|clang64|clangarm64|ucrt64)[\\\\/]', sys.executable, flags=re.IGNORECASE)
if match:
print(match.group(1).upper())
7 changes: 5 additions & 2 deletions test cases/common/33 run program/meson.build
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
project('run command', version : run_command('get-version.py', check : true).stdout().strip(), meson_version: '>=0.1.0')

if build_machine.system() == 'windows'
check_mingw = run_command('check-mingw.py', check : true).stdout().strip()
is_mingw = not (check_mingw == '' or check_mingw == 'MSYS')

if build_machine.system() == 'windows' and not is_mingw
c = run_command('cmd', '/c', 'echo', 'hello', check: false)
else
c = run_command('echo', 'hello', check: false)
Expand Down Expand Up @@ -45,7 +48,7 @@ endif
# We should be able to have files() in argument
f = files('meson.build')

if build_machine.system() == 'windows'
if build_machine.system() == 'windows' and not is_mingw
c = run_command('cmd', '/c', 'echo', f, check: false)
else
c = run_command('echo', f, check: false)
Expand Down
3 changes: 1 addition & 2 deletions test cases/frameworks/25 hdf5/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
"matrix": {
"options": {
"method": [
{ "val": "pkg-config", "expect_skip_on_jobname": ["linux-gentoo-gcc"] },
{ "val": "config-tool", "expect_skip_on_jobname": ["macos"] }
{ "val": "pkg-config", "expect_skip_on_jobname": ["linux-gentoo-gcc"] }
]
}
},
Expand Down
26 changes: 13 additions & 13 deletions unittests/windowstests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,20 +54,20 @@ def test_find_program(self):
PATH to point to a directory with Python scripts.
'''
testdir = os.path.join(self.platform_test_dir, '8 find program')
# Find `cmd` and `cmd.exe`
prog1 = ExternalProgram('cmd')
self.assertTrue(prog1.found(), msg='cmd not found')
prog2 = ExternalProgram('cmd.exe')
self.assertTrue(prog2.found(), msg='cmd.exe not found')
# Find `xcopy` and `xcopy.exe`
prog1 = ExternalProgram('xcopy')
self.assertTrue(prog1.found(), msg='xcopy not found')
prog2 = ExternalProgram('xcopy.exe')
self.assertTrue(prog2.found(), msg='xcopy.exe not found')
self.assertPathEqual(prog1.get_path(), prog2.get_path())
# Find cmd.exe with args without searching
prog = ExternalProgram('cmd', command=['cmd', '/C'])
self.assertTrue(prog.found(), msg='cmd not found with args')
self.assertPathEqual(prog.get_command()[0], 'cmd')
# Find cmd with an absolute path that's missing the extension
cmd_path = prog2.get_path()[:-4]
prog = ExternalProgram(cmd_path)
self.assertTrue(prog.found(), msg=f'{cmd_path!r} not found')
# Find xcopy.exe with args without searching
prog = ExternalProgram('xcopy', command=['xcopy', '/?'])
self.assertTrue(prog.found(), msg='xcopy not found with args')
self.assertPathEqual(prog.get_command()[0], 'xcopy')
# Find xcopy with an absolute path that's missing the extension
xcopy_path = prog2.get_path()[:-4]
prog = ExternalProgram(xcopy_path)
self.assertTrue(prog.found(), msg=f'{xcopy_path!r} not found')
# Finding a script with no extension inside a directory works
prog = ExternalProgram(os.path.join(testdir, 'test-script'))
self.assertTrue(prog.found(), msg='test-script not found')
Expand Down
Loading