Fix building with build.py on Windows (#3013)
Changes: - gen-doctest.py: Use slashes in paths to make cmake happy. - unit-doc/CMakeLists.txt: Don't add invalid arguments to MSVC and call gen-doctest.py properly. - build.py: Build and install with cmake calls on Windows. JerryScript-DCO-1.0-Signed-off-by: Csaba Osztrogonác oszi@inf.u-szeged.hu
This commit is contained in:
committed by
Dániel Bátyai
parent
b47c36ad18
commit
fd075322fb
@@ -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
|
||||
)
|
||||
|
||||
+17
-6
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
|
||||
Reference in New Issue
Block a user