More fixes.

This commit is contained in:
Marcel Pi 2024-01-02 15:52:07 +01:00
parent a845e10173
commit 046ad2b238
8 changed files with 500 additions and 235 deletions

View File

@ -43,6 +43,8 @@ DEFAULT_ERROR_MESSAGE = (
' https://discord.gg/42KJdRj\n'
)
def FindExecutable(candidates : list):
for e in candidates:
ec = subprocess.call(
@ -91,12 +93,16 @@ DEFAULT_C_STANDARD = 11
DEFAULT_CPP_STANDARD = 20
argp = argparse.ArgumentParser(description = __doc__)
def AddCLIFlag(name : str, help : str):
argp.add_argument(f'--{name}', action = 'store_true', help = help)
def AddCLIStringOption(name : str, default : str, help : str):
argp.add_argument(f'--{name}', type = str, default = str(default), help = f'{help} (default = "{default}").')
def ADDCLIIntOption(name : str, default : int, help : str):
argp.add_argument(f'--{name}', type = int, default = int(default), help = f'{help} (default = {default}).')
AddCLIFlag(
'launch',
'Build and open the CarlaUE4 project in the Unreal Engine editor.')
@ -233,6 +239,8 @@ AddCLIStringOption(
'Set the path of Unreal Engine.')
ARGS_SYNC_PATH = WORKSPACE_PATH / 'ArgsSync.json'
def SyncArgs():
argv = argparse.Namespace()
if __name__ == '__main__':
@ -296,6 +304,7 @@ LIB_IS_AR = 'ar' in LIB
UNREAL_ENGINE_PATH = Path(ARGV.ue_path)
# Dependencies:
# Boost
BOOST_USE_SUPERPROJECT = True
BOOST_VERSION = (1, 83, 0)
BOOST_VERSION_MAJOR, BOOST_VERSION_MINOR, BOOST_VERSION_PATCH = BOOST_VERSION
BOOST_VERSION_STRING = f'{BOOST_VERSION_MAJOR}.{BOOST_VERSION_MINOR}.{BOOST_VERSION_PATCH}'
@ -306,6 +315,48 @@ BOOST_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-install'
BOOST_INCLUDE_PATH = BOOST_INSTALL_PATH / 'include'
BOOST_LIBRARY_PATH = BOOST_INSTALL_PATH / 'lib'
BOOST_B2_PATH = BOOST_SOURCE_PATH / f'b2{EXE_EXT}'
BOOST_ALGORITHM_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-algorithm-source'
BOOST_ALGORITHM_BUILD_PATH = DEPENDENCIES_PATH / 'boost-algorithm-build'
BOOST_ALGORITHM_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-algorithm-install'
BOOST_ALGORITHM_INCLUDE_PATH = BOOST_ALGORITHM_INSTALL_PATH / 'include'
BOOST_ALGORITHM_LIB_PATH = BOOST_ALGORITHM_INSTALL_PATH / 'lib'
BOOST_ASIO_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-asio-source'
BOOST_ASIO_BUILD_PATH = DEPENDENCIES_PATH / 'boost-asio-build'
BOOST_ASIO_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-asio-install'
BOOST_ASIO_INCLUDE_PATH = BOOST_ASIO_INSTALL_PATH / 'include'
BOOST_ASIO_LIB_PATH = BOOST_ASIO_INSTALL_PATH / 'lib'
BOOST_DATE_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-date-time-source'
BOOST_DATE_BUILD_PATH = DEPENDENCIES_PATH / 'boost-date-time-build'
BOOST_DATE_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-date-install'
BOOST_DATE_INCLUDE_PATH = BOOST_DATE_INSTALL_PATH / 'include'
BOOST_DATE_LIB_PATH = BOOST_DATE_INSTALL_PATH / 'lib'
BOOST_GEOMETRY_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-geometry-source'
BOOST_GEOMETRY_BUILD_PATH = DEPENDENCIES_PATH / 'boost-geometry-build'
BOOST_GEOMETRY_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-geometry-install'
BOOST_GEOMETRY_INCLUDE_PATH = BOOST_GEOMETRY_INSTALL_PATH / 'include'
BOOST_GEOMETRY_LIB_PATH = BOOST_GEOMETRY_INSTALL_PATH / 'lib'
BOOST_GIL_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-gil-source'
BOOST_GIL_BUILD_PATH = DEPENDENCIES_PATH / 'boost-gil-build'
BOOST_GIL_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-gil-install'
BOOST_GIL_INCLUDE_PATH = BOOST_GIL_INSTALL_PATH / 'include'
BOOST_GIL_LIB_PATH = BOOST_GIL_INSTALL_PATH / 'lib'
BOOST_ITERATOR_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-iterator-source'
BOOST_ITERATOR_BUILD_PATH = DEPENDENCIES_PATH / 'boost-iterator-build'
BOOST_ITERATOR_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-iterator-install'
BOOST_ITERATOR_INCLUDE_PATH = BOOST_ITERATOR_INSTALL_PATH / 'include'
BOOST_ITERATOR_LIB_PATH = BOOST_ITERATOR_INSTALL_PATH / 'lib'
BOOST_PYTHON_SOURCE_PATH = DEPENDENCIES_PATH / 'boost-python-source'
BOOST_PYTHON_BUILD_PATH = DEPENDENCIES_PATH / 'boost-python-build'
BOOST_PYTHON_INSTALL_PATH = DEPENDENCIES_PATH / 'boost-python-install'
BOOST_PYTHON_INCLUDE_PATH = BOOST_PYTHON_INSTALL_PATH / 'include'
BOOST_PYTHON_LIB_PATH = BOOST_PYTHON_INSTALL_PATH / 'lib'
# Eigen
EIGEN_SOURCE_PATH = DEPENDENCIES_PATH / 'eigen-source'
EIGEN_BUILD_PATH = DEPENDENCIES_PATH / 'eigen-build'
@ -391,11 +442,15 @@ NV_OMNIVERSE_PATCH_PATH = PATCHES_PATH / 'omniverse_4.26'
# Basic IO functions:
def Log(message):
message = str(message)
message += '\n'
print(message, end='')
def LaunchSubprocess(
cmd : list,
working_directory : Path = None,
@ -406,6 +461,8 @@ def LaunchSubprocess(
stderr = log,
cwd = working_directory)
def LaunchSubprocessImmediate(
cmd : list,
working_directory : Path = None,
@ -422,6 +479,8 @@ def LaunchSubprocessImmediate(
sp = subprocess.run(cmd, cwd = working_directory)
sp.check_returncode()
# Convenience classes for listing dependencies:
class Download:
@ -447,11 +506,9 @@ class DependencyUEPlugin(Dependency):
def __init__(self, name: str, *sources):
super().__init__(name, *sources)
DEFAULT_DEPENDENCIES = [
Dependency(
'boost',
Download(f'https://boostorg.jfrog.io/artifactory/main/release/{BOOST_VERSION_STRING}/source/boost_{BOOST_VERSION_MAJOR}_{BOOST_VERSION_MINOR}_{BOOST_VERSION_PATCH}.zip'),
Download(f'https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/boost_{BOOST_VERSION_MAJOR}_{BOOST_VERSION_MINOR}_{BOOST_VERSION_PATCH}.zip')),
Dependency(
'eigen',
GitRepository('https://gitlab.com/libeigen/eigen.git', tag_or_branch = '3.4.0')),
@ -460,20 +517,16 @@ DEFAULT_DEPENDENCIES = [
GitRepository('https://github.com/glennrp/libpng.git', tag_or_branch = 'v1.6.40')),
Dependency(
'proj',
GitRepository('https://github.com/OSGeo/PROJ.git', tag_or_branch = '9.3.0'),
Download('https://download.osgeo.org/proj/proj-9.3.0.tar.gz')),
GitRepository('https://github.com/OSGeo/PROJ.git', tag_or_branch = '9.3.0')),
Dependency(
'gtest',
GitRepository('https://github.com/google/googletest.git', tag_or_branch = 'v1.14.0')),
Dependency(
'zlib',
GitRepository('https://github.com/madler/zlib.git'),
Download('https://zlib.net/current/zlib.tar.gz')),
GitRepository('https://github.com/madler/zlib.git'),),
Dependency(
'xercesc',
GitRepository('https://github.com/apache/xerces-c.git', tag_or_branch = 'v3.2.4'),
Download('https://archive.apache.org/dist/xerces/c/3/sources/xerces-c-3.2.3.zip'),
Download('https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/xerces-c-3.2.3.zip')),
GitRepository('https://github.com/apache/xerces-c.git', tag_or_branch = 'v3.2.4')),
Dependency(
'sqlite',
Download('https://www.sqlite.org/2021/sqlite-amalgamation-3340100.zip')),
@ -483,16 +536,30 @@ DEFAULT_DEPENDENCIES = [
Dependency(
'recast',
GitRepository('https://github.com/carla-simulator/recastnavigation.git', tag_or_branch = 'carla')),
]
# @TODO: Use these instead of full boost.
BOOST_DEPENDENCIES_EXPERIMENTAL = [
] + [
Dependency(
'boost',
Download(f'https://boostorg.jfrog.io/artifactory/main/release/{BOOST_VERSION_STRING}/source/boost_{BOOST_VERSION_MAJOR}_{BOOST_VERSION_MINOR}_{BOOST_VERSION_PATCH}.zip'),
Download(f'https://carla-releases.s3.eu-west-3.amazonaws.com/Backup/boost_{BOOST_VERSION_MAJOR}_{BOOST_VERSION_MINOR}_{BOOST_VERSION_PATCH}.zip')),
] if BOOST_USE_SUPERPROJECT else [
Dependency(
'boost-algorithm',
GitRepository('https://github.com/boostorg/algorithm.git')),
Dependency(
'boost-asio',
GitRepository('https://github.com/boostorg/asio.git')),
Dependency(
'boost-iterator',
GitRepository('https://github.com/boostorg/iterator.git')),
Dependency(
'boost-python',
GitRepository('https://github.com/boostorg/python.git')),
Dependency(
'boost-geometry',
GitRepository('https://github.com/boostorg/geometry.git')),
Dependency(
'boost-date-time',
GitRepository('https://github.com/boostorg/date_time.git')),
Dependency(
'boost-gil',
GitRepository('https://github.com/boostorg/gil.git')),
@ -577,6 +644,9 @@ class Task:
def Run(self):
self.body(*self.args)
def ToString(self):
return f'{[ e.name for e in self.in_edges ]} -> {self.name}'
@ -604,9 +674,17 @@ class TaskGraph:
def Validate(self):
return True
def ToString(self):
return '\n'.join([ e.ToString() for e in self.tasks ])
def Print(self):
print(self.ToString())
def Execute(self, sequential : bool = False):
if len(self.tasks) == 0:
return
print('-- Running task graph --')
self.Print()
from collections import deque
assert self.Validate()
prior_sequential = self.sequential
@ -616,11 +694,9 @@ class TaskGraph:
for in_edge in task.in_edges:
assert in_edge != None
in_edge.out_edges.append(task)
task_queue = deque()
active_count = 0
done_count = 0
def UpdateOutEdges(task):
nonlocal task_queue
if len(task.out_edges) == 0:
@ -630,7 +706,6 @@ class TaskGraph:
out.in_edge_done_count += 1
if out.in_edge_done_count == len(out.in_edges):
task_queue.append(out)
def Flush():
nonlocal futures
nonlocal future_map
@ -641,14 +716,13 @@ class TaskGraph:
done_tasks = [ future_map[e] for e in done ]
for e in done_tasks:
e.done = True
Log(f'{e.name} - done')
Log(f'> {task.name} - DONE')
UpdateOutEdges(e)
assert active_count == len(done_tasks)
done_count += len(done_tasks)
active_count = 0
future_map = {}
futures = []
assert len(set(self.sources)) == len(self.sources)
task_queue.extend(self.sources)
with ProcessPoolExecutor(self.parallelism) as pool:
@ -657,7 +731,7 @@ class TaskGraph:
while len(task_queue) != 0:
while len(task_queue) != 0 and active_count < self.parallelism:
task = task_queue.popleft()
Log(f'{task.name} - start')
Log(f'> {task.name} - STARTED')
if not self.sequential:
active_count += 1
future = pool.submit(task.Run)
@ -665,24 +739,25 @@ class TaskGraph:
futures.append(future)
else:
task.Run()
Log(f'{task.name} - done')
Log(f'> {task.name} - DONE')
task.done = True
done_count += 1
UpdateOutEdges(task)
Flush()
if done_count != len(self.tasks):
pending_tasks = []
for e in self.tasks:
if not e.done:
pending_tasks.append(e)
Log(f'{len(self.tasks) - done_count} did not complete: {pending_tasks}.')
Log(f'> {len(self.tasks) - done_count} did not complete: {pending_tasks}.')
assert False
finally:
print('-- Done --')
self.sequential = prior_sequential
self.Reset()
def UpdateGitRepository(path : Path, url : str, branch : str = None, commit : str = None):
if path.exists():
LaunchSubprocessImmediate([ 'git', '-C', str(path), 'pull' ])
@ -696,6 +771,8 @@ def UpdateGitRepository(path : Path, url : str, branch : str = None, commit : st
LaunchSubprocessImmediate([ 'git', '-C', str(path), 'fetch' ])
LaunchSubprocessImmediate([ 'git', '-C', str(path), 'checkout', commit ])
def DownloadDependency(name : str, path : Path, url : str):
# Download:
try:
@ -730,6 +807,8 @@ def DownloadDependency(name : str, path : Path, url : str):
except Exception as err:
Log(f'Failed to extract dependency "{name}": {err}')
def UpdateDependency(dep : Dependency):
name = dep.name
@ -751,6 +830,8 @@ def UpdateDependency(dep : Dependency):
Log(f'Failed to update dependency "{name}".')
assert False
def UpdateDependencies(task_graph : TaskGraph):
DEPENDENCIES_PATH.mkdir(exist_ok = True)
unique_deps = set(DEFAULT_DEPENDENCIES)
@ -766,14 +847,20 @@ def UpdateDependencies(task_graph : TaskGraph):
task_graph.Add(Task(f'update-{dep.name}', [], UpdateDependency, dep)) for dep in unique_deps
]
def CleanDownloadsMain():
for ext in [ '*.tmp', '*.zip', '*.tar.gz' ]:
for e in DEPENDENCIES_PATH.glob(ext):
e.unlink(missing_ok = True)
def CleanDownloads(task_graph : TaskGraph):
return task_graph.Add(Task('clean-downloads', [], CleanDownloadsMain))
def ConfigureBoost():
if BOOST_B2_PATH.exists():
return
@ -781,6 +868,8 @@ def ConfigureBoost():
[ BOOST_SOURCE_PATH / f'bootstrap{SHELL_EXT}' ],
working_directory = BOOST_SOURCE_PATH)
def BuildAndInstallBoost():
LaunchSubprocessImmediate([
@ -805,7 +894,7 @@ def BuildAndInstallBoost():
'install'
],
working_directory = BOOST_SOURCE_PATH,
log_name = 'build-boost')
log_name = 'boost-build')
if (BOOST_INCLUDE_PATH / 'boost').exists():
return
candidates = glob.glob(f'{BOOST_INCLUDE_PATH}/**/boost', recursive = True)
@ -814,6 +903,8 @@ def BuildAndInstallBoost():
shutil.move(boost_path, BOOST_INCLUDE_PATH / 'boost')
boost_path.parent.rmdir()
def BuildSQLite():
SQLITE_BUILD_PATH.mkdir(exist_ok = True)
sqlite_sources = glob.glob(f'{SQLITE_SOURCE_PATH}/**/*.c', recursive = True)
@ -838,7 +929,7 @@ def BuildSQLite():
cmd.append(f'/Fe{SQLITE_EXE_PATH}')
else:
cmd.extend([ '-o', SQLITE_EXE_PATH ])
LaunchSubprocessImmediate(cmd, log_name = 'build-sqlite-exe')
LaunchSubprocessImmediate(cmd, log_name = 'sqlite-exe-build')
if not SQLITE_LIB_PATH.exists():
if C_COMPILER_IS_CLANG:
cmd = [
@ -862,7 +953,7 @@ def BuildSQLite():
cmd.extend([ '/Fo:' if C_COMPILER_CLI_TYPE == 'msvc' else '-o', SQLITE_LIB_PATH ])
LaunchSubprocessImmediate(
cmd,
log_name = 'build-sqlite-lib')
log_name = 'sqlite-lib-build')
else:
objs = []
BUILD_TEMP_PATH.mkdir(exist_ok = True)
@ -884,14 +975,16 @@ def BuildSQLite():
])
obj_path = BUILD_TEMP_PATH / f'{e.name}{OBJ_EXT}'
cmd.extend([ e, '/Fo:' if C_COMPILER_CLI_TYPE == 'msvc' else '-o', obj_path ])
LaunchSubprocessImmediate(cmd, log_name = f'build-sqlite-{e.stem}')
LaunchSubprocessImmediate(cmd, log_name = f'sqlite-{e.stem}-build')
objs.append(obj_path)
cmd = [
LIB,
f'/OUT:{SQLITE_LIB_PATH}',
]
cmd.extend(objs)
LaunchSubprocessImmediate(cmd, log_name = 'build-sqlite-lib')
LaunchSubprocessImmediate(cmd, log_name = 'sqlite-lib-build')
def ConfigureSUMO():
xercesc_path_candidates = glob.glob(f'{XERCESC_INSTALL_PATH}/**/{LIB_PREFIX}xerces-c*{LIB_EXT}', recursive=True)
@ -904,13 +997,17 @@ def ConfigureSUMO():
cmd = Task.CreateCMakeConfigureDefaultCommandLine(
SUMO_SOURCE_PATH,
SUMO_BUILD_PATH)
proj_candidates = glob.glob(str(PROJ_INSTALL_PATH / 'lib' / '**' / f'*proj{LIB_EXT}'), recursive = True)
if len(proj_candidates) == 0:
raise Exception('Could not configure SUMO since PROJ could not be found.')
PROJ_LIB_PATH = proj_candidates[0]
cmd.extend([
SUMO_SOURCE_PATH,
SUMO_BUILD_PATH,
f'-DZLIB_INCLUDE_DIR={ZLIB_INCLUDE_PATH}',
f'-DZLIB_LIBRARY={ZLIB_LIB_PATH}',
f'-DPROJ_INCLUDE_DIR={PROJ_INSTALL_PATH}/include',
f'-DPROJ_LIBRARY={PROJ_INSTALL_PATH}/lib/{LIB_PREFIX}proj{LIB_EXT}',
f'-DPROJ_LIBRARY={PROJ_LIB_PATH}',
f'-DXercesC_INCLUDE_DIR={XERCESC_INSTALL_PATH}/include',
f'-DXercesC_LIBRARY={XERCESC_PATH}',
'-DSUMO_LIBRARIES=OFF',
@ -926,31 +1023,91 @@ def ConfigureSUMO():
])
LaunchSubprocessImmediate(cmd)
def BuildDependencies(
task_graph : TaskGraph):
# Configure:
build_sqlite = task_graph.Add(Task('build-sqlite', [], BuildSQLite))
task_graph.Add(Task('configure-boost', [], ConfigureBoost))
def BuildDependencies(task_graph : TaskGraph):
# There are some dependencies that need sqlite to be built before configuring.
build_sqlite = task_graph.Add(Task('sqlite-build', [], BuildSQLite))
configure_zlib = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-zlib',
[],
ZLIB_SOURCE_PATH,
ZLIB_BUILD_PATH,
install_path = ZLIB_INSTALL_PATH))
build_zlib = task_graph.Add(Task.CreateCMakeBuildDefault(
'build-zlib',
'zlib-build',
[ configure_zlib ],
ZLIB_BUILD_PATH))
install_zlib = task_graph.Add(Task.CreateCMakeInstallDefault(
'install-zlib',
# Configure step:
if BOOST_USE_SUPERPROJECT:
task_graph.Add(Task('configure-boost', [], ConfigureBoost))
else:
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-algorithm',
[],
BOOST_ALGORITHM_SOURCE_PATH,
BOOST_ALGORITHM_BUILD_PATH,
install_path = BOOST_ALGORITHM_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-asio',
[],
BOOST_ASIO_SOURCE_PATH,
BOOST_ASIO_BUILD_PATH,
install_path = BOOST_ASIO_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-date',
[],
BOOST_DATE_SOURCE_PATH,
BOOST_DATE_BUILD_PATH,
install_path = BOOST_DATE_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-geometry',
[],
BOOST_GEOMETRY_SOURCE_PATH,
BOOST_GEOMETRY_BUILD_PATH,
install_path = BOOST_GEOMETRY_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-gil',
[],
BOOST_GIL_SOURCE_PATH,
BOOST_GIL_BUILD_PATH,
install_path = BOOST_GIL_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-iterator',
[],
BOOST_ITERATOR_SOURCE_PATH,
BOOST_ITERATOR_BUILD_PATH,
install_path = BOOST_ITERATOR_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'boost-python',
[],
BOOST_PYTHON_SOURCE_PATH,
BOOST_PYTHON_BUILD_PATH,
install_path = BOOST_PYTHON_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault(
'zlib-install',
[ build_zlib ],
ZLIB_BUILD_PATH,
ZLIB_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-gtest',
[],
GTEST_SOURCE_PATH,
GTEST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libpng',
[],
@ -961,6 +1118,7 @@ def BuildDependencies(
'-DPNG_BUILD_ZLIB=ON',
f'-DZLIB_INCLUDE_DIRS={ZLIB_INCLUDE_PATH}',
f'-DZLIB_LIBRARIES={ZLIB_LIB_PATH}'))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-proj',
[ build_sqlite ],
@ -984,6 +1142,7 @@ def BuildDependencies(
'-DBUILD_PROJ=OFF',
'-DBUILD_TESTING=OFF',
install_path = PROJ_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-recast',
[],
@ -992,6 +1151,7 @@ def BuildDependencies(
'-DRECASTNAVIGATION_DEMO=OFF',
'-DRECASTNAVIGATION_TESTS=OFF',
'-DRECASTNAVIGATION_EXAMPLES=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-rpclib',
[],
@ -1003,11 +1163,13 @@ def BuildDependencies(
'-DRPCLIB_ENABLE_LOGGING=OFF',
'-DRPCLIB_ENABLE_COVERAGE=OFF',
'-DRPCLIB_MSVC_STATIC_RUNTIME=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault(
configure_xercesc = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-xercesc',
[],
XERCESC_SOURCE_PATH,
XERCESC_BUILD_PATH))
if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libosmscout',
@ -1019,11 +1181,13 @@ def BuildDependencies(
'-DOSMSCOUT_BUILD_TESTS=OFF',
'-DOSMSCOUT_BUILD_CLIENT_QT=OFF',
'-DOSMSCOUT_BUILD_DEMOS=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-lunasvg',
[],
LUNASVG_SOURCE_PATH,
LUNASVG_BUILD_PATH))
if ENABLE_CHRONO:
task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-chrono',
@ -1033,51 +1197,84 @@ def BuildDependencies(
f'-DEIGEN3_INCLUDE_DIR={EIGEN_SOURCE_PATH}',
'-DENABLE_MODULE_VEHICLE=ON'))
# SUMO requires that Proj and Xerces be built and installed before its configure step:
if ENABLE_OSM2ODR:
build_xercesc = task_graph.Add(Task.CreateCMakeBuildDefault('build-xercesc', [], XERCESC_BUILD_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-xercesc', [ build_xercesc ], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH))
# SUMO requires that Proj and Xerces be built and installed before its configure step:
build_xercesc = task_graph.Add(Task.CreateCMakeBuildDefault(
'xercesc-build',
[ configure_xercesc ],
XERCESC_BUILD_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault(
'xercesc-install',
[ build_xercesc ],
XERCESC_BUILD_PATH,
XERCESC_INSTALL_PATH))
# We wait for all pending tasks to finish here, then we'll switch to sequential task execution for the build step.
task_graph.Execute()
# Build:
task_graph.Add(Task('build-boost', [], BuildAndInstallBoost))
task_graph.Add(Task.CreateCMakeBuildDefault('build-gtest', [], GTEST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('build-libpng', [], LIBPNG_BUILD_PATH))
build_proj = task_graph.Add(Task.CreateCMakeBuildDefault('build-proj', [], PROJ_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('build-recast', [], RECAST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('build-rpclib', [], RPCLIB_BUILD_PATH))
if ENABLE_OSM2ODR:
install_proj = task_graph.Add(Task.CreateCMakeInstallDefault('install-proj', [ build_proj ], PROJ_BUILD_PATH, PROJ_INSTALL_PATH))
configure_sumo = task_graph.Add(Task('configure-sumo', [ install_proj ], ConfigureSUMO))
task_graph.Add(Task.CreateCMakeBuildDefault('build-sumo', [ configure_sumo ], SUMO_BUILD_PATH))
if BOOST_USE_SUPERPROJECT:
task_graph.Add(Task('boost-build', [], BuildAndInstallBoost))
else:
task_graph.Add(Task.CreateCMakeBuildDefault('build-xercesc', [], XERCESC_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-algorithm-build', [], BOOST_ALGORITHM_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-asio-build', [], BOOST_ASIO_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-date-build', [], BOOST_DATE_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-geometry-build', [], BOOST_GEOMETRY_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-gil-build', [], BOOST_GIL_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-iterator-build', [], BOOST_ITERATOR_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-python-build', [], BOOST_PYTHON_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('gtest-build', [], GTEST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('libpng-build', [], LIBPNG_BUILD_PATH))
build_proj = task_graph.Add(Task.CreateCMakeBuildDefault('proj-build', [], PROJ_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('recast-build', [], RECAST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('rpclib-build', [], RPCLIB_BUILD_PATH))
if ENABLE_OSM2ODR:
install_proj = task_graph.Add(Task.CreateCMakeInstallDefault('proj-install', [ build_proj ], PROJ_BUILD_PATH, PROJ_INSTALL_PATH))
configure_sumo = task_graph.Add(Task('configure-sumo', [ install_proj ], ConfigureSUMO))
task_graph.Add(Task.CreateCMakeBuildDefault('sumo-build', [ configure_sumo ], SUMO_BUILD_PATH))
else:
task_graph.Add(Task.CreateCMakeBuildDefault('xercesc-build', [], XERCESC_BUILD_PATH))
if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeBuildDefault('build-lunasvg', [], LUNASVG_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('build-libosmscout', [], LIBOSMSCOUT_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('lunasvg-build', [], LUNASVG_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('libosmscout-build', [], LIBOSMSCOUT_BUILD_PATH))
if ENABLE_CHRONO:
task_graph.Add(Task.CreateCMakeBuildDefault('build-chrono', [], CHRONO_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('chrono-build', [], CHRONO_BUILD_PATH))
task_graph.Execute(sequential = True) # The underlying build system should already parallelize.
# Install:
task_graph.Add(Task.CreateCMakeInstallDefault('install-gtest', [], GTEST_BUILD_PATH, GTEST_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-libpng', [], LIBPNG_BUILD_PATH, LIBPNG_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-recast', [], RECAST_BUILD_PATH, RECAST_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-rpclib', [], RPCLIB_BUILD_PATH, RPCLIB_INSTALL_PATH))
if not BOOST_USE_SUPERPROJECT:
task_graph.Add(Task.CreateCMakeBuildDefault('boost-algorithm-install', [], BOOST_ALGORITHM_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-asio-install', [], BOOST_ASIO_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-date-install', [], BOOST_DATE_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-geometry-install', [], BOOST_GEOMETRY_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-gil-install', [], BOOST_GIL_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-iterator-install', [], BOOST_ITERATOR_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('boost-python-install', [], BOOST_PYTHON_BUILD_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('gtest-install', [], GTEST_BUILD_PATH, GTEST_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('libpng-install', [], LIBPNG_BUILD_PATH, LIBPNG_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('recast-install', [], RECAST_BUILD_PATH, RECAST_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('rpclib-install', [], RPCLIB_BUILD_PATH, RPCLIB_INSTALL_PATH))
if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeInstallDefault('install-lunasvg', [], LUNASVG_BUILD_PATH, LUNASVG_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-libosmscout', [], LIBOSMSCOUT_BUILD_PATH, LIBOSMSCOUT_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('lunasvg-install', [], LUNASVG_BUILD_PATH, LUNASVG_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('libosmscout-install', [], LIBOSMSCOUT_BUILD_PATH, LIBOSMSCOUT_INSTALL_PATH))
if ENABLE_OSM2ODR:
task_graph.Add(Task.CreateCMakeInstallDefault('install-sumo', [], SUMO_BUILD_PATH, SUMO_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('sumo-install', [], SUMO_BUILD_PATH, SUMO_INSTALL_PATH))
else:
task_graph.Add(Task.CreateCMakeInstallDefault('install-proj', [], PROJ_BUILD_PATH, PROJ_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-xercesc', [], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('proj-install', [], PROJ_BUILD_PATH, PROJ_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('xercesc-install', [], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH))
if ENABLE_CHRONO:
task_graph.Add(Task.CreateCMakeInstallDefault('install-chrono', [], CHRONO_BUILD_PATH, CHRONO_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('chrono-install', [], CHRONO_BUILD_PATH, CHRONO_INSTALL_PATH))
task_graph.Execute()
def BuildLibCarlaMain(task_graph : TaskGraph):
configure_libcarla = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libcarla',
@ -1090,15 +1287,17 @@ def BuildLibCarlaMain(task_graph : TaskGraph):
f'-DBUILD_OSM_WORLD_RENDERER={"ON" if ENABLE_OSM_WORLD_RENDERER else "OFF"}',
f'-DLIBCARLA_PYTORCH={"ON" if ARGV.pytorch else "OFF"}'))
build_libcarla = task_graph.Add(Task.CreateCMakeBuildDefault(
'build-libcarla',
'libcarla-build',
[ configure_libcarla ],
LIBCARLA_BUILD_PATH))
return task_graph.Add(Task.CreateCMakeInstallDefault(
'install-libcarla',
'libcarla-install',
[ build_libcarla ],
LIBCARLA_BUILD_PATH,
LIBCARLA_INSTALL_PATH))
def BuildPythonAPIMain():
content = ''
with open(PYTHON_API_PATH / 'setup.py.in', 'r') as file:
@ -1112,13 +1311,19 @@ def BuildPythonAPIMain():
sys.executable, 'setup.py', 'bdist_wheel', 'bdist_egg'
], working_directory = PYTHON_API_PATH)
def BuildPythonAPI(task_graph : TaskGraph):
install_libcarla = task_graph.task_map.get('install-libcarla')
task_graph.Add(Task('build-python-api', [ install_libcarla ], BuildPythonAPIMain))
install_libcarla = task_graph.task_map.get('libcarla-install')
task_graph.Add(Task('python-api-build', [ install_libcarla ], BuildPythonAPIMain))
def SetupUnrealEngine(task_graph : TaskGraph):
pass
def BuildCarlaUEMain():
assert UNREAL_ENGINE_PATH.exists()
unreal_build_tool_args = []
@ -1141,19 +1346,23 @@ def BuildCarlaUEMain():
'-WaitMutex',
'-FromMsBuild',
CARLA_UE_PATH / 'CarlaUE4.uproject',
], log_name = 'build-carla-ue-editor')
], log_name = 'carla-ue-editor-build')
else:
pass
def BuildCarlaUE(task_graph : TaskGraph):
if ENABLE_NVIDIA_OMNIVERSE:
task_graph.Add(Task('install-nv-omniverse', [], InstallNVIDIAOmniverse))
task_graph.Add(Task('nv-omniverse-install', [], InstallNVIDIAOmniverse))
dependencies = []
if ENABLE_LIBCARLA:
dependencies.append(task_graph.task_map.get('install-libcarla'))
dependencies.append(task_graph.task_map.get('libcarla-install'))
if ENABLE_PYTHON_API:
dependencies.append(task_graph.task_map.get('build-python-api'))
task_graph.Add(Task('build-carla-ue', dependencies, BuildCarlaUEMain))
dependencies.append(task_graph.task_map.get('python-api-build'))
task_graph.Add(Task('carla-ue-build', dependencies, BuildCarlaUEMain))
def InstallNVIDIAOmniverse():
filename = 'USDCarlaInterface'
@ -1167,6 +1376,8 @@ def InstallNVIDIAOmniverse():
for src, dst in files:
shutil.copyfile(src, dst)
def Clean():
if not BUILD_PATH.exists():
return

View File

@ -1,59 +0,0 @@
// Copyright (c) 2023 Computer Vision Center (CVC) at the Universitat Autonoma
// de Barcelona (UAB).
//
// This work is licensed under the terms of the MIT license.
// For a copy, see <https://opensource.org/licenses/MIT>.
#include "carla/Exception.h"
#include <source_location>
// =============================================================================
// -- Define boost::throw_exception --------------------------------------------
// =============================================================================
#ifdef BOOST_NO_EXCEPTIONS
namespace boost {
void throw_exception(const std::exception &e)
{
carla::throw_exception(e);
}
void throw_exception(
const std::exception &e,
std::source_location const& loc)
{
throw_exception(e);
}
} // namespace boost
#endif // BOOST_NO_EXCEPTIONS
// =============================================================================
// -- Workaround for Boost.Asio bundled with rpclib ----------------------------
// =============================================================================
#ifdef ASIO_NO_EXCEPTIONS
#include <exception>
#include <system_error>
#include <typeinfo>
namespace clmdep_asio {
namespace detail {
template <typename Exception>
void throw_exception(const Exception& e) {
carla::throw_exception(e);
}
template void throw_exception<std::bad_cast>(const std::bad_cast &);
template void throw_exception<std::exception>(const std::exception &);
template void throw_exception<std::system_error>(const std::system_error &);
} // namespace detail
} // namespace clmdep_asio
#endif // ASIO_NO_EXCEPTIONS

View File

@ -5,18 +5,19 @@
// For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once
#include <exception>
// =============================================================================
// -- Define carla::throw_exception --------------------------------------------
// =============================================================================
#ifdef LIBCARLA_NO_EXCEPTIONS
namespace std {
class exception;
} // namespace std
namespace carla {
/// User define function, similar to Boost throw_exception.
namespace carla
{
/// User defined function, similar to Boost throw_exception.
///
/// @important Boost exceptions are also routed to this function.
///
@ -25,19 +26,65 @@ namespace carla {
/// appropriate definition. Callers of throw_exception are allowed to assume
/// that the function never returns; therefore, if the user-defined
/// throw_exception returns, the behavior is undefined.
[[ noreturn ]] void throw_exception(const std::exception &e);
[[noreturn]]
void throw_exception(const std::exception &e);
} // namespace carla
#else
namespace carla {
template <typename T>
[[ noreturn ]] void throw_exception(const T &e) {
namespace carla
{
[[noreturn]]
inline void throw_exception(const std::exception &e)
{
throw e;
}
} // namespace carla
#endif // LIBCARLA_NO_EXCEPTIONS
// =============================================================================
// -- Define boost::throw_exception --------------------------------------------
// =============================================================================
#ifdef BOOST_NO_EXCEPTIONS
#include <boost/assert/source_location.hpp>
namespace boost
{
[[noreturn]]
inline void throw_exception(const std::exception &e)
{
carla::throw_exception(e);
}
[[noreturn]]
inline void throw_exception(const std::exception &e, boost::source_location const& loc)
{
throw_exception(e);
}
} // namespace boost
#endif // BOOST_NO_EXCEPTIONS
// =============================================================================
// -- Workaround for Boost.Asio bundled with rpclib ----------------------------
// =============================================================================
#ifdef ASIO_NO_EXCEPTIONS
namespace clmdep_asio
{
namespace detail
{
[[noreturn]]
inline void throw_exception(const std::exception& e)
{
carla::throw_exception(e);
}
} // namespace detail
} // namespace clmdep_asio
#endif // ASIO_NO_EXCEPTIONS

View File

@ -24,7 +24,7 @@ namespace s11n {
class NoopSerializer {
public:
[[ noreturn ]] static SharedPtr<SensorData> Deserialize(RawData &&data);
[[noreturn]] static SharedPtr<SensorData> Deserialize(RawData &&data);
};
} // namespace s11n

View File

@ -3,14 +3,18 @@
using System;
using System.IO;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using UnrealBuildTool;
using EpicGames.Core;
using System.Diagnostics;
public class Carla :
ModuleRules
{
[CommandLine("-carsim")]
[CommandLine("-verbose")]
bool Verbose = true;
[CommandLine("-carsim")]
bool EnableCarSim = false;
[CommandLine("-chrono")]
@ -22,6 +26,9 @@ public class Carla :
[CommandLine("-ros2")]
bool EnableRos2 = false;
[CommandLine("-osm2odr")]
bool EnableOSM2ODR = false;
[CommandLine("-carla-install-path")]
string CarlaInstallPath = null;
@ -102,6 +109,12 @@ public class Carla :
PrivateDefinitions.Add("WITH_ROS2");
}
if (EnableOSM2ODR)
{
PublicDefinitions.Add("WITH_OSM2ODR");
PrivateDefinitions.Add("WITH_OSM2ODR");
}
// PublicIncludePaths.AddRange(new string[] { });
// PrivateIncludePaths.AddRange(new string[] { });
@ -169,6 +182,8 @@ public class Carla :
var InstallPath = Path.Combine(DependenciesInstallPath, name + "-install");
var LibPath = Path.Combine(InstallPath, "lib");
var Candidates = Directory.GetFiles(LibPath, GetLibraryName(pattern));
if (Candidates.Length == 0)
Console.WriteLine(string.Format("Could not find any matching libraries for \"{0}\" using pattern \"{1}\"", name, pattern));
Array.Sort(Candidates);
return Candidates;
};
@ -179,32 +194,40 @@ public class Carla :
var LibCarlaIncludePath = Path.Combine(LibCarlaInstallPath, "include");
var LibCarlaLibPath = Path.Combine(LibCarlaInstallPath, "lib");
var LibCarlaServerPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-server"));
PublicAdditionalLibraries.AddRange(new string[]{LibCarlaServerPath});
var LibCarlaClientPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-client"));
Debug.Assert(Directory.Exists(LibCarlaServerPath));
Debug.Assert(Directory.Exists(LibCarlaClientPath));
// Boost
var BoostLibraryPatterns = new string[]
var BoostLibraryPatterns = new string[]
{
GetLibraryName("*boost_asio*"),
GetLibraryName("*boost_python*"),
};
"libboost_atomic*",
"libboost_date_time*",
"libboost_filesystem*",
"libboost_numpy*",
"libboost_python*",
"libboost_system*",
};
var BoostIncludePath = Path.Combine(DependenciesInstallPath, "boost-install", "include");
var BoostLibraries =
var BoostLibraries =
from Pattern in BoostLibraryPatterns
from Candidate in FindLibraries("boost", Pattern)
select Candidate;
select FindLibraries("boost", Pattern)[0];
var SQLiteBuildPath = Path.Combine(DependenciesInstallPath, "sqlite-build");
var SQLiteLibrary = Directory.GetFiles(SQLiteBuildPath, GetLibraryName("sqlite*"))[0];
PublicAdditionalLibraries.AddRange(BoostLibraries);
PublicAdditionalLibraries.AddRange(new string[]
var AdditionalLibraries = new List<string>
{
LibCarlaServerPath,
SQLiteLibrary,
FindLibraries("rpclib", "rpc")[0],
FindLibraries("xercesc", "xerces-c*")[0],
FindLibraries("proj", "proj")[0],
FindLibraries("sumo", "*osm2odr")[0],
FindLibraries("zlib", "zlib*")[0],
});
};
AdditionalLibraries.AddRange(BoostLibraries);
if (EnableOSM2ODR)
AdditionalLibraries.Add(FindLibraries("sumo", "*osm2odr")[0]);
if (EnableChrono)
{
@ -221,7 +244,7 @@ public class Carla :
var ChronoLibraries =
from Name in ChronoLibraryNames
select FindLibraries(ChronoLibPath, GetLibraryName(Name))[0];
PublicAdditionalLibraries.AddRange(ChronoLibraries);
AdditionalLibraries.AddRange(ChronoLibraries);
}
PublicIncludePaths.Add(ModuleDirectory);
@ -248,12 +271,21 @@ public class Carla :
PublicDefinitions.Add("BOOST_DISABLE_ABI_HEADERS");
PublicDefinitions.Add("BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY");
if (IsWindows)
if (IsWindows)
{
PublicDefinitions.Add("NOMINMAX");
PublicDefinitions.Add("VC_EXTRALEAN");
PublicDefinitions.Add("WIN32_LEAN_AND_MEAN");
}
if (Verbose)
{
Console.WriteLine("Additional CARLA libraries:");
foreach (var e in AdditionalLibraries)
Console.WriteLine(" - " + e);
}
PublicAdditionalLibraries.AddRange(AdditionalLibraries);
}
#if false

View File

@ -7,10 +7,6 @@
#include "Carla/Vehicle/CarlaWheeledVehicle.h"
#if 0 // @CARLAUE5
#include "TireConfig.h"
#include "VehicleWheel.h"
#include "Components/BoxComponent.h"
#include "Engine/CollisionProfile.h"
#include "MovementComponents/DefaultMovementComponent.h"
@ -35,6 +31,7 @@
ACarlaWheeledVehicle::ACarlaWheeledVehicle(const FObjectInitializer& ObjectInitializer) :
Super(ObjectInitializer)
{
#if 0 // @CARLAUE5
VehicleBounds = CreateDefaultSubobject<UBoxComponent>(TEXT("VehicleBounds"));
VehicleBounds->SetupAttachment(RootComponent);
VehicleBounds->SetHiddenInGame(true);
@ -45,10 +42,12 @@ ACarlaWheeledVehicle::ACarlaWheeledVehicle(const FObjectInitializer& ObjectIniti
GetWheeledVehicleComponent()->bReverseAsBrake = false;
BaseMovementComponent = CreateDefaultSubobject<UBaseCarlaMovementComponent>(TEXT("BaseMovementComponent"));
#endif
}
ACarlaWheeledVehicle::~ACarlaWheeledVehicle() {}
#if 0 // @CARLAUE5
void ACarlaWheeledVehicle::SetWheelCollision(UWheeledVehicleMovementComponent4W *Vehicle4W,
const FVehiclePhysicsControl &PhysicsControl ) {
@ -74,6 +73,7 @@ void ACarlaWheeledVehicle::SetWheelCollision(UWheeledVehicleMovementComponent4W
#endif
}
#endif
void ACarlaWheeledVehicle::SetWheelCollisionNW(UWheeledVehicleMovementComponentNW *VehicleNW,
const FVehiclePhysicsControl &PhysicsControl ) {
@ -97,6 +97,7 @@ void ACarlaWheeledVehicle::SetWheelCollisionNW(UWheeledVehicleMovementComponentN
void ACarlaWheeledVehicle::BeginPlay()
{
#if 0 // @CARLAUE5
Super::BeginPlay();
UDefaultMovementComponent::CreateDefaultMovementComponent(this);
@ -200,6 +201,7 @@ void ACarlaWheeledVehicle::BeginPlay()
}
AddReferenceToManager();
#endif
}
bool ACarlaWheeledVehicle::IsInVehicleRange(const FVector& Location) const
@ -306,11 +308,15 @@ FVector ACarlaWheeledVehicle::GetVehicleBoundingBoxExtent() const
float ACarlaWheeledVehicle::GetMaximumSteerAngle() const
{
#if 0 // @CARLAUE5
const auto &Wheels = GetWheeledVehicleComponent()->Wheels;
check(Wheels.Num() > 0);
const auto *FrontWheel = Wheels[0];
check(FrontWheel != nullptr);
return FrontWheel->SteerAngle;
#else
return 0.0F;
#endif
}
// =============================================================================
@ -367,9 +373,9 @@ void ACarlaWheeledVehicle::SetHandbrakeInput(const bool Value)
TArray<float> ACarlaWheeledVehicle::GetWheelsFrictionScale()
{
TArray<float> WheelsFrictionScale;
#if 0 // @CARLAUE5
UChaosWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
TArray<float> WheelsFrictionScale;
if (Movement)
{
check(Movement != nullptr);
@ -379,12 +385,13 @@ TArray<float> ACarlaWheeledVehicle::GetWheelsFrictionScale()
WheelsFrictionScale.Add(Wheel->TireConfig->GetFrictionScale());
}
}
#endif
return WheelsFrictionScale;
}
void ACarlaWheeledVehicle::SetWheelsFrictionScale(TArray<float> &WheelsFrictionScale)
{
#if 0 // @CARLAUE5
UChaosWheeledVehicleMovementComponent* Movement = GetVehicleMovement();
if (Movement)
{
@ -396,12 +403,13 @@ void ACarlaWheeledVehicle::SetWheelsFrictionScale(TArray<float> &WheelsFrictionS
Movement->Wheels[i]->TireConfig->SetFrictionScale(WheelsFrictionScale[i]);
}
}
#endif
}
FVehiclePhysicsControl ACarlaWheeledVehicle::GetVehiclePhysicsControl() const
{
FVehiclePhysicsControl PhysicsControl;
#if 0 // @CARLAUE5
if (!bIsNWVehicle) {
UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
GetVehicleMovement());
@ -558,6 +566,7 @@ FVehiclePhysicsControl ACarlaWheeledVehicle::GetVehiclePhysicsControl() const
PhysicsControl.Wheels = Wheels;
}
#endif
return PhysicsControl;
}
@ -574,6 +583,7 @@ void ACarlaWheeledVehicle::RestoreVehiclePhysicsControl()
void ACarlaWheeledVehicle::ApplyVehiclePhysicsControl(const FVehiclePhysicsControl &PhysicsControl)
{
LastPhysicsControl = PhysicsControl;
#if 0 // @CARLAUE5
if (!bIsNWVehicle) {
UWheeledVehicleMovementComponent4W *Vehicle4W = Cast<UWheeledVehicleMovementComponent4W>(
GetVehicleMovement());
@ -787,7 +797,7 @@ void ACarlaWheeledVehicle::ApplyVehiclePhysicsControl(const FVehiclePhysicsContr
// Update physics in the Ackermann Controller
AckermannController.UpdateVehiclePhysics(this);
#endif
}
void ACarlaWheeledVehicle::ActivateVelocityControl(const FVector &Velocity)
@ -802,6 +812,7 @@ void ACarlaWheeledVehicle::DeactivateVelocityControl()
void ACarlaWheeledVehicle::ShowDebugTelemetry(bool Enabled)
{
#if 0 // @CARLAUE5
if (GetWorld()->GetFirstPlayerController())
{
ACarlaHUD* hud = Cast<ACarlaHUD>(GetWorld()->GetFirstPlayerController()->GetHUD());
@ -823,6 +834,7 @@ void ACarlaWheeledVehicle::ShowDebugTelemetry(bool Enabled)
UE_LOG(LogCarla, Warning, TEXT("ACarlaWheeledVehicle::ShowDebugTelemetry:: Cannot find HUD for debug info"));
}
}
#endif
}
void ACarlaWheeledVehicle::SetVehicleLightState(const FVehicleLightState &LightState)
@ -860,6 +872,7 @@ void ACarlaWheeledVehicle::SetCarlaMovementComponent(UBaseCarlaMovementComponent
void ACarlaWheeledVehicle::SetWheelSteerDirection(EVehicleWheelLocation WheelLocation, float AngleInDeg) {
#if 0 // @CARLAUE5
if (bPhysicsEnabled == false)
{
check((uint8)WheelLocation >= 0)
@ -871,10 +884,12 @@ void ACarlaWheeledVehicle::SetWheelSteerDirection(EVehicleWheelLocation WheelLoc
{
UE_LOG(LogTemp, Warning, TEXT("Cannot set wheel steer direction. Physics are enabled."))
}
#endif
}
float ACarlaWheeledVehicle::GetWheelSteerAngle(EVehicleWheelLocation WheelLocation) {
#if 0 // @CARLAUE5
check((uint8)WheelLocation >= 0)
UVehicleAnimationInstance *VehicleAnim = Cast<UVehicleAnimationInstance>(GetMesh()->GetAnimInstance());
check(VehicleAnim != nullptr)
@ -888,9 +903,13 @@ float ACarlaWheeledVehicle::GetWheelSteerAngle(EVehicleWheelLocation WheelLocati
{
return VehicleAnim->GetWheelRotAngle((uint8)WheelLocation);
}
#else
return 0.0F;
#endif
}
void ACarlaWheeledVehicle::SetSimulatePhysics(bool enabled) {
#if 0 // @CARLAUE5
if(!GetCarlaMovementComponent<UDefaultMovementComponent>())
{
return;
@ -929,7 +948,7 @@ void ACarlaWheeledVehicle::SetSimulatePhysics(bool enabled) {
ResetConstraints();
}
#endif
}
void ACarlaWheeledVehicle::ResetConstraints()
@ -1074,12 +1093,14 @@ void ACarlaWheeledVehicle::ApplyRolloverBehavior()
}
void ACarlaWheeledVehicle::CheckRollover(const float roll, const std::pair<float, float> threshold_roll){
#if 0 // @CARLAUE5
if (threshold_roll.first < roll && roll < threshold_roll.second){
auto RootComponent = Cast<UPrimitiveComponent>(GetRootComponent());
auto angular_velocity = RootComponent->GetPhysicsAngularVelocityInDegrees();
RootComponent->SetPhysicsAngularVelocity((1 - RolloverBehaviorForce) * angular_velocity);
auto Root = Cast<UPrimitiveComponent>(GetRootComponent());
auto angular_velocity = Root->GetPhysicsAngularVelocityInDegrees();
Root->SetPhysicsAngularVelocity((1 - RolloverBehaviorForce) * angular_velocity);
RolloverBehaviorTracker += 1;
}
#endif
}
void ACarlaWheeledVehicle::SetRolloverFlag(){
@ -1133,5 +1154,4 @@ void ACarlaWheeledVehicle::SetPhysicsConstraintAngle(
UPhysicsConstraintComponent* Component, const FRotator &NewAngle)
{
Component->ConstraintInstance.AngularRotationOffset = NewAngle;
}
#endif
}

View File

@ -2,20 +2,27 @@
using System;
using System.IO;
using UnrealBuildTool;
using EpicGames.Core;
using System.Linq;
using System.Diagnostics;
using System.Collections.Generic;
using UnrealBuildTool;
using EpicGames.Core;
public class CarlaTools :
ModuleRules
{
[CommandLine("-verbose")]
bool Verbose = true;
[CommandLine("-houdini")]
bool EnableHoudini = false;
[CommandLine("-nv-omniverse")]
bool EnableNVIDIAOmniverse = false;
[CommandLine("-osm2odr")]
bool EnableOSM2ODR = false;
[CommandLine("-carla-install-path")]
string CarlaInstallPath = null;
@ -28,40 +35,18 @@ public class CarlaTools :
Console.WriteLine(string.Format("{0} is {1}.", name, state));
}
public static string FindLibrary(string SearchPath, params string[] Patterns)
{
foreach (var Pattern in Patterns)
{
var Candidates = Directory.GetFiles(SearchPath, Pattern);
if (Candidates.Length == 0)
continue;
Array.Sort(Candidates);
return Candidates[0];
}
string message = "Warning: Could not find any matches in \"";
message += SearchPath;
message += "\" for";
foreach (var Pattern in Patterns)
{
message += " \"";
message += Pattern;
message += "\",";
}
if (Patterns.Length != 0)
message.Remove(message.Length - 1, 1);
message += '.';
Console.WriteLine(message);
return "";
}
public CarlaTools(ReadOnlyTargetRules Target) :
base(Target)
{
LogFlagStatus("Houdini support", EnableHoudini);
LogFlagStatus("NVIDIA Omniverse support", EnableNVIDIAOmniverse);
if (EnableOSM2ODR)
{
PublicDefinitions.Add("WITH_OSM2ODR");
PrivateDefinitions.Add("WITH_OSM2ODR");
}
var DirectoryInfo = new DirectoryInfo(ModuleDirectory);
for (int i = 0; i != 6; ++i)
DirectoryInfo = DirectoryInfo.Parent;
@ -89,13 +74,8 @@ public class CarlaTools :
Console.WriteLine("Current module directory: " + ModuleDirectory);
bool IsWindows = Target.Platform == UnrealTargetPlatform.Win64;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnableExceptions = bEnableExceptions || IsWindows;
// PrivatePCHHeaderFile = "Carla.h";
// PublicIncludePaths.AddRange(new string[] { });
// PrivateIncludePaths.AddRange(new string[] { });
PublicDependencyModuleNames.AddRange(new string[]
{
@ -103,8 +83,8 @@ public class CarlaTools :
"ProceduralMeshComponent",
"MeshDescription",
"RawMesh",
"AssetTools"
});
"AssetTools",
});
PrivateDependencyModuleNames.AddRange(new string[]
{
@ -118,8 +98,8 @@ public class CarlaTools :
"EditorScriptingUtilities",
"Landscape",
"Foliage",
"FoliageEdit",
"MeshMergeUtilities",
"FoliageEdit",
"MeshMergeUtilities",
"Carla",
"StaticMeshDescription",
"ChaosVehicles",
@ -132,7 +112,7 @@ public class CarlaTools :
"RenderCore",
"MeshMergeUtilities",
"StreetMapImporting",
"StreetMapRuntime"
"StreetMapRuntime",
});
if (EnableHoudini)
@ -198,33 +178,40 @@ public class CarlaTools :
var LibCarlaLibPath = Path.Combine(LibCarlaInstallPath, "lib");
var LibCarlaServerPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-server"));
var LibCarlaClientPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-client"));
// Boost
var BoostLibraryPatterns = new string[]
{
GetLibraryName("*boost_asio*"),
GetLibraryName("*boost_python*"),
"libboost_atomic*",
"libboost_date_time*",
"libboost_filesystem*",
"libboost_numpy*",
"libboost_python*",
"libboost_system*",
};
var BoostLibraries =
from Pattern in BoostLibraryPatterns
from Candidate in FindLibraries("boost", Pattern)
select Candidate;
select FindLibraries("boost", Pattern)[0];
// SQLite
var SQLiteBuildPath = Path.Combine(DependenciesInstallPath, "sqlite-build");
var SQLiteLibrary = Directory.GetFiles(SQLiteBuildPath, GetLibraryName("sqlite*"))[0];
PublicIncludePaths.Add(ModuleDirectory);
PublicIncludePaths.Add(LibCarlaIncludePath);
PublicAdditionalLibraries.AddRange(BoostLibraries);
PublicAdditionalLibraries.AddRange(new string[]
var AdditionalLibraries = new List<string>
{
SQLiteLibrary,
FindLibraries("rpclib", "rpc")[0],
FindLibraries("xercesc", "xerces-c*")[0],
FindLibraries("proj", "proj")[0],
FindLibraries("sumo", "*osm2odr")[0],
FindLibraries("zlib", "zlib*")[0],
});
};
if (EnableOSM2ODR)
AdditionalLibraries.Add(FindLibraries("sumo", "*osm2odr")[0]);
PublicIncludePaths.Add(ModuleDirectory);
PublicIncludePaths.Add(LibCarlaIncludePath);
PublicIncludePaths.AddRange(new string[]
{
GetIncludePath("boost"),
@ -233,5 +220,28 @@ public class CarlaTools :
GetIncludePath("sumo"),
GetIncludePath("zlib"),
});
PublicDefinitions.Add("ASIO_NO_EXCEPTIONS");
PublicDefinitions.Add("BOOST_NO_EXCEPTIONS");
PublicDefinitions.Add("LIBCARLA_NO_EXCEPTIONS");
PublicDefinitions.Add("PUGIXML_NO_EXCEPTIONS");
PublicDefinitions.Add("BOOST_DISABLE_ABI_HEADERS");
PublicDefinitions.Add("BOOST_TYPE_INDEX_FORCE_NO_RTTI_COMPATIBILITY");
if (IsWindows)
{
PublicDefinitions.Add("NOMINMAX");
PublicDefinitions.Add("VC_EXTRALEAN");
PublicDefinitions.Add("WIN32_LEAN_AND_MEAN");
}
if (Verbose)
{
Console.WriteLine("Additional CARLA libraries:");
foreach (var e in AdditionalLibraries)
Console.WriteLine(" - " + e);
}
PublicAdditionalLibraries.AddRange(AdditionalLibraries);
}
}

View File

@ -12,6 +12,7 @@
void UCustomFileDownloader::ConvertOSMInOpenDrive(FString FilePath, float Lat_0, float Lon_0)
{
#ifdef WITH_OSM2ODR
IPlatformFile &FileManager = FPlatformFileManager::Get().GetPlatformFile();
FString FileContent;
@ -52,6 +53,9 @@ void UCustomFileDownloader::ConvertOSMInOpenDrive(FString FilePath, float Lat_0,
{
UE_LOG(LogCarlaToolsMapGenerator, Warning, TEXT("FileManipulation: Failed to write FString to file."));
}
#else
UE_LOG(LogCarlaToolsMapGenerator, Error, TEXT("UCustomFileDownloader::ConvertOSMInOpenDrive is disabled since SUMO's OSM2ODR is not enabled."));
#endif
}
void UCustomFileDownloader::StartDownload()