Commit 67208da2 authored by Karsten Suehring's avatar Karsten Suehring

Update cmake environment

- remove unnecessary build scripts
- allow MSYS32/64 build
- small feature improvements, e.g. allow targeting major compiler options for build parameters
parent 016e68f1
...@@ -96,7 +96,7 @@ endif() ...@@ -96,7 +96,7 @@ endif()
bb_enable_warnings( msvc warnings-as-errors "/wd4996" ) bb_enable_warnings( msvc warnings-as-errors "/wd4996" )
# enable sse4.1 build for all source files for gcc and clang # enable sse4.1 build for all source files for gcc and clang
if( UNIX ) if( UNIX OR MINGW )
add_compile_options( "-msse4.1" ) add_compile_options( "-msse4.1" )
endif() endif()
......
...@@ -20,16 +20,28 @@ TARGETS := CommonLib DecoderAnalyserApp DecoderAnalyserLib DecoderApp DecoderLib ...@@ -20,16 +20,28 @@ TARGETS := CommonLib DecoderAnalyserApp DecoderAnalyserLib DecoderApp DecoderLib
TARGETS += EncoderApp EncoderLib Utilities SEIRemovalApp TARGETS += EncoderApp EncoderLib Utilities SEIRemovalApp
ifeq ($(OS),Windows_NT) ifeq ($(OS),Windows_NT)
PY := $(wildcard c:/windows/py.*) ifneq ($(MSYSTEM),)
ifeq ($(PY),) # MSYS runtime environment
PYTHON_LAUNCHER := python UNAME_S := $(shell uname -s)
PYTHON_LAUNCHER := python3
BUILD_CMD := $(PYTHON_LAUNCHER) $(BUILD_SCRIPT)
else else
PYTHON_LAUNCHER := $(notdir $(PY)) UNAME_S := Windows
PY := $(wildcard c:/windows/py.*)
ifeq ($(PY),)
PYTHON_LAUNCHER := python
else
PYTHON_LAUNCHER := $(notdir $(PY))
endif
# If a plain cmake.py is used, the exit codes won't arrive in make; i.e. build failures are reported as success by make.
BUILD_CMD := $(PYTHON_LAUNCHER) $(BUILD_SCRIPT)
ifeq ($(toolset),gcc)
g := mgwmake
endif
endif endif
# If a plain cmake.py is used, the exit codes won't arrive in make; i.e. build failures are reported as success by make.
BUILD_SCRIPT := $(PYTHON_LAUNCHER) $(CURDIR)/cmake/CMakeBuild/bin/cmake.py
else else
UNAME_S := $(shell uname -s) UNAME_S := $(shell uname -s)
BUILD_CMD := $(BUILD_SCRIPT)
ifeq ($(UNAME_S),Linux) ifeq ($(UNAME_S),Linux)
endif endif
ifeq ($(UNAME_S),Darwin) ifeq ($(UNAME_S),Darwin)
...@@ -48,7 +60,12 @@ CONFIG_OPTIONS += -g $(g) ...@@ -48,7 +60,12 @@ CONFIG_OPTIONS += -g $(g)
endif endif
ifneq ($(toolset),) ifneq ($(toolset),)
CONFIG_OPTIONS += toolset=$(toolset) # aarch64 and mingw are two shortcuts to simplify toolset specification.
ifeq ($(toolset),mingw)
CONFIG_OPTIONS += toolset=x86_64-w64-mingw32-gcc-posix
else
CONFIG_OPTIONS += toolset=$(toolset)
endif
endif endif
ifneq ($(address-model),) ifneq ($(address-model),)
...@@ -82,33 +99,33 @@ endif ...@@ -82,33 +99,33 @@ endif
BUILD_OPTIONS := $(CONFIG_OPTIONS) -b BUILD_OPTIONS := $(CONFIG_OPTIONS) -b
debug: debug:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug
all: all:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
release: release:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release
relwithdebinfo: relwithdebinfo:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo
clean: clean:
# clean is equal to realclean to ensure that CMake options are reset # clean is equal to realclean to ensure that CMake options are reset
$(RM) -rf bin build lib $(RM) -rf bin build lib
# $(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target clean # $(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target clean
clean-r: clean-r:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target clean $(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target clean
clean-d: clean-d:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target clean $(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target clean
clean-p: clean-p:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target clean $(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target clean
configure: configure:
$(BUILD_SCRIPT) $(CONFIG_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo $(BUILD_CMD) $(CONFIG_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
# #
# project specific targets # project specific targets
...@@ -126,28 +143,28 @@ TARGETS_DEBUG_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cd) ...@@ -126,28 +143,28 @@ TARGETS_DEBUG_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cd)
TARGETS_RELWITHDEBINFO_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cp) TARGETS_RELWITHDEBINFO_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cp)
$(TARGETS_ALL): $(TARGETS_ALL):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target $(patsubst %-a,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --target $(patsubst %-a,%,$@)
$(TARGETS_ALL_CLEAN_FIRST): $(TARGETS_ALL_CLEAN_FIRST):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --clean-first --target $(patsubst %-ca,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo --clean-first --target $(patsubst %-ca,%,$@)
$(TARGETS_RELEASE): $(TARGETS_RELEASE):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target $(patsubst %-r,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target $(patsubst %-r,%,$@)
$(TARGETS_RELEASE_CLEAN_FIRST): $(TARGETS_RELEASE_CLEAN_FIRST):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --clean-first --target $(patsubst %-cr,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --clean-first --target $(patsubst %-cr,%,$@)
$(TARGETS_DEBUG): $(TARGETS_DEBUG):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-d,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-d,%,$@)
$(TARGETS_DEBUG_CLEAN_FIRST): $(TARGETS_DEBUG_CLEAN_FIRST):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-cd,%,$@) --clean-first $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target $(patsubst %-cd,%,$@) --clean-first
$(TARGETS_RELWITHDEBINFO): $(TARGETS_RELWITHDEBINFO):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-p,%,$@) $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-p,%,$@)
$(TARGETS_RELWITHDEBINFO_CLEAN_FIRST): $(TARGETS_RELWITHDEBINFO_CLEAN_FIRST):
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-cp,%,$@) --clean-first $(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target $(patsubst %-cp,%,$@) --clean-first
realclean: realclean:
$(RM) -rf bin build lib $(RM) -rf bin build lib
......
NextSoftware build howto: NextSoftware/VVCSoftware_VTM build howto:
The software uses cmake to create the needed build files. The software uses cmake to create the needed build files.
Download cmake: http://www.cmake.org/ and install it. Download cmake: http://www.cmake.org/ and install it.
Usage: =================== Windows only =======================
Python and gnuwin32 are not mandatory, but they simplifiy the build process for the user.
python: https://www.python.org/downloads/release/python-371/
gnuwin32: https://sourceforge.net/projects/getgnuwin32/files/getgnuwin32/0.6.30/GetGnuWin32-0.6.3.exe/download
To use MinGW, install MSYS2:
http://repo.msys2.org/distrib/msys2-x86_64-latest.exe
Installation instructions:
https://www.msys2.org/
and install the needed toolchains.
pacman -S --needed base-devel mingw-w64-i686-toolchain mingw-w64-x86_64-toolchain git subversion mingw-w64-i686-cmake mingw-w64-x86_64-cmake
========================================================
========= Build instructions for plain cmake ===========
Open a command prompt on your system and change into the root directory Open a command prompt on your system and change into the root directory
of this project (location of README.txt). of this project (location of README.txt).
...@@ -29,3 +43,23 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug ...@@ -29,3 +43,23 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug
MACOSX Xcode sample: MACOSX Xcode sample:
cd build cd build
cmake .. -G "Xcode" cmake .. -G "Xcode"
========================================================
============= Build instructions for make ==============
remark:
If you installed python and gnuwin32 on Windows operating systems,
you will be able to use make.
Open a command prompt on your system and change into the root directory
of this project (location of README.txt).
to use the default system compiler simply call:
make all
Using MSYS2 and MinGW:
Open an MSYS MinGW 64-Bit terminal and change into the root directory
of this project (location of README.txt).
Call:
make all toolset=gcc
========================================================
#!/usr/bin/env python #!/usr/bin/python
# #
# cmake.py # cmake.py
# #
import pyhhi.build.common.util import pyhhi.build.common.util
import pyhhi.cmbuild.app.cmk import pyhhi.build.app.cmk
app = pyhhi.cmbuild.app.cmk.CMakeLauncherApp() app = pyhhi.build.app.cmk.CMakeLauncherApp()
pyhhi.build.common.util.exec_main_default_try(app) pyhhi.build.common.util.exec_main_default_try(app)
#!/usr/bin/env python #!/usr/bin/python
# #
# boost_install.py # cmake_docutil.py
# #
import pyhhi.build.app.cmkdocapp
import pyhhi.build.common.util import pyhhi.build.common.util
import pyhhi.cmbuild.app.boost
app = pyhhi.cmbuild.app.boost.BoostInstallApp()
app = pyhhi.build.app.cmkdocapp.CMakeDocUtilApp()
pyhhi.build.common.util.exec_main_default_try(app) pyhhi.build.common.util.exec_main_default_try(app)
#!/usr/bin/env python #!/usr/bin/python
# #
# create_ndk_toolchain.py # cmakebuild_update.py
# #
import pyhhi.build.app.cmbldup
import pyhhi.build.common.util import pyhhi.build.common.util
import pyhhi.cmbuild.app.androidapp
app = pyhhi.cmbuild.app.androidapp.CreateNdkToolchainApp()
app = pyhhi.build.app.cmbldup.CMakeBuildUpdateApp()
pyhhi.build.common.util.exec_main_default_try(app) pyhhi.build.common.util.exec_main_default_try(app)
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
This diff is collapsed.
from __future__ import print_function from __future__ import print_function
import argparse import argparse
...@@ -6,7 +7,9 @@ import os.path ...@@ -6,7 +7,9 @@ import os.path
import sys import sys
import pyhhi.build.common.util as util import pyhhi.build.common.util as util
import pyhhi.cmbuild.cmkdoc as cmkdoc import pyhhi.build.cmkdoc as cmkdoc
from pyhhi.build.common.error import InvalidCommandLineArgumentError, InvalidInputParameterError
class CMakeDocUtilApp(object): class CMakeDocUtilApp(object):
...@@ -19,6 +22,10 @@ class CMakeDocUtilApp(object): ...@@ -19,6 +22,10 @@ class CMakeDocUtilApp(object):
def main(self, argv): def main(self, argv):
params = self._parse_command_line(argv) params = self._parse_command_line(argv)
self.update_cmake_manual_docs(params)
def update_cmake_manual_docs(self, params):
self._check_params(params)
cmkdocutil = cmkdoc.CMakeManualRstUtil(dry_run=params.dry_run) cmkdocutil = cmkdoc.CMakeManualRstUtil(dry_run=params.dry_run)
if params.update_action == 'add': if params.update_action == 'add':
cmkdocutil.add_extension_modules(params.rst_module_filenm, params.extension_module_names, cmkdocutil.add_extension_modules(params.rst_module_filenm, params.extension_module_names,
...@@ -30,19 +37,28 @@ class CMakeDocUtilApp(object): ...@@ -30,19 +37,28 @@ class CMakeDocUtilApp(object):
else: else:
assert False assert False
def _check_params(self, params):
assert params.rst_module_filenm is not None
if not os.path.exists(params.rst_module_filenm):
raise InvalidInputParameterError("CMake doc module file {} does not exist.".format(params.rst_module_filenm))
def _parse_command_line(self, argv): def _parse_command_line(self, argv):
params = cmkdoc.CMakeRstUtilParams()
parser = argparse.ArgumentParser() parser = argparse.ArgumentParser()
parser.add_argument("input", action="store", help="specifies the CMake RST module file to be updated.")
parser.add_argument("-m", action="append", dest="module_names", parser.add_argument("-m", action="append", dest="module_names",
help="specifies an extension module name, the option must be repeated for each extension module.") help="specifies an extension module name, the option must be repeated for each extension module.")
parser.add_argument("-R", action="store_true", dest="remove_all", default=False, parser.add_argument("-R", action="store_true", dest="remove_all", default=False,
help="remove all non-standard module sections.") help="remove all non-standard module sections.")
parser.add_argument("-r", action="store_true", dest="remove", default=False, parser.add_argument("-r", action="store_true", dest="remove", default=False,
help="remove a single non-standard module section.") help="remove a single non-standard module section.")
parser.add_argument("-f", action="store", dest="rst_filenm", required=True,
help="specifies the CMake RST file to be updated.")
parser.add_argument("-o", action="store", dest="output_rst_filenm") parser.add_argument("-o", action="store", dest="output_rst_filenm")
parser.add_argument("-s", action="store", dest="section_title", default="Extension Modules", parser.add_argument("-s", action="store", dest="section_title", default=params.extension_section_title,
help="specifies the section to be updated [default: Extension Modules]") help="specifies the section to be updated [default: %(default)s]")
parser.add_argument("--dry-run", action="store_true", dest="dry_run", default=False) parser.add_argument("--dry-run", action="store_true", dest="dry_run", default=False)
util.app_args_add_log_level(parser) util.app_args_add_log_level(parser)
...@@ -52,9 +68,8 @@ class CMakeDocUtilApp(object): ...@@ -52,9 +68,8 @@ class CMakeDocUtilApp(object):
# configure the python logger asap # configure the python logger asap
util.app_configure_logging(args.log_level) util.app_configure_logging(args.log_level)
params = cmkdoc.CMakeRstUtilParams()
params.dry_run = args.dry_run params.dry_run = args.dry_run
params.rst_module_filenm = os.path.abspath(args.rst_filenm) params.rst_module_filenm = os.path.abspath(args.input)
if args.module_names: if args.module_names:
params.update_action = 'add' params.update_action = 'add'
...@@ -64,8 +79,7 @@ class CMakeDocUtilApp(object): ...@@ -64,8 +79,7 @@ class CMakeDocUtilApp(object):
elif args.remove: elif args.remove:
params.update_action = 'remove' params.update_action = 'remove'
else: else:
print("No update action specified, use -m, -R or -r.") raise InvalidCommandLineArgumentError("no update action specified, use -m, -R or -r.")
sys.exit(1)
if args.section_title: if args.section_title:
params.extension_section_title = args.section_title params.extension_section_title = args.section_title
if args.output_rst_filenm: if args.output_rst_filenm:
......
from __future__ import print_function
import logging
import os
import re
import subprocess
import pyhhi.build.common.util as util
import pyhhi.build.common.ver as ver
from pyhhi.build.common.system import SystemInfo
class CMakeFinder(object):
def __init__(self, sys_info=None):
self._logger = logging.getLogger(__name__)
if sys_info is None:
self._sys_info = SystemInfo()
else:
self._sys_info = sys_info
self._cmake_prog = None
self._cmake_version = None
self._cmake_search_path = self._sys_info.get_path()
if self._sys_info.is_windows():
cmake_dir_list = []
cmake_inst_dir = self._query_winreg_cmake_inst_dir()
if cmake_inst_dir is None:
# cmake 3.6.1 is 64 bit but earlier cmake versions are 32 bit only.
if self._sys_info.get_os_arch() == 'x86_64':
cmake_dir_list.append(os.path.join(self._sys_info.get_program_dir('x86_64'), 'CMake', 'bin'))
cmake_dir_list.append(os.path.join(self._sys_info.get_program_dir('x86'), 'CMake', 'bin'))
for cmake_dir in cmake_dir_list:
if os.path.exists(cmake_dir):
if cmake_dir not in self._cmake_search_path:
self._cmake_search_path.append(cmake_dir)
else:
# Append cmake install directory picked up from the registry (3.8.0 or higher).
self._cmake_search_path.append(cmake_inst_dir)
elif self._sys_info.is_macosx():
# The default installation path is /Applications/CMake.app/Contents/bin on MacOSX.
cmake_dir = os.path.join('/Applications', 'CMake.app', 'Contents', 'bin')
if os.path.exists(cmake_dir):
if cmake_dir not in self._cmake_search_path:
self._cmake_search_path.append(cmake_dir)
elif self._sys_info.is_linux():
pass
else:
assert False
def set_cmake_search_path(self, search_path):
if search_path:
self._cmake_search_path = search_path[:]
self._logger.debug("cmake search path changed to: %s", ';'.join(self._cmake_search_path))
def find_cmake(self):
"""Returns the absolute path of a cmake executable."""
if self._cmake_prog is None:
self._logger.debug("cmake search path: %s", ';'.join(self._cmake_search_path))
self._cmake_prog = util.find_tool_on_path('cmake', must_succeed=True, search_path=self._cmake_search_path)
self._cmake_version = self._query_cmake_version(self._cmake_prog)
return self._cmake_prog
def is_cmake_installed(self):
return self.find_cmake() is not None
def get_cmake_version(self):
assert self._cmake_version is not None
return self._cmake_version
def _query_cmake_version(self, cmake_cmd):
retv = subprocess.check_output([cmake_cmd, '--version'], universal_newlines=True)
return self._parse_cmake_version_retv(retv)
def _parse_cmake_version_retv(self, retv):
version_response = retv.rstrip()
lines = version_response.splitlines()
# Possible version information:
# cmake version 3.7.2
# cmake version 3.8.0-rc2
# cmake3 version 3.6.3 # redhat 7.x cmake3
re_version_match = re.match(r'cmake\d*\s+version\s+([0-9]+\.[0-9]+\.[0-9]+)', lines[0], re.IGNORECASE)
if not re_version_match:
raise Exception("cmake has returned an unsupported version string. Please contact technical support.")
self._logger.debug("cmake version: %s", re_version_match.group(1))
return ver.version_tuple_from_str(re_version_match.group(1))
def _query_winreg_cmake_inst_dir(self):
cmake_install_dir = None
if self._sys_info.is_python3():
import winreg
win_registry = winreg
else:
import _winreg
win_registry = _winreg
reg_section = "SOFTWARE\\Kitware\\CMake"
try:
# rkey must be initialized in case OpenKey() does not return but raises an exception.
rkey = None
rkey = win_registry.OpenKey(win_registry.HKEY_LOCAL_MACHINE, reg_section)
install_dir = win_registry.QueryValueEx(rkey, 'InstallDir')[0]
if os.path.exists(os.path.join(install_dir, 'bin', 'cmake.exe')):
cmake_install_dir = os.path.join(install_dir, 'bin')
except WindowsError:
if rkey is not None:
win_registry.CloseKey(rkey)
if cmake_install_dir:
self._logger.debug("cmake install dir (winreg): %s", cmake_install_dir)
else:
self._logger.debug("cmake install dir (winreg): %s", "not found")
return cmake_install_dir
File mode changed from 100644 to 100755
...@@ -134,7 +134,7 @@ class NdkFinder(object): ...@@ -134,7 +134,7 @@ class NdkFinder(object):
print("Launching: " + ' '.join(mk_toolchain_args)) print("Launching: " + ' '.join(mk_toolchain_args))
# and launch the script to create the new toolchain # and launch the script to create the new toolchain
subprocess.check_call(mk_toolchain_args) util.subproc_check_call_flushed(mk_toolchain_args)
if hash_bang_missing: if hash_bang_missing:
if os.path.exists(mk_toolchain_script): if os.path.exists(mk_toolchain_script):
......
...@@ -7,6 +7,7 @@ import platform ...@@ -7,6 +7,7 @@ import platform
import re import re
import shutil import shutil
import subprocess import subprocess
import sys
import tempfile import tempfile
import textwrap import textwrap
...@@ -15,36 +16,6 @@ import pyhhi.build.common.util as util ...@@ -15,36 +16,6 @@ import pyhhi.build.common.util as util
import pyhhi.build.common.ver as ver import pyhhi.build.common.ver as ver
class MsvcToolsetSpecDict(object):
def __init__(self):
# Mapping between CMake VC toolsets and Boost.Build VC toolsets if unique.
# VS 2017 updates cl to 19.11.x whereas Boost.Build detects 19.10.x and 19.11.x as msvc-14.1, hence
# no mapping anymore.
self._dict_cmake_msvc_bbuild_msvc = {'msvc-19.0': 'msvc-14.0',
'msvc-18.0': 'msvc-12.0',
'msvc-17.0': 'msvc-11.0',
'msvc-16.0': 'msvc-10.0'}
# Mapping between Boost.Build VC toolsets and CMake VC toolsets.
self._dict_bbuild_msvc_cmake_msvc = {'msvc-14.0': 'msvc-19.0',
'msvc-12.0': 'msvc-18.0',
'msvc-11.0': 'msvc-17.0',
'msvc-10.0': 'msvc-16.0'}
def transform_bbuild_to_cmake(self, toolset):
if toolset in self._dict_bbuild_msvc_cmake_msvc:
return self._dict_bbuild_msvc_cmake_msvc[toolset]
else:
return toolset
def transform_cmake_to_bbuild(self, toolset):
if toolset in self._dict_cmake_msvc_bbuild_msvc:
return self._dict_cmake_msvc_bbuild_msvc[toolset]
else:
return toolset
class MsvcRegistry(object): class MsvcRegistry(object):
class __MsvcRegistry(object): class __MsvcRegistry(object):
...@@ -80,11 +51,6 @@ class MsvcRegistry(object): ...@@ -80,11 +51,6 @@ class MsvcRegistry(object):
self._do_inventory_vc141() self._do_inventory_vc141()
self._do_inventory() self._do_inventory()
def _get_devnull(self):
if not hasattr(self, '_devnull'):
self._devnull = os.open(os.devnull, os.O_RDWR)
return self._devnull
def get_compiler_command(self, version=None): def get_compiler_command(self, version=None):
if version is None: if version is None:
version = self.get_latest_version() version = self.get_latest_version()
...@@ -196,14 +162,7 @@ class MsvcRegistry(object): ...@@ -196,14 +162,7 @@ class MsvcRegistry(object):
versionf.write(textwrap.dedent("""\ versionf.write(textwrap.dedent("""\
#pragma message(_MSC_FULL_VER _MSC_BUILD) #pragma message(_MSC_FULL_VER _MSC_BUILD)
""".format())) """.format()))
python_version = ver.get_python_version() retv = subprocess.check_output([cl_cmd, '/EP', version_file], stderr=self._sys_info.get_subprocess_devnull(), universal_newlines=True).lstrip()
if ver.version_compare(python_version, (3,3)) >= 0:
# subprocess.DEVNULL since python 3.3
retv = subprocess.check_output([cl_cmd, '/EP', version_file], stderr=subprocess.DEVNULL, universal_newlines=True).lstrip()
else:
self._logger.debug("attribute subprocess.DEVNULL not available (python < 3.3), using os.devnull instead")
devnull = self._get_devnull()
retv = subprocess.check_output([cl_cmd, '/EP', version_file], stderr=devnull, universal_newlines=True).lstrip()
# print("_query_msvc_compiler_versionf(): retv=" + retv) # print("_query_msvc_compiler_versionf(): retv=" + retv)
re_match = re.match(r'#pragma\s+message\(([0-9][0-9])([0-9][0-9])([0-9]+)\s+([0-9]+)\)', retv) re_match = re.match(r'#pragma\s+message\(([0-9][0-9])([0-9][0-9])([0-9]+)\s+([0-9]+)\)', retv)
if re_match: if re_match:
...@@ -1283,7 +1242,7 @@ class FatBinaryTool(object): ...@@ -1283,7 +1242,7 @@ class FatBinaryTool(object):
# and launch lipo to create the universal binary file. # and launch lipo to create the universal binary file.
cmd_line = ' '.join(lipo_argv) cmd_line = ' '.join(lipo_argv)
print("Launching: " + cmd_line) print("Launching: " + cmd_line)
retv = subprocess.call(lipo_argv) retv = util.subproc_call_flushed(lipo_argv)
if retv != 0: if retv != 0:
raise Exception("Creating a universal file failed -> " + cmd_line) raise Exception("Creating a universal file failed -> " + cmd_line)
else: else:
...@@ -1386,7 +1345,7 @@ class DyLibInstallNameInfoInspector(object): ...@@ -1386,7 +1345,7 @@ class DyLibInstallNameInfoInspector(object):
argv.append(depends_dict[key]) argv.append(depends_dict[key])
argv.append(dylib) argv.append(dylib)
#print("modify_depends(): ", argv) #print("modify_depends(): ", argv)
subprocess.check_call(argv) util.subproc_check_call_flushed(argv)
def change_rpaths(self, dylib, rpaths_dict): def change_rpaths(self, dylib, rpaths_dict):
argv = ['install_name_tool'] argv = ['install_name_tool']
...@@ -1396,7 +1355,7 @@ class DyLibInstallNameInfoInspector(object): ...@@ -1396,7 +1355,7 @@ class DyLibInstallNameInfoInspector(object):
argv.append(rpaths_dict[key]) argv.append(rpaths_dict[key])
argv.append(dylib) argv.append(dylib)
#print("change_rpaths(): ", argv) #print("change_rpaths(): ", argv)
subprocess.check_call(argv) util.subproc_check_call_flushed(argv)
def delete_rpaths(self, dylib, rpath_list): def delete_rpaths(self, dylib, rpath_list):
argv = ['install_name_tool'] argv = ['install_name_tool']
...@@ -1405,36 +1364,26 @@ class DyLibInstallNameInfoInspector(object): ...@@ -1405,36 +1364,26 @@ class DyLibInstallNameInfoInspector(object):
argv.append(rpath) argv.append(rpath)
argv.append(dylib) argv.append(dylib)
#print("change_rpaths(): ", argv)