adapt cmake command to platform
(code contributed by Miro Ilias)
This commit is contained in:
parent
6f592ba2f0
commit
13c7398979
@ -7,3 +7,4 @@ script:
|
|||||||
- pep8 --ignore=E501 test/test.py
|
- pep8 --ignore=E501 test/test.py
|
||||||
- pep8 --ignore=E501 lib/config.py
|
- pep8 --ignore=E501 lib/config.py
|
||||||
- py.test -vv test/test.py
|
- py.test -vv test/test.py
|
||||||
|
- py.test -vv lib/config.py
|
||||||
|
@ -44,6 +44,34 @@ def setup_build_path(build_path):
|
|||||||
os.makedirs(build_path, 0o755)
|
os.makedirs(build_path, 0o755)
|
||||||
|
|
||||||
|
|
||||||
|
def test_adapt_cmake_command_to_platform():
|
||||||
|
|
||||||
|
cmake_command = "FC=foo CC=bar CXX=RABOOF cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||||
|
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
|
||||||
|
assert res == cmake_command
|
||||||
|
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
|
||||||
|
assert res == "set FC=foo && set CC=bar && set CXX=RABOOF && cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||||
|
|
||||||
|
cmake_command = "cmake -DTHIS -DTHAT='this and that cmake' .."
|
||||||
|
res = adapt_cmake_command_to_platform(cmake_command, 'linux')
|
||||||
|
assert res == cmake_command
|
||||||
|
res = adapt_cmake_command_to_platform(cmake_command, 'win32')
|
||||||
|
assert res == cmake_command
|
||||||
|
|
||||||
|
|
||||||
|
def adapt_cmake_command_to_platform(cmake_command, platform):
|
||||||
|
"""
|
||||||
|
Adapt CMake command to MS Windows platform.
|
||||||
|
"""
|
||||||
|
if platform == 'win32':
|
||||||
|
pos = cmake_command.find('cmake')
|
||||||
|
s = ['set %s &&' % e for e in cmake_command[:pos].split()]
|
||||||
|
s.append(cmake_command[pos:])
|
||||||
|
return ' '.join(s)
|
||||||
|
else:
|
||||||
|
return cmake_command
|
||||||
|
|
||||||
|
|
||||||
def run_cmake(command, build_path, default_build_path):
|
def run_cmake(command, build_path, default_build_path):
|
||||||
"""
|
"""
|
||||||
Execute CMake command.
|
Execute CMake command.
|
||||||
@ -113,6 +141,8 @@ def configure(root_directory, build_path, cmake_command, only_show):
|
|||||||
if not only_show:
|
if not only_show:
|
||||||
setup_build_path(build_path)
|
setup_build_path(build_path)
|
||||||
|
|
||||||
|
cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform)
|
||||||
|
|
||||||
print('%s\n' % cmake_command)
|
print('%s\n' % cmake_command)
|
||||||
if only_show:
|
if only_show:
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user