diff --git a/.travis.yml b/.travis.yml index a1526e7..a10d796 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,3 +7,4 @@ script: - pep8 --ignore=E501 test/test.py - pep8 --ignore=E501 lib/config.py - py.test -vv test/test.py + - py.test -vv lib/config.py diff --git a/lib/config.py b/lib/config.py index 6c1bc70..be34c43 100644 --- a/lib/config.py +++ b/lib/config.py @@ -44,6 +44,34 @@ def setup_build_path(build_path): 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): """ Execute CMake command. @@ -113,6 +141,8 @@ def configure(root_directory, build_path, cmake_command, only_show): if not only_show: setup_build_path(build_path) + cmake_command = adapt_cmake_command_to_platform(cmake_command, sys.platform) + print('%s\n' % cmake_command) if only_show: sys.exit(0)