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()
bb_enable_warnings( msvc warnings-as-errors "/wd4996" )
# enable sse4.1 build for all source files for gcc and clang
if( UNIX )
if( UNIX OR MINGW )
add_compile_options( "-msse4.1" )
endif()
......
......@@ -20,16 +20,28 @@ TARGETS := CommonLib DecoderAnalyserApp DecoderAnalyserLib DecoderApp DecoderLib
TARGETS += EncoderApp EncoderLib Utilities SEIRemovalApp
ifeq ($(OS),Windows_NT)
PY := $(wildcard c:/windows/py.*)
ifeq ($(PY),)
PYTHON_LAUNCHER := python
ifneq ($(MSYSTEM),)
# MSYS runtime environment
UNAME_S := $(shell uname -s)
PYTHON_LAUNCHER := python3
BUILD_CMD := $(PYTHON_LAUNCHER) $(BUILD_SCRIPT)
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
# 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
UNAME_S := $(shell uname -s)
BUILD_CMD := $(BUILD_SCRIPT)
ifeq ($(UNAME_S),Linux)
endif
ifeq ($(UNAME_S),Darwin)
......@@ -48,7 +60,12 @@ CONFIG_OPTIONS += -g $(g)
endif
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
ifneq ($(address-model),)
......@@ -82,33 +99,33 @@ endif
BUILD_OPTIONS := $(CONFIG_OPTIONS) -b
debug:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug
$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug
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:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release
$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release
relwithdebinfo:
$(BUILD_SCRIPT) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo
$(BUILD_CMD) $(BUILD_JOBS) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo
clean:
# clean is equal to realclean to ensure that CMake options are reset
$(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:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target clean
$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=release --target clean
clean-d:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target clean
$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=debug --target clean
clean-p:
$(BUILD_SCRIPT) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target clean
$(BUILD_CMD) $(BUILD_OPTIONS) $(CMAKE_OPTIONS) variant=relwithdebinfo --target clean
configure:
$(BUILD_SCRIPT) $(CONFIG_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
$(BUILD_CMD) $(CONFIG_OPTIONS) $(CMAKE_OPTIONS) variant=debug,release,relwithdebinfo
#
# project specific targets
......@@ -126,28 +143,28 @@ TARGETS_DEBUG_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cd)
TARGETS_RELWITHDEBINFO_CLEAN_FIRST := $(foreach t,$(TARGETS),$(t)-cp)
$(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):
$(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):
$(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):
$(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):
$(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):
$(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):
$(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):
$(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:
$(RM) -rf bin build lib
......
NextSoftware build howto:
NextSoftware/VVCSoftware_VTM build howto:
The software uses cmake to create the needed build files.
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
of this project (location of README.txt).
......@@ -29,3 +43,23 @@ cmake .. -DCMAKE_BUILD_TYPE=Debug
MACOSX Xcode sample:
cd build
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
#
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)
#!/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.cmbuild.app.boost
app = pyhhi.cmbuild.app.boost.BoostInstallApp()
app = pyhhi.build.app.cmkdocapp.CMakeDocUtilApp()
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.cmbuild.app.androidapp
app = pyhhi.cmbuild.app.androidapp.CreateNdkToolchainApp()
app = pyhhi.build.app.cmbldup.CMakeBuildUpdateApp()
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
import argparse
......@@ -6,7 +7,9 @@ import os.path
import sys
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):
......@@ -19,6 +22,10 @@ class CMakeDocUtilApp(object):
def main(self, 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)
if params.update_action == 'add':
cmkdocutil.add_extension_modules(params.rst_module_filenm, params.extension_module_names,
......@@ -30,19 +37,28 @@ class CMakeDocUtilApp(object):
else:
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):
params = cmkdoc.CMakeRstUtilParams()
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",
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,
help="remove all non-standard module sections.")
parser.add_argument("-r", action="store_true", dest="remove", default=False,
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("-s", action="store", dest="section_title", default="Extension Modules",
help="specifies the section to be updated [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: %(default)s]")
parser.add_argument("--dry-run", action="store_true", dest="dry_run", default=False)
util.app_args_add_log_level(parser)
......@@ -52,9 +68,8 @@ class CMakeDocUtilApp(object):
# configure the python logger asap
util.app_configure_logging(args.log_level)
params = cmkdoc.CMakeRstUtilParams()
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:
params.update_action = 'add'
......@@ -64,8 +79,7 @@ class CMakeDocUtilApp(object):
elif args.remove:
params.update_action = 'remove'
else:
print("No update action specified, use -m, -R or -r.")
sys.exit(1)
raise InvalidCommandLineArgumentError("no update action specified, use -m, -R or -r.")
if args.section_title:
params.extension_section_title = args.section_title
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):
print("Launching: " + ' '.join(mk_toolchain_args))
# 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 os.path.exists(mk_toolchain_script):
......
......@@ -7,6 +7,7 @@ import platform
import re
import shutil
import subprocess
import sys
import tempfile
import textwrap
......@@ -15,36 +16,6 @@ import pyhhi.build.common.util as util
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):
......@@ -80,11 +51,6 @@ class MsvcRegistry(object):
self._do_inventory_vc141()
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):
if version is None:
version = self.get_latest_version()
......@@ -196,14 +162,7 @@ class MsvcRegistry(object):
versionf.write(textwrap.dedent("""\
#pragma message(_MSC_FULL_VER _MSC_BUILD)
""".format()))
python_version = ver.get_python_version()
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()
retv = subprocess.check_output([cl_cmd, '/EP', version_file], stderr=self._sys_info.get_subprocess_devnull(), universal_newlines=True).lstrip()
# 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)
if re_match:
......@@ -1283,7 +1242,7 @@ class FatBinaryTool(object):
# and launch lipo to create the universal binary file.
cmd_line = ' '.join(lipo_argv)
print("Launching: " + cmd_line)
retv = subprocess.call(lipo_argv)
retv = util.subproc_call_flushed(lipo_argv)
if retv != 0:
raise Exception("Creating a universal file failed -> " + cmd_line)
else:
......@@ -1386,7 +1345,7 @@ class DyLibInstallNameInfoInspector(object):
argv.append(depends_dict[key])
argv.append(dylib)
#print("modify_depends(): ", argv)
subprocess.check_call(argv)
util.subproc_check_call_flushed(argv)
def change_rpaths(self, dylib, rpaths_dict):
argv = ['install_name_tool']
......@@ -1396,7 +1355,7 @@ class DyLibInstallNameInfoInspector(object):
argv.append(rpaths_dict[key])
argv.append(dylib)
#print("change_rpaths(): ", argv)
subprocess.check_call(argv)
util.subproc_check_call_flushed(argv)
def delete_rpaths(self, dylib, rpath_list):
argv = ['install_name_tool']
......@@ -1405,36 +1364,26 @@ class DyLibInstallNameInfoInspector(object):
argv.append(rpath)
argv.append(dylib)
#print("change_rpaths(): ", argv)
subprocess.check_call(argv)
util.subproc_check_call_flushed(argv)
def modify_install_name(self, dylib, install_name):
argv = ['install_name_tool', '-id', install_name, dylib]
subprocess.check_call(argv)
util.subproc_check_call_flushed(argv)
class BuildScriptInstaller(object):
def __init__(self, top_dir=None, verbose=False):
def __init__(self, verbose=False):
self._logger = logging.getLogger(__name__)
# print("BuildScriptInstaller.__init__(): __name__=" + __name__)
self._verbose = verbose
self._sys_info = system.SystemInfo()
if top_dir is None:
top_dir = os.getcwd()
else:
assert os.path.exists(top_dir)
self._top_dir = top_dir
def set_verbose(self, verbose):
self._verbose = verbose
def get_top_dir(self):
return self._top_dir
def install_script(self, inst_dir, script, modules, rename=None):
def install_script(self, inst_dir, script, modules):
assert inst_dir is not None
script = os.path.abspath(script)
src_dir = os.path.dirname(script)
module_flist = []
package_dir_set = set()
# python modules are specified in import syntax like "<package>.<name>".
......@@ -1460,16 +1409,27 @@ class BuildScriptInstaller(object):
# make sure all files exist before trying to copy anything.
if not os.path.exists(script):
raise Exception("file " + script + " does not exist.")
# key = module_file_path, value = file system path
# e.g. pyhhi/build/common/ver.py must be mapped to a directory listed by sys.path.
module_flist_src_dict = {}
for f in module_flist:
fpath = os.path.join(src_dir, f)
if not os.path.exists(fpath):
raise Exception("file " + fpath + " does not exist.")
for pth in sys.path:
fpath = os.path.join(pth, f)
if os.path.exists(fpath):
module_flist_src_dict[f] = fpath
break
else:
fpath = None
if fpath is None:
raise Exception("module file {0} not found.".format(fpath))
# create destination directory
if not os.path.exists(inst_dir):
os.makedirs(inst_dir)
for f in module_flist:
fpath_src = os.path.join(src_dir, f)
assert f in module_flist_src_dict
fpath_src = module_flist_src_dict[f]
dname = os.path.dirname(f)
dst_dir = os.path.join(inst_dir, dname)
#print("cp " + fpath_src + " -> " + os.path.join(dst_dir, dname))
......@@ -1481,12 +1441,7 @@ class BuildScriptInstaller(object):
shutil.copy(fpath_src, dst_dir)
# copy the script to <inst_dir>
if rename is None:
if self._verbose:
print("copying %-15s %s" % (os.path.basename(script), inst_dir))
shutil.copy(script, inst_dir)
else:
if self._verbose:
print("copying %-15s %s" % (os.path.basename(script), os.path.join(inst_dir, rename)))
shutil.copy2(script, os.path.join(inst_dir, rename))
if self._verbose:
print("copying %-15s %s" % (os.path.basename(script), inst_dir))
shutil.copy(script, inst_dir)
#-- WARNING --
# This file is automatically generated by CMake.
# Any manual changes here will be overridden by the next build.
#-------------
CMAKE_BUILD_VERSION_STR = "3.13.0.2"
class BaseError(Exception):
"""Base exception with a hint whether to list traceback information or not.
Attributes:
msg -- explanation of the error
list_traceback -- hint to an application level exception handler whether to list traceback information or not.
"""
def __init__(self, msg, list_traceback=True):
self.msg = msg
self.list_traceback = list_traceback
def __str__(self):
return self.msg
class InvalidInputParameterError(BaseError):
"""Exception raised for invalid input parameters."""
def __init__(self, msg, list_traceback=False):
BaseError.__init__(self, msg, list_traceback)
class InvalidCommandLineArgumentError(BaseError):
"""Exception raised for invalid command line arguments."""
def __init__(self, msg, list_traceback=False):
BaseError.__init__(self, msg, list_traceback)
#
# Copyright:
# 2016 Fraunhofer Institute for Telecommunications, Heinrich-Hertz-Institut (HHI)
# The copyright of this software source code is the property of HHI.
# This software may be used and/or copied only with the written permission
# of HHI and in accordance with the terms and conditions stipulated
# in the agreement/contract under which the software has been supplied.