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' ' https://discord.gg/42KJdRj\n'
) )
def FindExecutable(candidates : list): def FindExecutable(candidates : list):
for e in candidates: for e in candidates:
ec = subprocess.call( ec = subprocess.call(
@ -91,12 +93,16 @@ DEFAULT_C_STANDARD = 11
DEFAULT_CPP_STANDARD = 20 DEFAULT_CPP_STANDARD = 20
argp = argparse.ArgumentParser(description = __doc__) argp = argparse.ArgumentParser(description = __doc__)
def AddCLIFlag(name : str, help : str): def AddCLIFlag(name : str, help : str):
argp.add_argument(f'--{name}', action = 'store_true', help = help) argp.add_argument(f'--{name}', action = 'store_true', help = help)
def AddCLIStringOption(name : str, default : str, help : str): def AddCLIStringOption(name : str, default : str, help : str):
argp.add_argument(f'--{name}', type = str, default = str(default), help = f'{help} (default = "{default}").') argp.add_argument(f'--{name}', type = str, default = str(default), help = f'{help} (default = "{default}").')
def ADDCLIIntOption(name : str, default : int, help : str): def ADDCLIIntOption(name : str, default : int, help : str):
argp.add_argument(f'--{name}', type = int, default = int(default), help = f'{help} (default = {default}).') argp.add_argument(f'--{name}', type = int, default = int(default), help = f'{help} (default = {default}).')
AddCLIFlag( AddCLIFlag(
'launch', 'launch',
'Build and open the CarlaUE4 project in the Unreal Engine editor.') 'Build and open the CarlaUE4 project in the Unreal Engine editor.')
@ -233,6 +239,8 @@ AddCLIStringOption(
'Set the path of Unreal Engine.') 'Set the path of Unreal Engine.')
ARGS_SYNC_PATH = WORKSPACE_PATH / 'ArgsSync.json' ARGS_SYNC_PATH = WORKSPACE_PATH / 'ArgsSync.json'
def SyncArgs(): def SyncArgs():
argv = argparse.Namespace() argv = argparse.Namespace()
if __name__ == '__main__': if __name__ == '__main__':
@ -296,6 +304,7 @@ LIB_IS_AR = 'ar' in LIB
UNREAL_ENGINE_PATH = Path(ARGV.ue_path) UNREAL_ENGINE_PATH = Path(ARGV.ue_path)
# Dependencies: # Dependencies:
# Boost # Boost
BOOST_USE_SUPERPROJECT = True
BOOST_VERSION = (1, 83, 0) BOOST_VERSION = (1, 83, 0)
BOOST_VERSION_MAJOR, BOOST_VERSION_MINOR, BOOST_VERSION_PATCH = BOOST_VERSION BOOST_VERSION_MAJOR, BOOST_VERSION_MINOR, BOOST_VERSION_PATCH = BOOST_VERSION
BOOST_VERSION_STRING = f'{BOOST_VERSION_MAJOR}.{BOOST_VERSION_MINOR}.{BOOST_VERSION_PATCH}' 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_INCLUDE_PATH = BOOST_INSTALL_PATH / 'include'
BOOST_LIBRARY_PATH = BOOST_INSTALL_PATH / 'lib' BOOST_LIBRARY_PATH = BOOST_INSTALL_PATH / 'lib'
BOOST_B2_PATH = BOOST_SOURCE_PATH / f'b2{EXE_EXT}' 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
EIGEN_SOURCE_PATH = DEPENDENCIES_PATH / 'eigen-source' EIGEN_SOURCE_PATH = DEPENDENCIES_PATH / 'eigen-source'
EIGEN_BUILD_PATH = DEPENDENCIES_PATH / 'eigen-build' EIGEN_BUILD_PATH = DEPENDENCIES_PATH / 'eigen-build'
@ -391,11 +442,15 @@ NV_OMNIVERSE_PATCH_PATH = PATCHES_PATH / 'omniverse_4.26'
# Basic IO functions: # Basic IO functions:
def Log(message): def Log(message):
message = str(message) message = str(message)
message += '\n' message += '\n'
print(message, end='') print(message, end='')
def LaunchSubprocess( def LaunchSubprocess(
cmd : list, cmd : list,
working_directory : Path = None, working_directory : Path = None,
@ -406,6 +461,8 @@ def LaunchSubprocess(
stderr = log, stderr = log,
cwd = working_directory) cwd = working_directory)
def LaunchSubprocessImmediate( def LaunchSubprocessImmediate(
cmd : list, cmd : list,
working_directory : Path = None, working_directory : Path = None,
@ -422,6 +479,8 @@ def LaunchSubprocessImmediate(
sp = subprocess.run(cmd, cwd = working_directory) sp = subprocess.run(cmd, cwd = working_directory)
sp.check_returncode() sp.check_returncode()
# Convenience classes for listing dependencies: # Convenience classes for listing dependencies:
class Download: class Download:
@ -447,11 +506,9 @@ class DependencyUEPlugin(Dependency):
def __init__(self, name: str, *sources): def __init__(self, name: str, *sources):
super().__init__(name, *sources) super().__init__(name, *sources)
DEFAULT_DEPENDENCIES = [ 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( Dependency(
'eigen', 'eigen',
GitRepository('https://gitlab.com/libeigen/eigen.git', tag_or_branch = '3.4.0')), 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')), GitRepository('https://github.com/glennrp/libpng.git', tag_or_branch = 'v1.6.40')),
Dependency( Dependency(
'proj', 'proj',
GitRepository('https://github.com/OSGeo/PROJ.git', tag_or_branch = '9.3.0'), 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')),
Dependency( Dependency(
'gtest', 'gtest',
GitRepository('https://github.com/google/googletest.git', tag_or_branch = 'v1.14.0')), GitRepository('https://github.com/google/googletest.git', tag_or_branch = 'v1.14.0')),
Dependency( Dependency(
'zlib', 'zlib',
GitRepository('https://github.com/madler/zlib.git'), GitRepository('https://github.com/madler/zlib.git'),),
Download('https://zlib.net/current/zlib.tar.gz')),
Dependency( Dependency(
'xercesc', 'xercesc',
GitRepository('https://github.com/apache/xerces-c.git', tag_or_branch = 'v3.2.4'), 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')),
Dependency( Dependency(
'sqlite', 'sqlite',
Download('https://www.sqlite.org/2021/sqlite-amalgamation-3340100.zip')), Download('https://www.sqlite.org/2021/sqlite-amalgamation-3340100.zip')),
@ -483,16 +536,30 @@ DEFAULT_DEPENDENCIES = [
Dependency( Dependency(
'recast', 'recast',
GitRepository('https://github.com/carla-simulator/recastnavigation.git', tag_or_branch = 'carla')), GitRepository('https://github.com/carla-simulator/recastnavigation.git', tag_or_branch = 'carla')),
] ] + [
Dependency(
# @TODO: Use these instead of full boost. 'boost',
BOOST_DEPENDENCIES_EXPERIMENTAL = [ 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( Dependency(
'boost-asio', 'boost-asio',
GitRepository('https://github.com/boostorg/asio.git')), GitRepository('https://github.com/boostorg/asio.git')),
Dependency(
'boost-iterator',
GitRepository('https://github.com/boostorg/iterator.git')),
Dependency( Dependency(
'boost-python', 'boost-python',
GitRepository('https://github.com/boostorg/python.git')), 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( Dependency(
'boost-gil', 'boost-gil',
GitRepository('https://github.com/boostorg/gil.git')), GitRepository('https://github.com/boostorg/gil.git')),
@ -577,6 +644,9 @@ class Task:
def Run(self): def Run(self):
self.body(*self.args) 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): def Validate(self):
return True 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): def Execute(self, sequential : bool = False):
if len(self.tasks) == 0: if len(self.tasks) == 0:
return return
print('-- Running task graph --')
self.Print()
from collections import deque from collections import deque
assert self.Validate() assert self.Validate()
prior_sequential = self.sequential prior_sequential = self.sequential
@ -616,11 +694,9 @@ class TaskGraph:
for in_edge in task.in_edges: for in_edge in task.in_edges:
assert in_edge != None assert in_edge != None
in_edge.out_edges.append(task) in_edge.out_edges.append(task)
task_queue = deque() task_queue = deque()
active_count = 0 active_count = 0
done_count = 0 done_count = 0
def UpdateOutEdges(task): def UpdateOutEdges(task):
nonlocal task_queue nonlocal task_queue
if len(task.out_edges) == 0: if len(task.out_edges) == 0:
@ -630,7 +706,6 @@ class TaskGraph:
out.in_edge_done_count += 1 out.in_edge_done_count += 1
if out.in_edge_done_count == len(out.in_edges): if out.in_edge_done_count == len(out.in_edges):
task_queue.append(out) task_queue.append(out)
def Flush(): def Flush():
nonlocal futures nonlocal futures
nonlocal future_map nonlocal future_map
@ -641,14 +716,13 @@ class TaskGraph:
done_tasks = [ future_map[e] for e in done ] done_tasks = [ future_map[e] for e in done ]
for e in done_tasks: for e in done_tasks:
e.done = True e.done = True
Log(f'{e.name} - done') Log(f'> {task.name} - DONE')
UpdateOutEdges(e) UpdateOutEdges(e)
assert active_count == len(done_tasks) assert active_count == len(done_tasks)
done_count += len(done_tasks) done_count += len(done_tasks)
active_count = 0 active_count = 0
future_map = {} future_map = {}
futures = [] futures = []
assert len(set(self.sources)) == len(self.sources) assert len(set(self.sources)) == len(self.sources)
task_queue.extend(self.sources) task_queue.extend(self.sources)
with ProcessPoolExecutor(self.parallelism) as pool: with ProcessPoolExecutor(self.parallelism) as pool:
@ -657,7 +731,7 @@ class TaskGraph:
while len(task_queue) != 0: while len(task_queue) != 0:
while len(task_queue) != 0 and active_count < self.parallelism: while len(task_queue) != 0 and active_count < self.parallelism:
task = task_queue.popleft() task = task_queue.popleft()
Log(f'{task.name} - start') Log(f'> {task.name} - STARTED')
if not self.sequential: if not self.sequential:
active_count += 1 active_count += 1
future = pool.submit(task.Run) future = pool.submit(task.Run)
@ -665,24 +739,25 @@ class TaskGraph:
futures.append(future) futures.append(future)
else: else:
task.Run() task.Run()
Log(f'{task.name} - done') Log(f'> {task.name} - DONE')
task.done = True task.done = True
done_count += 1 done_count += 1
UpdateOutEdges(task) UpdateOutEdges(task)
Flush() Flush()
if done_count != len(self.tasks): if done_count != len(self.tasks):
pending_tasks = [] pending_tasks = []
for e in self.tasks: for e in self.tasks:
if not e.done: if not e.done:
pending_tasks.append(e) 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 assert False
finally: finally:
print('-- Done --')
self.sequential = prior_sequential self.sequential = prior_sequential
self.Reset() self.Reset()
def UpdateGitRepository(path : Path, url : str, branch : str = None, commit : str = None): def UpdateGitRepository(path : Path, url : str, branch : str = None, commit : str = None):
if path.exists(): if path.exists():
LaunchSubprocessImmediate([ 'git', '-C', str(path), 'pull' ]) 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), 'fetch' ])
LaunchSubprocessImmediate([ 'git', '-C', str(path), 'checkout', commit ]) LaunchSubprocessImmediate([ 'git', '-C', str(path), 'checkout', commit ])
def DownloadDependency(name : str, path : Path, url : str): def DownloadDependency(name : str, path : Path, url : str):
# Download: # Download:
try: try:
@ -730,6 +807,8 @@ def DownloadDependency(name : str, path : Path, url : str):
except Exception as err: except Exception as err:
Log(f'Failed to extract dependency "{name}": {err}') Log(f'Failed to extract dependency "{name}": {err}')
def UpdateDependency(dep : Dependency): def UpdateDependency(dep : Dependency):
name = dep.name name = dep.name
@ -751,6 +830,8 @@ def UpdateDependency(dep : Dependency):
Log(f'Failed to update dependency "{name}".') Log(f'Failed to update dependency "{name}".')
assert False assert False
def UpdateDependencies(task_graph : TaskGraph): def UpdateDependencies(task_graph : TaskGraph):
DEPENDENCIES_PATH.mkdir(exist_ok = True) DEPENDENCIES_PATH.mkdir(exist_ok = True)
unique_deps = set(DEFAULT_DEPENDENCIES) 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 task_graph.Add(Task(f'update-{dep.name}', [], UpdateDependency, dep)) for dep in unique_deps
] ]
def CleanDownloadsMain(): def CleanDownloadsMain():
for ext in [ '*.tmp', '*.zip', '*.tar.gz' ]: for ext in [ '*.tmp', '*.zip', '*.tar.gz' ]:
for e in DEPENDENCIES_PATH.glob(ext): for e in DEPENDENCIES_PATH.glob(ext):
e.unlink(missing_ok = True) e.unlink(missing_ok = True)
def CleanDownloads(task_graph : TaskGraph): def CleanDownloads(task_graph : TaskGraph):
return task_graph.Add(Task('clean-downloads', [], CleanDownloadsMain)) return task_graph.Add(Task('clean-downloads', [], CleanDownloadsMain))
def ConfigureBoost(): def ConfigureBoost():
if BOOST_B2_PATH.exists(): if BOOST_B2_PATH.exists():
return return
@ -781,6 +868,8 @@ def ConfigureBoost():
[ BOOST_SOURCE_PATH / f'bootstrap{SHELL_EXT}' ], [ BOOST_SOURCE_PATH / f'bootstrap{SHELL_EXT}' ],
working_directory = BOOST_SOURCE_PATH) working_directory = BOOST_SOURCE_PATH)
def BuildAndInstallBoost(): def BuildAndInstallBoost():
LaunchSubprocessImmediate([ LaunchSubprocessImmediate([
@ -805,7 +894,7 @@ def BuildAndInstallBoost():
'install' 'install'
], ],
working_directory = BOOST_SOURCE_PATH, working_directory = BOOST_SOURCE_PATH,
log_name = 'build-boost') log_name = 'boost-build')
if (BOOST_INCLUDE_PATH / 'boost').exists(): if (BOOST_INCLUDE_PATH / 'boost').exists():
return return
candidates = glob.glob(f'{BOOST_INCLUDE_PATH}/**/boost', recursive = True) candidates = glob.glob(f'{BOOST_INCLUDE_PATH}/**/boost', recursive = True)
@ -814,6 +903,8 @@ def BuildAndInstallBoost():
shutil.move(boost_path, BOOST_INCLUDE_PATH / 'boost') shutil.move(boost_path, BOOST_INCLUDE_PATH / 'boost')
boost_path.parent.rmdir() boost_path.parent.rmdir()
def BuildSQLite(): def BuildSQLite():
SQLITE_BUILD_PATH.mkdir(exist_ok = True) SQLITE_BUILD_PATH.mkdir(exist_ok = True)
sqlite_sources = glob.glob(f'{SQLITE_SOURCE_PATH}/**/*.c', recursive = 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}') cmd.append(f'/Fe{SQLITE_EXE_PATH}')
else: else:
cmd.extend([ '-o', SQLITE_EXE_PATH ]) 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 not SQLITE_LIB_PATH.exists():
if C_COMPILER_IS_CLANG: if C_COMPILER_IS_CLANG:
cmd = [ cmd = [
@ -862,7 +953,7 @@ def BuildSQLite():
cmd.extend([ '/Fo:' if C_COMPILER_CLI_TYPE == 'msvc' else '-o', SQLITE_LIB_PATH ]) cmd.extend([ '/Fo:' if C_COMPILER_CLI_TYPE == 'msvc' else '-o', SQLITE_LIB_PATH ])
LaunchSubprocessImmediate( LaunchSubprocessImmediate(
cmd, cmd,
log_name = 'build-sqlite-lib') log_name = 'sqlite-lib-build')
else: else:
objs = [] objs = []
BUILD_TEMP_PATH.mkdir(exist_ok = True) BUILD_TEMP_PATH.mkdir(exist_ok = True)
@ -884,14 +975,16 @@ def BuildSQLite():
]) ])
obj_path = BUILD_TEMP_PATH / f'{e.name}{OBJ_EXT}' obj_path = BUILD_TEMP_PATH / f'{e.name}{OBJ_EXT}'
cmd.extend([ e, '/Fo:' if C_COMPILER_CLI_TYPE == 'msvc' else '-o', obj_path ]) 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) objs.append(obj_path)
cmd = [ cmd = [
LIB, LIB,
f'/OUT:{SQLITE_LIB_PATH}', f'/OUT:{SQLITE_LIB_PATH}',
] ]
cmd.extend(objs) cmd.extend(objs)
LaunchSubprocessImmediate(cmd, log_name = 'build-sqlite-lib') LaunchSubprocessImmediate(cmd, log_name = 'sqlite-lib-build')
def ConfigureSUMO(): def ConfigureSUMO():
xercesc_path_candidates = glob.glob(f'{XERCESC_INSTALL_PATH}/**/{LIB_PREFIX}xerces-c*{LIB_EXT}', recursive=True) 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( cmd = Task.CreateCMakeConfigureDefaultCommandLine(
SUMO_SOURCE_PATH, SUMO_SOURCE_PATH,
SUMO_BUILD_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([ cmd.extend([
SUMO_SOURCE_PATH, SUMO_SOURCE_PATH,
SUMO_BUILD_PATH, SUMO_BUILD_PATH,
f'-DZLIB_INCLUDE_DIR={ZLIB_INCLUDE_PATH}', f'-DZLIB_INCLUDE_DIR={ZLIB_INCLUDE_PATH}',
f'-DZLIB_LIBRARY={ZLIB_LIB_PATH}', f'-DZLIB_LIBRARY={ZLIB_LIB_PATH}',
f'-DPROJ_INCLUDE_DIR={PROJ_INSTALL_PATH}/include', 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_INCLUDE_DIR={XERCESC_INSTALL_PATH}/include',
f'-DXercesC_LIBRARY={XERCESC_PATH}', f'-DXercesC_LIBRARY={XERCESC_PATH}',
'-DSUMO_LIBRARIES=OFF', '-DSUMO_LIBRARIES=OFF',
@ -926,31 +1023,91 @@ def ConfigureSUMO():
]) ])
LaunchSubprocessImmediate(cmd) LaunchSubprocessImmediate(cmd)
def BuildDependencies(
task_graph : TaskGraph):
# Configure: def BuildDependencies(task_graph : TaskGraph):
build_sqlite = task_graph.Add(Task('build-sqlite', [], BuildSQLite))
task_graph.Add(Task('configure-boost', [], ConfigureBoost)) # 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 = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-zlib', 'configure-zlib',
[], [],
ZLIB_SOURCE_PATH, ZLIB_SOURCE_PATH,
ZLIB_BUILD_PATH, ZLIB_BUILD_PATH,
install_path = ZLIB_INSTALL_PATH)) install_path = ZLIB_INSTALL_PATH))
build_zlib = task_graph.Add(Task.CreateCMakeBuildDefault( build_zlib = task_graph.Add(Task.CreateCMakeBuildDefault(
'build-zlib', 'zlib-build',
[ configure_zlib ], [ configure_zlib ],
ZLIB_BUILD_PATH)) 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 ], [ build_zlib ],
ZLIB_BUILD_PATH, ZLIB_BUILD_PATH,
ZLIB_INSTALL_PATH)) ZLIB_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-gtest', 'configure-gtest',
[], [],
GTEST_SOURCE_PATH, GTEST_SOURCE_PATH,
GTEST_BUILD_PATH)) GTEST_BUILD_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libpng', 'configure-libpng',
[], [],
@ -961,6 +1118,7 @@ def BuildDependencies(
'-DPNG_BUILD_ZLIB=ON', '-DPNG_BUILD_ZLIB=ON',
f'-DZLIB_INCLUDE_DIRS={ZLIB_INCLUDE_PATH}', f'-DZLIB_INCLUDE_DIRS={ZLIB_INCLUDE_PATH}',
f'-DZLIB_LIBRARIES={ZLIB_LIB_PATH}')) f'-DZLIB_LIBRARIES={ZLIB_LIB_PATH}'))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-proj', 'configure-proj',
[ build_sqlite ], [ build_sqlite ],
@ -984,6 +1142,7 @@ def BuildDependencies(
'-DBUILD_PROJ=OFF', '-DBUILD_PROJ=OFF',
'-DBUILD_TESTING=OFF', '-DBUILD_TESTING=OFF',
install_path = PROJ_INSTALL_PATH)) install_path = PROJ_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-recast', 'configure-recast',
[], [],
@ -992,6 +1151,7 @@ def BuildDependencies(
'-DRECASTNAVIGATION_DEMO=OFF', '-DRECASTNAVIGATION_DEMO=OFF',
'-DRECASTNAVIGATION_TESTS=OFF', '-DRECASTNAVIGATION_TESTS=OFF',
'-DRECASTNAVIGATION_EXAMPLES=OFF')) '-DRECASTNAVIGATION_EXAMPLES=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-rpclib', 'configure-rpclib',
[], [],
@ -1003,11 +1163,13 @@ def BuildDependencies(
'-DRPCLIB_ENABLE_LOGGING=OFF', '-DRPCLIB_ENABLE_LOGGING=OFF',
'-DRPCLIB_ENABLE_COVERAGE=OFF', '-DRPCLIB_ENABLE_COVERAGE=OFF',
'-DRPCLIB_MSVC_STATIC_RUNTIME=OFF')) '-DRPCLIB_MSVC_STATIC_RUNTIME=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault(
configure_xercesc = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-xercesc', 'configure-xercesc',
[], [],
XERCESC_SOURCE_PATH, XERCESC_SOURCE_PATH,
XERCESC_BUILD_PATH)) XERCESC_BUILD_PATH))
if ENABLE_OSM_WORLD_RENDERER: if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libosmscout', 'configure-libosmscout',
@ -1019,11 +1181,13 @@ def BuildDependencies(
'-DOSMSCOUT_BUILD_TESTS=OFF', '-DOSMSCOUT_BUILD_TESTS=OFF',
'-DOSMSCOUT_BUILD_CLIENT_QT=OFF', '-DOSMSCOUT_BUILD_CLIENT_QT=OFF',
'-DOSMSCOUT_BUILD_DEMOS=OFF')) '-DOSMSCOUT_BUILD_DEMOS=OFF'))
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-lunasvg', 'configure-lunasvg',
[], [],
LUNASVG_SOURCE_PATH, LUNASVG_SOURCE_PATH,
LUNASVG_BUILD_PATH)) LUNASVG_BUILD_PATH))
if ENABLE_CHRONO: if ENABLE_CHRONO:
task_graph.Add(Task.CreateCMakeConfigureDefault( task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-chrono', 'configure-chrono',
@ -1033,51 +1197,84 @@ def BuildDependencies(
f'-DEIGEN3_INCLUDE_DIR={EIGEN_SOURCE_PATH}', f'-DEIGEN3_INCLUDE_DIR={EIGEN_SOURCE_PATH}',
'-DENABLE_MODULE_VEHICLE=ON')) '-DENABLE_MODULE_VEHICLE=ON'))
# SUMO requires that Proj and Xerces be built and installed before its configure step:
if ENABLE_OSM2ODR: if ENABLE_OSM2ODR:
build_xercesc = task_graph.Add(Task.CreateCMakeBuildDefault('build-xercesc', [], XERCESC_BUILD_PATH)) # SUMO requires that Proj and Xerces be built and installed before its configure step:
task_graph.Add(Task.CreateCMakeInstallDefault('install-xercesc', [ build_xercesc ], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH)) 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() task_graph.Execute()
# Build: # Build:
task_graph.Add(Task('build-boost', [], BuildAndInstallBoost))
task_graph.Add(Task.CreateCMakeBuildDefault('build-gtest', [], GTEST_BUILD_PATH)) if BOOST_USE_SUPERPROJECT:
task_graph.Add(Task.CreateCMakeBuildDefault('build-libpng', [], LIBPNG_BUILD_PATH)) task_graph.Add(Task('boost-build', [], BuildAndInstallBoost))
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))
else: 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: if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeBuildDefault('build-lunasvg', [], LUNASVG_BUILD_PATH)) task_graph.Add(Task.CreateCMakeBuildDefault('lunasvg-build', [], LUNASVG_BUILD_PATH))
task_graph.Add(Task.CreateCMakeBuildDefault('build-libosmscout', [], LIBOSMSCOUT_BUILD_PATH)) task_graph.Add(Task.CreateCMakeBuildDefault('libosmscout-build', [], LIBOSMSCOUT_BUILD_PATH))
if ENABLE_CHRONO: 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. task_graph.Execute(sequential = True) # The underlying build system should already parallelize.
# Install: # Install:
task_graph.Add(Task.CreateCMakeInstallDefault('install-gtest', [], GTEST_BUILD_PATH, GTEST_INSTALL_PATH)) if not BOOST_USE_SUPERPROJECT:
task_graph.Add(Task.CreateCMakeInstallDefault('install-libpng', [], LIBPNG_BUILD_PATH, LIBPNG_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeBuildDefault('boost-algorithm-install', [], BOOST_ALGORITHM_BUILD_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-recast', [], RECAST_BUILD_PATH, RECAST_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeBuildDefault('boost-asio-install', [], BOOST_ASIO_BUILD_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-rpclib', [], RPCLIB_BUILD_PATH, RPCLIB_INSTALL_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: if ENABLE_OSM_WORLD_RENDERER:
task_graph.Add(Task.CreateCMakeInstallDefault('install-lunasvg', [], LUNASVG_BUILD_PATH, LUNASVG_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeInstallDefault('lunasvg-install', [], LUNASVG_BUILD_PATH, LUNASVG_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-libosmscout', [], LIBOSMSCOUT_BUILD_PATH, LIBOSMSCOUT_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeInstallDefault('libosmscout-install', [], LIBOSMSCOUT_BUILD_PATH, LIBOSMSCOUT_INSTALL_PATH))
if ENABLE_OSM2ODR: 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: else:
task_graph.Add(Task.CreateCMakeInstallDefault('install-proj', [], PROJ_BUILD_PATH, PROJ_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeInstallDefault('proj-install', [], PROJ_BUILD_PATH, PROJ_INSTALL_PATH))
task_graph.Add(Task.CreateCMakeInstallDefault('install-xercesc', [], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH)) task_graph.Add(Task.CreateCMakeInstallDefault('xercesc-install', [], XERCESC_BUILD_PATH, XERCESC_INSTALL_PATH))
if ENABLE_CHRONO: 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() task_graph.Execute()
def BuildLibCarlaMain(task_graph : TaskGraph): def BuildLibCarlaMain(task_graph : TaskGraph):
configure_libcarla = task_graph.Add(Task.CreateCMakeConfigureDefault( configure_libcarla = task_graph.Add(Task.CreateCMakeConfigureDefault(
'configure-libcarla', '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'-DBUILD_OSM_WORLD_RENDERER={"ON" if ENABLE_OSM_WORLD_RENDERER else "OFF"}',
f'-DLIBCARLA_PYTORCH={"ON" if ARGV.pytorch else "OFF"}')) f'-DLIBCARLA_PYTORCH={"ON" if ARGV.pytorch else "OFF"}'))
build_libcarla = task_graph.Add(Task.CreateCMakeBuildDefault( build_libcarla = task_graph.Add(Task.CreateCMakeBuildDefault(
'build-libcarla', 'libcarla-build',
[ configure_libcarla ], [ configure_libcarla ],
LIBCARLA_BUILD_PATH)) LIBCARLA_BUILD_PATH))
return task_graph.Add(Task.CreateCMakeInstallDefault( return task_graph.Add(Task.CreateCMakeInstallDefault(
'install-libcarla', 'libcarla-install',
[ build_libcarla ], [ build_libcarla ],
LIBCARLA_BUILD_PATH, LIBCARLA_BUILD_PATH,
LIBCARLA_INSTALL_PATH)) LIBCARLA_INSTALL_PATH))
def BuildPythonAPIMain(): def BuildPythonAPIMain():
content = '' content = ''
with open(PYTHON_API_PATH / 'setup.py.in', 'r') as file: 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' sys.executable, 'setup.py', 'bdist_wheel', 'bdist_egg'
], working_directory = PYTHON_API_PATH) ], working_directory = PYTHON_API_PATH)
def BuildPythonAPI(task_graph : TaskGraph): def BuildPythonAPI(task_graph : TaskGraph):
install_libcarla = task_graph.task_map.get('install-libcarla') install_libcarla = task_graph.task_map.get('libcarla-install')
task_graph.Add(Task('build-python-api', [ install_libcarla ], BuildPythonAPIMain)) task_graph.Add(Task('python-api-build', [ install_libcarla ], BuildPythonAPIMain))
def SetupUnrealEngine(task_graph : TaskGraph): def SetupUnrealEngine(task_graph : TaskGraph):
pass pass
def BuildCarlaUEMain(): def BuildCarlaUEMain():
assert UNREAL_ENGINE_PATH.exists() assert UNREAL_ENGINE_PATH.exists()
unreal_build_tool_args = [] unreal_build_tool_args = []
@ -1141,19 +1346,23 @@ def BuildCarlaUEMain():
'-WaitMutex', '-WaitMutex',
'-FromMsBuild', '-FromMsBuild',
CARLA_UE_PATH / 'CarlaUE4.uproject', CARLA_UE_PATH / 'CarlaUE4.uproject',
], log_name = 'build-carla-ue-editor') ], log_name = 'carla-ue-editor-build')
else: else:
pass pass
def BuildCarlaUE(task_graph : TaskGraph): def BuildCarlaUE(task_graph : TaskGraph):
if ENABLE_NVIDIA_OMNIVERSE: if ENABLE_NVIDIA_OMNIVERSE:
task_graph.Add(Task('install-nv-omniverse', [], InstallNVIDIAOmniverse)) task_graph.Add(Task('nv-omniverse-install', [], InstallNVIDIAOmniverse))
dependencies = [] dependencies = []
if ENABLE_LIBCARLA: 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: if ENABLE_PYTHON_API:
dependencies.append(task_graph.task_map.get('build-python-api')) dependencies.append(task_graph.task_map.get('python-api-build'))
task_graph.Add(Task('build-carla-ue', dependencies, BuildCarlaUEMain)) task_graph.Add(Task('carla-ue-build', dependencies, BuildCarlaUEMain))
def InstallNVIDIAOmniverse(): def InstallNVIDIAOmniverse():
filename = 'USDCarlaInterface' filename = 'USDCarlaInterface'
@ -1167,6 +1376,8 @@ def InstallNVIDIAOmniverse():
for src, dst in files: for src, dst in files:
shutil.copyfile(src, dst) shutil.copyfile(src, dst)
def Clean(): def Clean():
if not BUILD_PATH.exists(): if not BUILD_PATH.exists():
return 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>. // For a copy, see <https://opensource.org/licenses/MIT>.
#pragma once #pragma once
#include <exception>
// =============================================================================
// -- Define carla::throw_exception --------------------------------------------
// =============================================================================
#ifdef LIBCARLA_NO_EXCEPTIONS #ifdef LIBCARLA_NO_EXCEPTIONS
namespace std { namespace carla
{
class exception; /// User defined function, similar to Boost throw_exception.
} // namespace std
namespace carla {
/// User define function, similar to Boost throw_exception.
/// ///
/// @important Boost exceptions are also routed to this function. /// @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 /// appropriate definition. Callers of throw_exception are allowed to assume
/// that the function never returns; therefore, if the user-defined /// that the function never returns; therefore, if the user-defined
/// throw_exception returns, the behavior is undefined. /// 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 } // namespace carla
#else #else
namespace carla { namespace carla
{
template <typename T> [[noreturn]]
[[ noreturn ]] void throw_exception(const T &e) { inline void throw_exception(const std::exception &e)
{
throw e; throw e;
} }
} // namespace carla } // namespace carla
#endif // LIBCARLA_NO_EXCEPTIONS #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 { class NoopSerializer {
public: public:
[[ noreturn ]] static SharedPtr<SensorData> Deserialize(RawData &&data); [[noreturn]] static SharedPtr<SensorData> Deserialize(RawData &&data);
}; };
} // namespace s11n } // namespace s11n

View File

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

View File

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

View File

@ -2,20 +2,27 @@
using System; using System;
using System.IO; using System.IO;
using UnrealBuildTool;
using EpicGames.Core;
using System.Linq; using System.Linq;
using System.Diagnostics; using System.Diagnostics;
using System.Collections.Generic;
using UnrealBuildTool;
using EpicGames.Core;
public class CarlaTools : public class CarlaTools :
ModuleRules ModuleRules
{ {
[CommandLine("-verbose")]
bool Verbose = true;
[CommandLine("-houdini")] [CommandLine("-houdini")]
bool EnableHoudini = false; bool EnableHoudini = false;
[CommandLine("-nv-omniverse")] [CommandLine("-nv-omniverse")]
bool EnableNVIDIAOmniverse = false; bool EnableNVIDIAOmniverse = false;
[CommandLine("-osm2odr")]
bool EnableOSM2ODR = false;
[CommandLine("-carla-install-path")] [CommandLine("-carla-install-path")]
string CarlaInstallPath = null; string CarlaInstallPath = null;
@ -28,40 +35,18 @@ public class CarlaTools :
Console.WriteLine(string.Format("{0} is {1}.", name, state)); 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) : public CarlaTools(ReadOnlyTargetRules Target) :
base(Target) base(Target)
{ {
LogFlagStatus("Houdini support", EnableHoudini); LogFlagStatus("Houdini support", EnableHoudini);
LogFlagStatus("NVIDIA Omniverse support", EnableNVIDIAOmniverse); LogFlagStatus("NVIDIA Omniverse support", EnableNVIDIAOmniverse);
if (EnableOSM2ODR)
{
PublicDefinitions.Add("WITH_OSM2ODR");
PrivateDefinitions.Add("WITH_OSM2ODR");
}
var DirectoryInfo = new DirectoryInfo(ModuleDirectory); var DirectoryInfo = new DirectoryInfo(ModuleDirectory);
for (int i = 0; i != 6; ++i) for (int i = 0; i != 6; ++i)
DirectoryInfo = DirectoryInfo.Parent; DirectoryInfo = DirectoryInfo.Parent;
@ -89,13 +74,8 @@ public class CarlaTools :
Console.WriteLine("Current module directory: " + ModuleDirectory); Console.WriteLine("Current module directory: " + ModuleDirectory);
bool IsWindows = Target.Platform == UnrealTargetPlatform.Win64; bool IsWindows = Target.Platform == UnrealTargetPlatform.Win64;
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
bEnableExceptions = bEnableExceptions || IsWindows; bEnableExceptions = bEnableExceptions || IsWindows;
// PrivatePCHHeaderFile = "Carla.h";
// PublicIncludePaths.AddRange(new string[] { });
// PrivateIncludePaths.AddRange(new string[] { });
PublicDependencyModuleNames.AddRange(new string[] PublicDependencyModuleNames.AddRange(new string[]
{ {
@ -103,8 +83,8 @@ public class CarlaTools :
"ProceduralMeshComponent", "ProceduralMeshComponent",
"MeshDescription", "MeshDescription",
"RawMesh", "RawMesh",
"AssetTools" "AssetTools",
}); });
PrivateDependencyModuleNames.AddRange(new string[] PrivateDependencyModuleNames.AddRange(new string[]
{ {
@ -118,8 +98,8 @@ public class CarlaTools :
"EditorScriptingUtilities", "EditorScriptingUtilities",
"Landscape", "Landscape",
"Foliage", "Foliage",
"FoliageEdit", "FoliageEdit",
"MeshMergeUtilities", "MeshMergeUtilities",
"Carla", "Carla",
"StaticMeshDescription", "StaticMeshDescription",
"ChaosVehicles", "ChaosVehicles",
@ -132,7 +112,7 @@ public class CarlaTools :
"RenderCore", "RenderCore",
"MeshMergeUtilities", "MeshMergeUtilities",
"StreetMapImporting", "StreetMapImporting",
"StreetMapRuntime" "StreetMapRuntime",
}); });
if (EnableHoudini) if (EnableHoudini)
@ -198,33 +178,40 @@ public class CarlaTools :
var LibCarlaLibPath = Path.Combine(LibCarlaInstallPath, "lib"); var LibCarlaLibPath = Path.Combine(LibCarlaInstallPath, "lib");
var LibCarlaServerPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-server")); var LibCarlaServerPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-server"));
var LibCarlaClientPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-client")); var LibCarlaClientPath = Path.Combine(LibCarlaLibPath, GetLibraryName("carla-client"));
// Boost // Boost
var BoostLibraryPatterns = new string[] var BoostLibraryPatterns = new string[]
{ {
GetLibraryName("*boost_asio*"), "libboost_atomic*",
GetLibraryName("*boost_python*"), "libboost_date_time*",
"libboost_filesystem*",
"libboost_numpy*",
"libboost_python*",
"libboost_system*",
}; };
var BoostLibraries = var BoostLibraries =
from Pattern in BoostLibraryPatterns from Pattern in BoostLibraryPatterns
from Candidate in FindLibraries("boost", Pattern) select FindLibraries("boost", Pattern)[0];
select Candidate;
// SQLite
var SQLiteBuildPath = Path.Combine(DependenciesInstallPath, "sqlite-build"); var SQLiteBuildPath = Path.Combine(DependenciesInstallPath, "sqlite-build");
var SQLiteLibrary = Directory.GetFiles(SQLiteBuildPath, GetLibraryName("sqlite*"))[0]; var SQLiteLibrary = Directory.GetFiles(SQLiteBuildPath, GetLibraryName("sqlite*"))[0];
PublicIncludePaths.Add(ModuleDirectory); var AdditionalLibraries = new List<string>
PublicIncludePaths.Add(LibCarlaIncludePath);
PublicAdditionalLibraries.AddRange(BoostLibraries);
PublicAdditionalLibraries.AddRange(new string[]
{ {
SQLiteLibrary, SQLiteLibrary,
FindLibraries("rpclib", "rpc")[0], FindLibraries("rpclib", "rpc")[0],
FindLibraries("xercesc", "xerces-c*")[0], FindLibraries("xercesc", "xerces-c*")[0],
FindLibraries("proj", "proj")[0], FindLibraries("proj", "proj")[0],
FindLibraries("sumo", "*osm2odr")[0],
FindLibraries("zlib", "zlib*")[0], FindLibraries("zlib", "zlib*")[0],
}); };
if (EnableOSM2ODR)
AdditionalLibraries.Add(FindLibraries("sumo", "*osm2odr")[0]);
PublicIncludePaths.Add(ModuleDirectory);
PublicIncludePaths.Add(LibCarlaIncludePath);
PublicIncludePaths.AddRange(new string[] PublicIncludePaths.AddRange(new string[]
{ {
GetIncludePath("boost"), GetIncludePath("boost"),
@ -233,5 +220,28 @@ public class CarlaTools :
GetIncludePath("sumo"), GetIncludePath("sumo"),
GetIncludePath("zlib"), 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) void UCustomFileDownloader::ConvertOSMInOpenDrive(FString FilePath, float Lat_0, float Lon_0)
{ {
#ifdef WITH_OSM2ODR
IPlatformFile &FileManager = FPlatformFileManager::Get().GetPlatformFile(); IPlatformFile &FileManager = FPlatformFileManager::Get().GetPlatformFile();
FString FileContent; 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.")); 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() void UCustomFileDownloader::StartDownload()