diff --git a/tests/unit-doc/CMakeLists.txt b/tests/unit-doc/CMakeLists.txt index 97ebbcfbb..1157dbc5d 100644 --- a/tests/unit-doc/CMakeLists.txt +++ b/tests/unit-doc/CMakeLists.txt @@ -14,17 +14,21 @@ cmake_minimum_required (VERSION 2.8.12) project (unit-doc C) +find_package(PythonInterp REQUIRED) set(GEN_DOCTEST "${CMAKE_SOURCE_DIR}/tools/gen-doctest.py") file(GLOB DOC_FILES "${CMAKE_SOURCE_DIR}/docs/*.md") -set(COMPILE_FLAGS_DOCTEST "-Wno-unused-parameter -Wno-unused-function -Wno-unused-variable") +if(NOT (${CMAKE_C_COMPILER_ID} STREQUAL MSVC)) + set(COMPILE_FLAGS_DOCTEST "-Wno-unused-parameter -Wno-unused-function -Wno-unused-variable") +endif() + # Dry run of the doctest generator: analyze MarkDown files and get the list of # file names that will be generated. This allows the definition of proper # dependencies between the MarkDown files and the generated sources. execute_process( - COMMAND ${GEN_DOCTEST} --dry -d ${CMAKE_CURRENT_BINARY_DIR} ${DOC_FILES} + COMMAND ${Python_EXECUTABLE} ${GEN_DOCTEST} --dry -d ${CMAKE_CURRENT_BINARY_DIR} ${DOC_FILES} OUTPUT_VARIABLE DOCTEST_OUTPUT RESULT_VARIABLE GEN_DOCTEST_RESULT ) diff --git a/tools/build.py b/tools/build.py index d3efb5a40..52c2bc8fc 100755 --- a/tools/build.py +++ b/tools/build.py @@ -25,6 +25,10 @@ import sys import settings def default_toolchain(): + # We don't have default toolchain on Windows and os.uname() isn't supported. + if sys.platform == 'win32': + return None + (sysname, _, _, _, machine) = os.uname() toolchain = os.path.join(settings.PROJECT_DIR, 'cmake', @@ -60,7 +64,7 @@ def get_arguments(): buildgrp.add_argument('--compile-flag', metavar='OPT', action='append', default=[], help='add custom compile flag') buildgrp.add_argument('--debug', action='store_const', const='Debug', dest='build_type', - help='debug build') + default='MinSizeRel', help='debug build') buildgrp.add_argument('--install', metavar='DIR', nargs='?', default=None, const=False, help='install after build (default: don\'t install; ' 'default directory if install: OS-specific)') @@ -244,12 +248,19 @@ def configure_jerry(arguments): return subprocess.call(cmake_cmd) -def make_jerry(arguments, target=None): - make_cmd = ['make', '--no-print-directory', '-j', str(arguments.jobs), '-C', arguments.builddir] +def make_jerry(arguments): + make_cmd = ['cmake', '--build', arguments.builddir, '--config', arguments.build_type] + env = dict(os.environ) + env['CMAKE_BUILD_PARALLEL_LEVEL'] = str(arguments.jobs) + env['MAKEFLAGS'] = '-j%d' % (arguments.jobs) # Workaround for CMake < 3.12 + proc = subprocess.Popen(make_cmd, env=env) + proc.wait() - if target: - make_cmd.append(target) + return proc.returncode +def install_jerry(arguments): + install_target = 'INSTALL' if sys.platform == 'win32' else 'install' + make_cmd = ['cmake', '--build', arguments.builddir, '--config', arguments.build_type, '--target', install_target] return subprocess.call(make_cmd) def print_result(ret): @@ -269,7 +280,7 @@ def main(): ret = make_jerry(arguments) if not ret and arguments.install is not None: - ret = make_jerry(arguments, 'install') + ret = install_jerry(arguments) print_result(ret) sys.exit(ret) diff --git a/tools/gen-doctest.py b/tools/gen-doctest.py index 9e3c19667..02052736a 100755 --- a/tools/gen-doctest.py +++ b/tools/gen-doctest.py @@ -96,7 +96,7 @@ class DoctestExtractor(object): :param decl: the dictionary of the declaration parameters. :param code: the list of lines of the doctest. """ - outname = os.path.join(self._outdir, decl['name']) + outname = os.path.join(self._outdir, decl['name']).replace('\\', '/') action = decl['test'] if self._dry: print('%s %s' % (action, outname))