Commit 4c58be55 authored by Marcel Huber's avatar Marcel Huber
Browse files

enhanced binary dist target setup

- fixes bug that we cannot easily change lib versions
- less prone to errors when different versions of libs have different
  dependencies
- consolidated structure of build files
parent 1682d98e
......@@ -10,8 +10,8 @@
# -------------------------------------------------------------------------
import pkg_resources
pkg_resources.require(["SConsider"])
from SomeUtils import listFiles
Import('*')
_sconsider_dist = pkg_resources.get_distribution("SConsider").parsed_version
......@@ -21,55 +21,78 @@ else:
from SConsider.PackageRegistry import PackageRegistry
createFulltargetname = PackageRegistry.createFulltargetname
INCLUDE_TARGET_NAME = 'include'
TARGET_LIBS_AND_HEADERS = [(INCLUDE_TARGET_NAME, 'include', 'boost/version.hpp', 'CXX'),
('regex', 'boost_regex', 'boost/regex.h', 'CXX'),
('system', 'boost_system', 'boost/system/error_code.hpp', 'CXX')]
if _sconsider_dist < pkg_resources.parse_version("0.5"):
from SConsider import createTargets
from SConsider.PackageRegistry import PackageRegistry
buildSettings = {
'include': {
'public': {
'includeSubdir': '',
},
},
'regex': {
'targetType': 'LibraryShared',
'targetName': packagename + '_regex',
'linkDependencies': [
# used to pass public include dirs of boost
PackageRegistry.createFulltargetname(packagename, 'include'),
],
'sourceFiles': listFiles(['libs/regex/src/*.cpp']),
# 'appendUnique' : {
# 'CPPDEFINES' : ['BOOST_HAS_ICU=1'],
# 'LIBS' : ['icui18n','icuuc'],
# },
},
'system': {
'targetType': 'LibraryShared',
'targetName': packagename + '_system',
'linkDependencies': [
# used to pass public include dirs of boost
PackageRegistry.createFulltargetname(packagename, 'include'),
],
'sourceFiles': listFiles(['libs/system/src/*.cpp']),
},
}
from SConsider import cloneBaseEnv, createTargets
from SomeUtils import listFiles
from os import path
buildSettings = {packagename: {'linkDependencies': [], 'requires': []}}
_package_link_dependencies = buildSettings.get(packagename, {}).get('linkDependencies', [])
_package_requires = buildSettings.get(packagename, {}).get('requires', [])
env = cloneBaseEnv()
for _target_name, _real_libname_or_subdir, _headerfile, _lang in TARGET_LIBS_AND_HEADERS:
_lib_targetname = '_'.join(['lib', _target_name])
if _target_name == INCLUDE_TARGET_NAME:
buildSettings[_target_name] = {
'public': {
'includeSubdir': _real_libname_or_subdir,
},
}
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
else:
buildSettings[_lib_targetname] = {
'targetType': 'LibraryShared',
'targetName': _real_libname_or_subdir,
'sourceFiles': listFiles([path.join('libs', _target_name, 'src', '*.cpp')]),
'appendUnique': {},
'linkDependencies': [
createFulltargetname(packagename, INCLUDE_TARGET_NAME), # pass public include dirs
],
'public': {
'appendUnique': {},
},
}
# alias to prefixed target
buildSettings[_target_name] = {
'linkDependencies': [
createFulltargetname(packagename, _lib_targetname),
],
}
# add default link dependency to package target if needed
if False:
_package_link_dependencies.append(createFulltargetname(packagename, _lib_targetname))
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
# additional flag settings if required
if _target_name == 'regex' and False:
buildSettings[_lib_targetname]['appendUnique']['CPPDEFINES'] = ['BOOST_HAS_ICU=1']
buildSettings[_lib_targetname]['appendUnique']['LIBS'] = ['icui18n', 'icuuc']
createTargets(packagename, buildSettings)
elif _sconsider_dist >= pkg_resources.parse_version("0.5"):
from TargetMaker import EnvBuilder
from SomeUtils import listFiles
from os import path
from TargetHelpers import createPackageSharedLibrary
from TargetMaker import EnvBuilder
includeTarget = EnvBuilder(export=[EnvBuilder().include(Dir('.'))]).build().RegisterPackageTarget(
packagename=packagename, targetname='include')
all_libs = []
for libname in ['regex', 'system']:
for _target_name in ['regex', 'system']:
shared_lib = createPackageSharedLibrary(packagename,
'boost_' + libname,
listFiles(['libs/' + libname + '/src/*.cpp']),
'boost_' + _target_name,
listFiles([path.join('libs', _target_name, 'src', '*.cpp')]),
depend=[includeTarget])
# register lib with backward compatibility name
EnvBuilder().depend(shared_lib).build().RegisterPackageTarget(packagename=packagename,
targetname=libname)
targetname=_target_name)
all_libs.append(shared_lib)
libs = EnvBuilder().depend(all_libs).build().RegisterPackageTarget(packagename=packagename,
......
......@@ -10,6 +10,7 @@
# -------------------------------------------------------------------------
import pkg_resources
pkg_resources.require(["SConsider"])
Import('*')
......@@ -20,47 +21,66 @@ else:
from SConsider.PackageRegistry import PackageRegistry
createFulltargetname = PackageRegistry.createFulltargetname
INCLUDE_TARGET_NAME = 'include'
TARGET_LIBS_AND_HEADERS = [(INCLUDE_TARGET_NAME, 'include', 'boost/version.hpp', 'CXX'),
('regex', 'boost_regex', 'boost/regex.h', 'CXX'),
('system', 'boost_system', 'boost/system/error_code.hpp', 'CXX')]
if _sconsider_dist < pkg_resources.parse_version("0.5"):
from ConfigureHelper import Configure
from SConsider import createTargets, cloneBaseEnv
env = cloneBaseEnv()
conf = Configure(env)
if conf.CheckCXXHeader('boost/version.hpp'):
conf.env.Append(CPPDEFINES='HAS_BOOST')
if conf.CheckLibWithHeader('boost_regex', 'boost/regex.h', 'CXX'):
conf.env.Append(CPPDEFINES='HAS_BOOST_REGEX')
if conf.CheckLibWithHeader('boost_system', 'boost/system/error_code.hpp', 'CXX'):
conf.env.Append(CPPDEFINES='HAS_BOOST_SYSTEM')
env = conf.Finish()
buildSettings = {}
if 'HAS_BOOST' in env['CPPDEFINES']:
buildSettings['include'] = {}
from SConsider import cloneBaseEnv, createTargets
if 'HAS_BOOST_REGEX' in env['CPPDEFINES']:
buildSettings['regex'] = {
'public': {
'appendUnique': {
'LIBS': ['boost_regex'],
},
},
}
buildSettings = {packagename: {'linkDependencies': [], 'requires': []}}
_package_link_dependencies = buildSettings.get(packagename, {}).get('linkDependencies', [])
_package_requires = buildSettings.get(packagename, {}).get('requires', [])
if 'HAS_BOOST_SYSTEM' in env['CPPDEFINES']:
buildSettings['system'] = {
'public': {
'appendUnique': {
'LIBS': ['boost_system'],
},
},
}
env = cloneBaseEnv()
conf = Configure(env)
for _target_name, _real_libname_or_subdir, _headerfile, _lang in TARGET_LIBS_AND_HEADERS:
_lib_targetname = '_'.join(['lib', _target_name])
if _target_name == INCLUDE_TARGET_NAME:
if conf.CheckHeader(_headerfile, include_quotes='""', language=_lang):
buildSettings[_target_name] = {
'public': {},
}
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
else:
if conf.CheckLibWithHeader(_real_libname_or_subdir, _headerfile, _lang):
buildSettings[_lib_targetname] = {
'appendUnique': {},
'linkDependencies': [
createFulltargetname(packagename, INCLUDE_TARGET_NAME), # pass public include dirs
],
'public': {
'appendUnique': {
'LIBS': [_real_libname_or_subdir],
},
},
}
# alias to prefixed target
buildSettings[_target_name] = {
'linkDependencies': [
createFulltargetname(packagename, _lib_targetname),
],
}
# add default link dependency to package target if needed
if False:
_package_link_dependencies.append(createFulltargetname(packagename, _lib_targetname))
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
# add default requires if needed
if False:
_package_requires.append(createFulltargetname(packagename, _lib_targetname))
env = conf.Finish()
createTargets(packagename, buildSettings)
elif _sconsider_dist >= pkg_resources.parse_version("0.5"):
from TargetMaker import EnvBuilder
from ThirdParty import add_3rdparty_system_lib_target, add_3rdparty_system_header_target
from ThirdParty import add_3rdparty_system_header_target, add_3rdparty_system_lib_target
includeTarget = add_3rdparty_system_header_target(EnvBuilder().build(), packagename,
lambda conf: conf.CheckCHeader('boost/version.hpp'))
lambda conf: conf.CheckCXXHeader('boost/version.hpp'))
libnames = [('boost_regex', 'lib_boost_regex'), ('boost_system', 'lib_boost_system')]
libs = add_3rdparty_system_lib_target(EnvBuilder().depend(includeTarget).build(), packagename,
......
......@@ -10,6 +10,7 @@
# -------------------------------------------------------------------------
import pkg_resources
pkg_resources.require(["SConsider"])
Import('*')
......@@ -20,56 +21,91 @@ else:
from SConsider.PackageRegistry import PackageRegistry
createFulltargetname = PackageRegistry.createFulltargetname
INCLUDE_TARGET_NAME = 'include'
TARGET_LIBS_AND_HEADERS = [(INCLUDE_TARGET_NAME, 'include', 'openssl/ssl.h', 'C'),
('ssl', 'ssl', 'openssl/ssl.h', 'C'), ('crypto', 'crypto', 'openssl/ssl.h', 'C')]
if _sconsider_dist < pkg_resources.parse_version("0.5"):
from SConsider import createTargets
from ThirdParty import getBinaryDistDir
buildSettings = {
packagename: {
'linkDependencies': [
packagename + '.lib_ssl',
packagename + '.lib_crypto',
],
'targetType': 'IncludeOnly',
'public': {
'includeSubdir': 'include',
},
},
'lib_ssl': {
'sourceFiles': [getBinaryDistDir(packagename).File('ssl')],
'targetType': 'PrecompiledLibrary',
},
'lib_crypto': {
'sourceFiles': [getBinaryDistDir(packagename).File('crypto')],
'targetType': 'PrecompiledLibrary',
},
'opensslbin': {
'sourceFiles': [getBinaryDistDir(packagename).File('openssl')],
from ThirdParty import (
getBinaryDistDir,
determine_3rdparty_bin_node,
determine_3rdparty_lib_node,
)
from SConsider import cloneBaseEnv, createTargets
buildSettings = {packagename: {'linkDependencies': [], 'requires': []}}
_package_link_dependencies = buildSettings.get(packagename, {}).get('linkDependencies', [])
_package_requires = buildSettings.get(packagename, {}).get('requires', [])
env = cloneBaseEnv()
for _target_name, _real_libname_or_subdir, _headerfile, _lang in TARGET_LIBS_AND_HEADERS:
_lib_targetname = '_'.join(['lib', _target_name])
if _target_name == INCLUDE_TARGET_NAME:
buildSettings[_target_name] = {
'public': {
'includeSubdir': _real_libname_or_subdir,
},
}
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
else:
_checked_library = determine_3rdparty_lib_node(env, _real_libname_or_subdir,
getBinaryDistDir(packagename))
if _checked_library:
buildSettings[_lib_targetname] = {
'targetType': 'PrecompiledLibrary',
'sourceFiles': [getBinaryDistDir(packagename).File(_real_libname_or_subdir)],
'appendUnique': {},
'linkDependencies': [
createFulltargetname(packagename, INCLUDE_TARGET_NAME), # pass public include dirs
],
'public': {},
}
# alias to prefixed target
buildSettings[_target_name] = {
'linkDependencies': [
createFulltargetname(packagename, _lib_targetname),
],
}
_package_link_dependencies.append(createFulltargetname(packagename, _lib_targetname))
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
_executable_name = 'openssl'
_checked_executable = determine_3rdparty_bin_node(env, _executable_name, getBinaryDistDir(packagename))
if _checked_executable:
_bin_targetname = '_'.join(['bin', _executable_name])
buildSettings[_bin_targetname] = {
'targetType': 'PrecompiledBinary',
},
'openSSL': {
'sourceFiles': [getBinaryDistDir(packagename).File(_executable_name)],
}
_script_targetname = '_'.join(['script', _executable_name])
buildSettings[_script_targetname] = {
'targetType': 'ProgramApp',
'runConfig': {},
'requires': [
packagename + '.lib_ssl',
packagename + '.lib_crypto',
createFulltargetname(packagename, 'lib_ssl'),
createFulltargetname(packagename, 'lib_crypto'),
],
'usedTarget': packagename + '.opensslbin',
},
'script_openssl': {
'targetType': 'ProgramApp',
'usedTarget': createFulltargetname(packagename, _bin_targetname),
'runConfig': {},
'requires': [
packagename + '.lib_ssl',
packagename + '.lib_crypto',
}
# alias to prefixed targets
_script_target_aliasname = 'openSSL'
buildSettings[_script_target_aliasname] = {
'linkDependencies': [
createFulltargetname(packagename, _script_targetname),
],
'usedTarget': packagename + '.opensslbin',
},
}
}
createTargets(packagename, buildSettings)
elif _sconsider_dist >= pkg_resources.parse_version("0.5"):
from TargetHelpers import (
createPackageProgramScripts,
createPackageRunTarget,
installPrecompiledBinaries,
installPrecompiledLibraries,
)
from TargetMaker import EnvBuilder
from TargetHelpers import createPackageRunTarget, createPackageProgramScripts, installPrecompiledBinaries, installPrecompiledLibraries
includeTarget = EnvBuilder(export=[EnvBuilder().include(Dir('include'))]).build().RegisterPackageTarget(
packagename=packagename, targetname='include')
......
......@@ -10,6 +10,7 @@
# -------------------------------------------------------------------------
import pkg_resources
pkg_resources.require(["SConsider"])
Import('*')
......@@ -20,59 +21,94 @@ else:
from SConsider.PackageRegistry import PackageRegistry
createFulltargetname = PackageRegistry.createFulltargetname
INCLUDE_TARGET_NAME = 'include'
TARGET_LIBS_AND_HEADERS = [(INCLUDE_TARGET_NAME, 'include', 'openssl/ssl.h', 'C'),
('ssl', 'ssl', 'openssl/ssl.h', 'C'), ('crypto', 'crypto', 'openssl/ssl.h', 'C')]
if _sconsider_dist < pkg_resources.parse_version("0.5"):
from ConfigureHelper import Configure
from SConsider import createTargets, cloneBaseEnv
from SConsider import cloneBaseEnv, createTargets
buildSettings = {packagename: {'linkDependencies': [], 'requires': []}}
_package_link_dependencies = buildSettings.get(packagename, {}).get('linkDependencies', [])
_package_requires = buildSettings.get(packagename, {}).get('requires', [])
env = cloneBaseEnv()
conf = Configure(env)
if conf.CheckLibWithHeader('ssl', 'openssl/ssl.h', 'C') and conf.CheckLib('crypto'):
conf.env.Append(CPPDEFINES='HAS_OPENSSL')
opensslbin = conf.CheckExecutable('openssl')
env = conf.Finish()
buildSettings = {}
if 'HAS_OPENSSL' in env['CPPDEFINES']:
buildSettings[packagename] = {
'linkDependencies': [
packagename + '.lib_ssl',
packagename + '.lib_crypto',
],
for _target_name, _real_libname_or_subdir, _headerfile, _lang in TARGET_LIBS_AND_HEADERS:
_lib_targetname = '_'.join(['lib', _target_name])
if _target_name == INCLUDE_TARGET_NAME:
if conf.CheckHeader(_headerfile, include_quotes='""', language=_lang):
buildSettings[_target_name] = {
'public': {},
}
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
else:
if conf.CheckLibWithHeader(_real_libname_or_subdir, _headerfile, _lang):
buildSettings[_lib_targetname] = {
'appendUnique': {},
'linkDependencies': [
createFulltargetname(packagename, INCLUDE_TARGET_NAME), # pass public include dirs
],
'public': {
'appendUnique': {
'LIBS': [_real_libname_or_subdir],
},
},
}
# alias to prefixed target
buildSettings[_target_name] = {
'linkDependencies': [
createFulltargetname(packagename, _lib_targetname),
],
}
# add default link dependency to package target if needed
if True:
_package_link_dependencies.append(createFulltargetname(packagename, _lib_targetname))
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
# add default requires if needed
if False:
_package_requires.append(createFulltargetname(packagename, _lib_targetname))
_executable_name = 'openssl'
_checked_executable = conf.CheckExecutable(_executable_name)
if _checked_executable:
_bin_targetname = '_'.join(['bin', _executable_name])
buildSettings[_bin_targetname] = {
'targetType': 'InstallBinary',
'sourceFiles': [_checked_executable],
}
buildSettings['lib_ssl'] = {
'public': {
'appendUnique': {
'LIBS': ['ssl'],
},
},
_script_targetname = '_'.join(['script', _executable_name])
buildSettings[_script_targetname] = {
'targetType': 'ProgramApp',
'requires': [
createFulltargetname(packagename, 'lib_ssl'),
createFulltargetname(packagename, 'lib_crypto'),
],
'usedTarget': createFulltargetname(packagename, _bin_targetname),
'runConfig': {},
}
buildSettings['lib_crypto'] = {
'public': {
'appendUnique': {
'LIBS': ['crypto'],
},
},
# alias to prefixed targets
_script_target_aliasname = 'openSSL'
buildSettings[_script_target_aliasname] = {
'linkDependencies': [
createFulltargetname(packagename, _script_targetname),
],
}
if opensslbin:
buildSettings['opensslbin'] = {
'sourceFiles': [opensslbin],
'targetType': 'InstallBinary',
}
buildSettings['openSSL'] = {
'targetType': 'ProgramApp',
'runConfig': {},
'requires': [
packagename + '.lib_ssl',
packagename + '.lib_crypto',
],
'usedTarget': packagename + '.opensslbin',
}
buildSettings['script_openssl'] = buildSettings['openSSL']
env = conf.Finish()
createTargets(packagename, buildSettings)
elif _sconsider_dist >= pkg_resources.parse_version("0.5"):
from TargetMaker import EnvBuilder
from ThirdParty import add_3rdparty_system_lib_target, add_3rdparty_system_header_target, add_3rdparty_system_binary_target
from TargetHelpers import createPackageProgramScript, createPackageRunTarget
from TargetMaker import EnvBuilder
from ThirdParty import (
add_3rdparty_system_binary_target,
add_3rdparty_system_header_target,
add_3rdparty_system_lib_target,
)
includeTarget = add_3rdparty_system_header_target(EnvBuilder().build(), packagename,
lambda conf: conf.CheckCHeader('openssl/ssl.h'))
......
......@@ -10,6 +10,7 @@
# -------------------------------------------------------------------------
import pkg_resources
pkg_resources.require(["SConsider"])
Import('*')
......@@ -20,110 +21,125 @@ else:
from SConsider.PackageRegistry import PackageRegistry
createFulltargetname = PackageRegistry.createFulltargetname
INCLUDE_TARGET_NAME = 'include'
TARGET_LIBS_AND_HEADERS = [
(INCLUDE_TARGET_NAME, 'include', 'oci.h', 'C'),
('occi', 'occi', 'oci.h', 'C'),
('clntshcore', 'clntshcore', 'oci.h', 'C'),
('clntsh', 'clntsh', 'oci.h', 'C'),
('nnz', 'nnz', 'oci.h', 'C'),
('ociicus', 'ociicus', 'oci.h', 'C'), # oci library supporting us character sets
('ociei', 'ociei', 'oci.h', 'C'), # oci library supporting all character sets
('sqlplus', 'sqlplus', 'oci.h', 'C'),
('sqlplusic', 'sqlplusic', 'oci.h', 'C'),
]
if _sconsider_dist < pkg_resources.parse_version("0.5"):
from SConsider import createTargets
from ThirdParty import getBinaryDistDir
buildSettings = {
packagename: {
'linkDependencies': [
packagename + '.lib_nnz',
packagename + '.lib_clntsh',
],
'requires': [
packagename + '.lib_ociicus',
],
'targetType': 'IncludeOnly',
'public': {
'includeSubdir': 'include',
},
},
'lib_occi': {
'sourceFiles': [getBinaryDistDir(packagename).File('occi')],
'targetType': 'PrecompiledLibrary',
},
'lib_clntsh': {
'sourceFiles': [getBinaryDistDir(packagename).File('clntsh')],
'libVersion': '.11.1',
'targetType': 'PrecompiledLibrary',
},
'lib_clntsh': {
'sourceFiles': [getBinaryDistDir(packagename).File('clntsh')],
'libVersion': '.19.1',
'targetType': 'PrecompiledLibrary',
'linkDependencies': [
packagename + '.lib_clntshcore',
],
},
'lib_clntshcore': {
'sourceFiles': [getBinaryDistDir(packagename).File('clntshcore')],
'targetType': 'PrecompiledLibrary',
},
'lib_nnz': {
'sourceFiles': [getBinaryDistDir(packagename).File('nnz')],
'targetType': 'PrecompiledLibrary',
},
'lib_ociicus': { # us language support library
'sourceFiles': [getBinaryDistDir(packagename).File('ociicus')],
'targetType': 'PrecompiledLibrary',
},
'lib_ociei': { # oci library supporting all character sets
'sourceFiles': [getBinaryDistDir(packagename).File('ociei')],
'targetType': 'PrecompiledLibrary',
},
'lib_sqlplus': {
'sourceFiles': [getBinaryDistDir(packagename).File('sqlplus')],
'targetType': 'PrecompiledLibrary',
},
'lib_sqlplusic': {
'sourceFiles': [getBinaryDistDir(packagename).File('sqlplusic')],
'targetType': 'PrecompiledLibrary',
},
'sqlplusbin': {
'sourceFiles': [getBinaryDistDir(packagename).File('sqlplus')],
from ThirdParty import (
getBinaryDistDir,
determine_3rdparty_bin_node,
determine_3rdparty_lib_node,
)
from SConsider import cloneBaseEnv, createTargets
buildSettings = {packagename: {'linkDependencies': [], 'requires': []}}
_package_link_dependencies = buildSettings.get(packagename, {}).get('linkDependencies', [])
_package_requires = buildSettings.get(packagename, {}).get('requires', [])
env = cloneBaseEnv()
for _target_name, _real_libname_or_subdir, _headerfile, _lang in TARGET_LIBS_AND_HEADERS:
_lib_targetname = '_'.join(['lib', _target_name])
if _target_name == INCLUDE_TARGET_NAME:
buildSettings[_target_name] = {
'public': {
'includeSubdir': _real_libname_or_subdir,
},
}
_package_link_dependencies.append(createFulltargetname(packagename, _target_name))
else:
_checked_library = determine_3rdparty_lib_node(env, _real_libname_or_subdir,
getBinaryDistDir(packagename))
if _checked_library:
buildSettings[_lib_targetname] = {
'targetType': 'PrecompiledLibrary',
'sourceFiles': [getBinaryDistDir(packagename).File(_real_libname_or_subdir)],
'appendUnique': {},
'linkDependencies': [
createFulltargetname(packagename, INCLUDE_TARGET_NAME), # pass public include dirs
],