2020-01-17 10:22:00 -08:00
|
|
|
import os
|
|
|
|
|
import subprocess
|
|
|
|
|
import sys
|
2020-12-14 00:46:07 -08:00
|
|
|
import sysconfig
|
2020-02-01 23:36:50 -08:00
|
|
|
import platform
|
2020-11-11 21:14:51 +01:00
|
|
|
import numpy as np
|
2020-01-17 10:22:00 -08:00
|
|
|
|
2023-04-06 20:42:19 -07:00
|
|
|
import SCons.Errors
|
|
|
|
|
|
2023-04-22 15:24:45 -07:00
|
|
|
SCons.Warnings.warningAsException(True)
|
|
|
|
|
|
2024-01-11 14:16:09 -05:00
|
|
|
# pending upstream fix - https://github.com/SCons/scons/issues/4461
|
|
|
|
|
#SetOption('warn', 'all')
|
|
|
|
|
|
2020-09-24 19:24:14 +02:00
|
|
|
TICI = os.path.isfile('/TICI')
|
2022-06-13 09:50:40 +02:00
|
|
|
AGNOS = TICI
|
2022-06-02 15:20:51 +02:00
|
|
|
|
2020-10-12 18:46:37 +02:00
|
|
|
Decider('MD5-timestamp')
|
2020-09-24 19:24:14 +02:00
|
|
|
|
2024-01-03 11:16:54 -08:00
|
|
|
SetOption('num_jobs', int(os.cpu_count()/2))
|
|
|
|
|
|
2021-04-14 16:17:30 +02:00
|
|
|
AddOption('--kaitai',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='Regenerate kaitai struct parsers')
|
|
|
|
|
|
2020-01-17 10:22:00 -08:00
|
|
|
AddOption('--asan',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='turn on ASAN')
|
|
|
|
|
|
2021-01-12 00:03:31 -08:00
|
|
|
AddOption('--ubsan',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='turn on UBSan')
|
|
|
|
|
|
2023-10-30 13:08:43 -07:00
|
|
|
AddOption('--coverage',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='build with test coverage options')
|
|
|
|
|
|
2020-12-18 19:26:59 -08:00
|
|
|
AddOption('--clazy',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='build with clazy')
|
|
|
|
|
|
2021-01-05 12:50:23 -08:00
|
|
|
AddOption('--compile_db',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='build clang compilation database')
|
2024-01-03 11:16:54 -08:00
|
|
|
|
2023-11-17 22:53:16 +01:00
|
|
|
AddOption('--ccflags',
|
|
|
|
|
action='store',
|
|
|
|
|
type='string',
|
|
|
|
|
default='',
|
|
|
|
|
help='pass arbitrary flags over the command line')
|
2021-01-05 12:50:23 -08:00
|
|
|
|
2021-01-18 14:32:29 +01:00
|
|
|
AddOption('--external-sconscript',
|
|
|
|
|
action='store',
|
|
|
|
|
metavar='FILE',
|
|
|
|
|
dest='external_sconscript',
|
|
|
|
|
help='add an external SConscript to the build')
|
|
|
|
|
|
2022-09-01 10:31:14 -07:00
|
|
|
AddOption('--pc-thneed',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='pc_thneed',
|
|
|
|
|
help='use thneed on pc')
|
|
|
|
|
|
2024-09-30 13:46:04 -07:00
|
|
|
AddOption('--mutation',
|
|
|
|
|
action='store_true',
|
|
|
|
|
help='generate mutation-ready code')
|
|
|
|
|
|
2023-08-24 14:58:30 -07:00
|
|
|
AddOption('--minimal',
|
2022-08-25 16:22:52 -07:00
|
|
|
action='store_false',
|
2023-08-24 14:58:30 -07:00
|
|
|
dest='extras',
|
2024-06-07 15:26:55 -07:00
|
|
|
default=os.path.exists(File('#.lfsconfig').abspath), # minimal by default on release branch (where there's no LFS)
|
2023-08-24 14:58:30 -07:00
|
|
|
help='the minimum build to run openpilot. no tests, tools, etc.')
|
2022-08-25 16:22:52 -07:00
|
|
|
|
2025-01-03 15:04:09 -05:00
|
|
|
AddOption('--stock-ui',
|
|
|
|
|
action='store_true',
|
|
|
|
|
dest='stock_ui',
|
|
|
|
|
default=False,
|
|
|
|
|
help='Build stock openpilot UI instead of sunnypilot UI')
|
|
|
|
|
|
2023-08-02 01:18:46 +02:00
|
|
|
## Architecture name breakdown (arch)
|
|
|
|
|
## - larch64: linux tici aarch64
|
|
|
|
|
## - aarch64: linux pc aarch64
|
|
|
|
|
## - x86_64: linux pc x64
|
|
|
|
|
## - Darwin: mac x64 or arm64
|
2020-08-31 15:02:01 +02:00
|
|
|
real_arch = arch = subprocess.check_output(["uname", "-m"], encoding='utf8').rstrip()
|
2020-02-01 23:36:50 -08:00
|
|
|
if platform.system() == "Darwin":
|
|
|
|
|
arch = "Darwin"
|
2023-06-21 22:14:20 +02:00
|
|
|
brew_prefix = subprocess.check_output(['brew', '--prefix'], encoding='utf8').strip()
|
2023-08-02 01:18:46 +02:00
|
|
|
elif arch == "aarch64" and AGNOS:
|
2020-03-31 16:34:55 -07:00
|
|
|
arch = "larch64"
|
2023-08-02 01:18:46 +02:00
|
|
|
assert arch in ["larch64", "aarch64", "x86_64", "Darwin"]
|
2020-01-17 10:22:00 -08:00
|
|
|
|
2021-01-04 14:17:14 -08:00
|
|
|
lenv = {
|
|
|
|
|
"PATH": os.environ['PATH'],
|
2021-10-07 16:32:44 -07:00
|
|
|
"LD_LIBRARY_PATH": [Dir(f"#third_party/acados/{arch}/lib").abspath],
|
2023-08-15 18:53:21 -04:00
|
|
|
"PYTHONPATH": Dir("#").abspath + ':' + Dir(f"#third_party/acados").abspath,
|
2021-09-13 19:06:54 -07:00
|
|
|
|
2023-06-21 22:14:20 +02:00
|
|
|
"ACADOS_SOURCE_DIR": Dir("#third_party/acados").abspath,
|
2022-12-31 21:00:50 -08:00
|
|
|
"ACADOS_PYTHON_INTERFACE_PATH": Dir("#third_party/acados/acados_template").abspath,
|
2022-09-05 18:07:45 -07:00
|
|
|
"TERA_PATH": Dir("#").abspath + f"/third_party/acados/{arch}/t_renderer"
|
2021-01-04 14:17:14 -08:00
|
|
|
}
|
|
|
|
|
|
2021-09-13 19:06:54 -07:00
|
|
|
rpath = lenv["LD_LIBRARY_PATH"].copy()
|
|
|
|
|
|
2022-04-18 17:55:23 -07:00
|
|
|
if arch == "larch64":
|
2020-01-17 10:22:00 -08:00
|
|
|
cpppath = [
|
2021-10-07 16:32:44 -07:00
|
|
|
"#third_party/opencl/include",
|
2020-01-17 10:22:00 -08:00
|
|
|
]
|
2020-03-31 16:34:55 -07:00
|
|
|
|
2020-01-17 10:22:00 -08:00
|
|
|
libpath = [
|
2021-02-04 19:11:29 +01:00
|
|
|
"/usr/local/lib",
|
2020-01-17 10:22:00 -08:00
|
|
|
"/system/vendor/lib64",
|
2021-10-07 16:32:44 -07:00
|
|
|
f"#third_party/acados/{arch}/lib",
|
2020-01-17 10:22:00 -08:00
|
|
|
]
|
|
|
|
|
|
2022-04-18 17:55:23 -07:00
|
|
|
libpath += [
|
|
|
|
|
"#third_party/snpe/larch64",
|
|
|
|
|
"#third_party/libyuv/larch64/lib",
|
|
|
|
|
"/usr/lib/aarch64-linux-gnu"
|
|
|
|
|
]
|
|
|
|
|
cflags = ["-DQCOM2", "-mcpu=cortex-a57"]
|
|
|
|
|
cxxflags = ["-DQCOM2", "-mcpu=cortex-a57"]
|
|
|
|
|
rpath += ["/usr/local/lib"]
|
2020-01-17 10:22:00 -08:00
|
|
|
else:
|
2020-06-11 18:21:59 -07:00
|
|
|
cflags = []
|
|
|
|
|
cxxflags = []
|
2021-01-04 14:17:14 -08:00
|
|
|
cpppath = []
|
2023-11-22 13:25:29 -08:00
|
|
|
rpath += []
|
2020-02-01 23:36:50 -08:00
|
|
|
|
2022-02-23 13:52:38 +01:00
|
|
|
# MacOS
|
2020-02-01 23:36:50 -08:00
|
|
|
if arch == "Darwin":
|
|
|
|
|
libpath = [
|
2023-07-28 02:43:30 +02:00
|
|
|
f"#third_party/libyuv/{arch}/lib",
|
2023-06-21 22:14:20 +02:00
|
|
|
f"#third_party/acados/{arch}/lib",
|
2022-02-23 13:52:38 +01:00
|
|
|
f"{brew_prefix}/lib",
|
2023-04-19 22:31:19 +02:00
|
|
|
f"{brew_prefix}/opt/openssl@3.0/lib",
|
2020-02-01 23:36:50 -08:00
|
|
|
"/System/Library/Frameworks/OpenGL.framework/Libraries",
|
|
|
|
|
]
|
2022-09-05 18:07:45 -07:00
|
|
|
|
2020-07-10 15:26:16 -07:00
|
|
|
cflags += ["-DGL_SILENCE_DEPRECATION"]
|
|
|
|
|
cxxflags += ["-DGL_SILENCE_DEPRECATION"]
|
2021-05-02 14:21:49 -07:00
|
|
|
cpppath += [
|
2022-02-23 13:52:38 +01:00
|
|
|
f"{brew_prefix}/include",
|
2023-04-19 22:31:19 +02:00
|
|
|
f"{brew_prefix}/opt/openssl@3.0/include",
|
2021-05-02 14:21:49 -07:00
|
|
|
]
|
2023-06-21 22:14:20 +02:00
|
|
|
lenv["DYLD_LIBRARY_PATH"] = lenv["LD_LIBRARY_PATH"]
|
2023-08-02 01:18:46 +02:00
|
|
|
# Linux
|
2020-02-01 23:36:50 -08:00
|
|
|
else:
|
|
|
|
|
libpath = [
|
2023-08-02 01:18:46 +02:00
|
|
|
f"#third_party/acados/{arch}/lib",
|
|
|
|
|
f"#third_party/libyuv/{arch}/lib",
|
2020-02-01 23:36:50 -08:00
|
|
|
"/usr/lib",
|
|
|
|
|
"/usr/local/lib",
|
|
|
|
|
]
|
2023-08-02 01:18:46 +02:00
|
|
|
|
|
|
|
|
if arch == "x86_64":
|
|
|
|
|
libpath += [
|
|
|
|
|
f"#third_party/snpe/{arch}"
|
|
|
|
|
]
|
|
|
|
|
rpath += [
|
|
|
|
|
Dir(f"#third_party/snpe/{arch}").abspath,
|
|
|
|
|
]
|
2020-01-17 10:22:00 -08:00
|
|
|
|
2020-07-10 15:26:16 -07:00
|
|
|
if GetOption('asan'):
|
2021-01-12 00:03:31 -08:00
|
|
|
ccflags = ["-fsanitize=address", "-fno-omit-frame-pointer"]
|
|
|
|
|
ldflags = ["-fsanitize=address"]
|
|
|
|
|
elif GetOption('ubsan'):
|
|
|
|
|
ccflags = ["-fsanitize=undefined"]
|
|
|
|
|
ldflags = ["-fsanitize=undefined"]
|
2020-07-10 15:26:16 -07:00
|
|
|
else:
|
2021-01-12 00:03:31 -08:00
|
|
|
ccflags = []
|
|
|
|
|
ldflags = []
|
2020-01-17 10:22:00 -08:00
|
|
|
|
2021-04-08 11:17:07 -07:00
|
|
|
# no --as-needed on mac linker
|
|
|
|
|
if arch != "Darwin":
|
2021-09-13 19:06:54 -07:00
|
|
|
ldflags += ["-Wl,--as-needed", "-Wl,--no-undefined"]
|
2021-04-08 11:17:07 -07:00
|
|
|
|
2025-01-03 15:04:09 -05:00
|
|
|
if not GetOption('stock_ui'):
|
|
|
|
|
cflags += ["-DSUNNYPILOT"]
|
|
|
|
|
cxxflags += ["-DSUNNYPILOT"]
|
|
|
|
|
|
2023-11-17 22:53:16 +01:00
|
|
|
ccflags_option = GetOption('ccflags')
|
|
|
|
|
if ccflags_option:
|
|
|
|
|
ccflags += ccflags_option.split(' ')
|
|
|
|
|
|
2020-01-17 10:22:00 -08:00
|
|
|
env = Environment(
|
|
|
|
|
ENV=lenv,
|
|
|
|
|
CCFLAGS=[
|
|
|
|
|
"-g",
|
|
|
|
|
"-fPIC",
|
|
|
|
|
"-O2",
|
2020-07-09 09:25:32 -07:00
|
|
|
"-Wunused",
|
2020-05-26 13:27:01 -07:00
|
|
|
"-Werror",
|
2021-11-02 12:08:53 -04:00
|
|
|
"-Wshadow",
|
2020-09-30 14:58:56 +02:00
|
|
|
"-Wno-unknown-warning-option",
|
2020-05-26 13:27:01 -07:00
|
|
|
"-Wno-inconsistent-missing-override",
|
2020-09-30 14:58:56 +02:00
|
|
|
"-Wno-c99-designator",
|
|
|
|
|
"-Wno-reorder-init-list",
|
2024-04-28 16:24:04 -07:00
|
|
|
"-Wno-vla-cxx-extension",
|
2021-01-12 00:03:31 -08:00
|
|
|
] + cflags + ccflags,
|
2020-01-17 10:22:00 -08:00
|
|
|
|
|
|
|
|
CPPPATH=cpppath + [
|
|
|
|
|
"#",
|
2021-10-07 16:32:44 -07:00
|
|
|
"#third_party/acados/include",
|
|
|
|
|
"#third_party/acados/include/blasfeo/include",
|
|
|
|
|
"#third_party/acados/include/hpipm/include",
|
|
|
|
|
"#third_party/catch2/include",
|
|
|
|
|
"#third_party/libyuv/include",
|
2024-01-22 22:41:59 -08:00
|
|
|
"#third_party/json11",
|
2021-10-07 16:32:44 -07:00
|
|
|
"#third_party/linux/include",
|
|
|
|
|
"#third_party/snpe/include",
|
|
|
|
|
"#third_party",
|
2024-06-06 14:31:56 -07:00
|
|
|
"#msgq",
|
2020-01-17 10:22:00 -08:00
|
|
|
],
|
|
|
|
|
|
|
|
|
|
CC='clang',
|
|
|
|
|
CXX='clang++',
|
2021-01-12 00:03:31 -08:00
|
|
|
LINKFLAGS=ldflags,
|
2020-01-17 10:22:00 -08:00
|
|
|
|
|
|
|
|
RPATH=rpath,
|
|
|
|
|
|
|
|
|
|
CFLAGS=["-std=gnu11"] + cflags,
|
2020-10-17 22:33:12 +02:00
|
|
|
CXXFLAGS=["-std=c++1z"] + cxxflags,
|
2020-07-10 15:26:16 -07:00
|
|
|
LIBPATH=libpath + [
|
2024-06-10 13:18:47 -07:00
|
|
|
"#msgq_repo",
|
2021-10-07 16:32:44 -07:00
|
|
|
"#third_party",
|
2024-06-04 19:16:55 -07:00
|
|
|
"#selfdrive/pandad",
|
2022-05-18 14:11:57 -07:00
|
|
|
"#common",
|
2023-11-22 13:25:29 -08:00
|
|
|
"#rednose/helpers",
|
2020-11-11 21:14:51 +01:00
|
|
|
],
|
|
|
|
|
CYTHONCFILESUFFIX=".cpp",
|
2020-12-14 00:46:07 -08:00
|
|
|
COMPILATIONDB_USE_ABSPATH=True,
|
2023-11-22 13:25:29 -08:00
|
|
|
REDNOSE_ROOT="#",
|
|
|
|
|
tools=["default", "cython", "compilation_db", "rednose_filter"],
|
2024-07-30 13:11:05 -07:00
|
|
|
toolpath=["#site_scons/site_tools", "#rednose_repo/site_scons/site_tools"],
|
2020-01-17 10:22:00 -08:00
|
|
|
)
|
2020-11-16 21:33:33 -08:00
|
|
|
|
2022-01-07 15:15:18 -08:00
|
|
|
if arch == "Darwin":
|
2023-06-21 22:14:20 +02:00
|
|
|
# RPATH is not supported on macOS, instead use the linker flags
|
|
|
|
|
darwin_rpath_link_flags = [f"-Wl,-rpath,{path}" for path in env["RPATH"]]
|
|
|
|
|
env["LINKFLAGS"] += darwin_rpath_link_flags
|
2022-01-07 15:15:18 -08:00
|
|
|
|
2021-01-05 12:50:23 -08:00
|
|
|
if GetOption('compile_db'):
|
2020-12-14 00:46:07 -08:00
|
|
|
env.CompilationDatabase('compile_commands.json')
|
|
|
|
|
|
2021-06-01 17:12:32 -07:00
|
|
|
# Setup cache dir
|
CI: Build prebuilts and models from github and self hosted runners (#476)
* Create a GitHub Actions workflow for synchronizing the repository to GitLab and enhance GitLab CI settings
A new GitHub Actions workflow for mirroring the current repository to GitLab is added. This workflow is triggered by both push and delete events in addition to manual triggering. The role of GitHub actions runner is defined through a series of steps. A new '.gitlab-ci.yml' build configuration file is also introduced, with a more comprehensive definition of variables, jobs, and pipeline rules for its utilization in the GitLab CI/CD pipeline.
Further, other changes include the addition of scripts for installing and uninstalling GitLab CI runner, along with modifying the SCons build system configuration file to include custom cache directory. Moreover, 'release_files.py' has been revised to include additional blacklisted and whitelisted files specific to Sunnypilot, ensuring suitable settings for the CI flow.
The improvements facilitate a smoother integration between GitHub and GitLab, powerfully harnessing the capabilities of both platforms for more efficient and effective CI/CD pipelines and version control management.
* not needed for this
* Update workflow to build model from upstream repository
Revised the CI workflow to build directly from the upstream `commaai/openpilot` repository. Simplified configuration, removed unused steps, and added support for specifying the upstream branch dynamically via inputs.
* Update SConstruct to allow passing arbitrary cache_dir
Modified the SConstruct file to enable setting a custom cache directory via arguments. This enhances flexibility in configuring cache paths during the build process.
* Refactor build workflow to improve branch handling logic.
Reorganized conditions for setting environment variables, replacing repository_dispatch with workflow_dispatch for prebuilt builds. Added a fallback error message for unsupported triggers to improve robustness. This enhances clarity and ensures compatibility with the intended workflow triggers.
* test test test
* test test test
* test test test
* Enable publication flag during build configurations
Added `SHOULD_PUBLISH=true` to all relevant build configuration steps to ensure proper handling of publishing logic. Updated environment variables to include this flag for downstream usage. Removed the error-check step for unsupported configurations.
* Simplify publish condition in workflow logic
Replaced the previous condition for publishing with a single output variable, `should_publish`, to streamline logic and improve maintainability. This change reduces redundancy and makes the workflow more adaptable to future updates.
* Simplify restore key patterns in build workflow.
Removed unnecessary trailing dashes in SCons cache restore keys to streamline and slightly improve key matching logic. This ensures better consistency with the current workflow setup.
* Update cache key usage in build workflow
Replaced `github.ref_name` with `github.head_ref` for cache keys to ensure accurate branch-specific caching. Added fallback restore-keys for master branches to improve cache efficiency and reduce redundant builds.
* Improved debug logging in GitHub actions workflow
This commit refines the debug logging in our GitHub Actions workflow for the Sunnypilot build. This change provides more granularity, enabling logging only during debug mode, which helps to keep the runtime logs less cluttered during normal operations. This includes the conditionally displaying of environmental variables, GitHub output contents, and directory listings.
Additionally, debug mode verbosity was added to rsync commands to aid troubleshooting file transfers during the build process.
Blank lines were also reduced for better readability and cleaner code presentation.
* test diff path
* Refactor SCons cache handling in build workflow
Replaced hardcoded cache directory paths with an environment variable (`SCONS_CACHE_DIR`) for better maintainability and flexibility. Updated related workflow steps to utilize the new variable and adjusted cache key usage. Removed unused `BASE_BUILD_NUMBER` variable to clean up the configuration.
* Update cache key to include commit SHA in workflow
This change adds the commit SHA to the cache key in the GitHub Actions workflow. It ensures more precise caching by differentiating builds based on the specific commit, reducing potential conflicts.
* clean
Update GitHub runner service to set environment variables
Updated the ExecStart command to explicitly set HOME, USER, LOGNAME, and MAIL environment variables. This ensures the runner operates with the correct environment configuration, improving reliability and compatibility.
Refactor GitHub runner service ExecStart command.
Replaced direct command execution with running the service as a specific user using `su`. This improves compatibility and aligns with best practices for user-based execution. No functional changes are expected.
Update GitHub runner service to set environment variables
The ExecStart command now sets HOME, USER, LOGNAME, and MAIL environment variables for the runner process. This ensures proper environment initialization for the designated user, improving compatibility and reliability during execution.
Refactor GitHub runner service template handling.
Revised the `modify_service_template` function to create a properly structured service template for the GitHub runner. Updated service permissions, execution parameters, and enabled the function call to ensure usage during runner setup.
* Refactor GitHub Runner installer to improve argument parsing.
Reworked the script to implement flexible and explicit command-line argument parsing using flags like `--token`, `--repo`, and `--start-at-boot`. Added support for setting default values and enabling/disabling auto-start based on the `--start-at-boot` flag. Improved error handling and usage messaging for better user experience.
* Update cache keys in sunnypilot build workflow
Modified the cache keys to include `github.ref_name` for more precise caching and restore behavior. This improves build consistency by better differentiating between branches and refs. No changes to the overall workflow logic.
* Remove 'tinygrad/*' from release file exclusions
This change modifies the release file exclusions by removing 'tinygrad/*'. The adjustment ensures that files in the 'tinygrad' directory are now included in the release process, aligning with updated packaging requirements.
* Simplify release file exclusions list.
Removed redundant and unnecessary file patterns from the exclusions list in `release_files.py`. This streamlines the file handling process and reduces maintenance overhead.
* Refactor SCons cache path and key structure.
Updated the SCons cache directory path to `SCONS_CACHE_DIR` for clarity and consistency. Improved the caching key structure to include `github.head_ref` for better cache differentiation and restore hierarchy. Adjusted related build instructions to reflect the new environment variable.
* Refactor branch configuration in CI workflow
Standardize branch name handling by replacing hardcoded values with environment variables. This improves maintainability and simplifies updates to branch names across the workflow. Updated references to use the new dynamic environment variable approach.
2024-12-21 20:19:48 +01:00
|
|
|
default_cache_dir = '/data/scons_cache' if AGNOS else '/tmp/scons_cache'
|
|
|
|
|
cache_dir = ARGUMENTS.get('cache_dir', default_cache_dir)
|
2021-06-01 17:12:32 -07:00
|
|
|
CacheDir(cache_dir)
|
|
|
|
|
Clean(["."], cache_dir)
|
2020-01-17 10:22:00 -08:00
|
|
|
|
|
|
|
|
node_interval = 5
|
|
|
|
|
node_count = 0
|
|
|
|
|
def progress_function(node):
|
|
|
|
|
global node_count
|
|
|
|
|
node_count += node_interval
|
|
|
|
|
sys.stderr.write("progress: %d\n" % node_count)
|
|
|
|
|
|
|
|
|
|
if os.environ.get('SCONS_PROGRESS'):
|
|
|
|
|
Progress(progress_function, interval=node_interval)
|
|
|
|
|
|
2022-08-30 11:20:55 -07:00
|
|
|
# Cython build environment
|
2020-12-14 00:46:07 -08:00
|
|
|
py_include = sysconfig.get_paths()['include']
|
2020-11-11 21:14:51 +01:00
|
|
|
envCython = env.Clone()
|
2020-12-14 00:46:07 -08:00
|
|
|
envCython["CPPPATH"] += [py_include, np.get_include()]
|
2021-11-02 12:08:53 -04:00
|
|
|
envCython["CCFLAGS"] += ["-Wno-#warnings", "-Wno-shadow", "-Wno-deprecated-declarations"]
|
2023-07-20 21:56:57 -07:00
|
|
|
envCython["CCFLAGS"].remove("-Werror")
|
2020-11-11 21:14:51 +01:00
|
|
|
|
2020-12-14 00:46:07 -08:00
|
|
|
envCython["LIBS"] = []
|
2020-11-11 21:14:51 +01:00
|
|
|
if arch == "Darwin":
|
2023-06-21 22:14:20 +02:00
|
|
|
envCython["LINKFLAGS"] = ["-bundle", "-undefined", "dynamic_lookup"] + darwin_rpath_link_flags
|
2020-11-11 21:14:51 +01:00
|
|
|
else:
|
2020-12-14 00:46:07 -08:00
|
|
|
envCython["LINKFLAGS"] = ["-pthread", "-shared"]
|
2020-11-11 21:14:51 +01:00
|
|
|
|
2024-07-30 13:11:05 -07:00
|
|
|
np_version = SCons.Script.Value(np.__version__)
|
|
|
|
|
Export('envCython', 'np_version')
|
2020-11-11 21:14:51 +01:00
|
|
|
|
2020-12-20 19:39:59 -08:00
|
|
|
# Qt build environment
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_env = env.Clone()
|
2024-08-24 01:56:31 +08:00
|
|
|
qt_modules = ["Widgets", "Gui", "Core", "Network", "Concurrent", "DBus", "Xml"]
|
2020-12-20 19:39:59 -08:00
|
|
|
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_libs = []
|
|
|
|
|
if arch == "Darwin":
|
2023-06-21 22:14:20 +02:00
|
|
|
qt_env['QTDIR'] = f"{brew_prefix}/opt/qt@5"
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_dirs = [
|
2021-03-09 17:33:45 -08:00
|
|
|
os.path.join(qt_env['QTDIR'], "include"),
|
2021-02-25 22:19:53 -08:00
|
|
|
]
|
2021-03-09 17:33:45 -08:00
|
|
|
qt_dirs += [f"{qt_env['QTDIR']}/include/Qt{m}" for m in qt_modules]
|
|
|
|
|
qt_env["LINKFLAGS"] += ["-F" + os.path.join(qt_env['QTDIR'], "lib")]
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_env["FRAMEWORKS"] += [f"Qt{m}" for m in qt_modules] + ["OpenGL"]
|
2022-01-07 15:15:18 -08:00
|
|
|
qt_env.AppendENVPath('PATH', os.path.join(qt_env['QTDIR'], "bin"))
|
2021-02-25 22:19:53 -08:00
|
|
|
else:
|
2022-11-17 00:45:28 +01:00
|
|
|
qt_install_prefix = subprocess.check_output(['qmake', '-query', 'QT_INSTALL_PREFIX'], encoding='utf8').strip()
|
|
|
|
|
qt_install_headers = subprocess.check_output(['qmake', '-query', 'QT_INSTALL_HEADERS'], encoding='utf8').strip()
|
2022-11-30 20:27:55 -08:00
|
|
|
|
2022-11-17 00:45:28 +01:00
|
|
|
qt_env['QTDIR'] = qt_install_prefix
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_dirs = [
|
2022-11-17 00:45:28 +01:00
|
|
|
f"{qt_install_headers}",
|
2020-12-20 19:39:59 -08:00
|
|
|
]
|
2024-01-19 23:28:29 +02:00
|
|
|
|
|
|
|
|
qt_gui_path = os.path.join(qt_install_headers, "QtGui")
|
|
|
|
|
qt_gui_dirs = [d for d in os.listdir(qt_gui_path) if os.path.isdir(os.path.join(qt_gui_path, d))]
|
2024-01-19 13:45:06 -08:00
|
|
|
qt_dirs += [f"{qt_install_headers}/QtGui/{qt_gui_dirs[0]}/QtGui", ] if qt_gui_dirs else []
|
2022-11-17 00:45:28 +01:00
|
|
|
qt_dirs += [f"{qt_install_headers}/Qt{m}" for m in qt_modules]
|
2021-02-25 22:19:53 -08:00
|
|
|
|
|
|
|
|
qt_libs = [f"Qt5{m}" for m in qt_modules]
|
|
|
|
|
if arch == "larch64":
|
|
|
|
|
qt_libs += ["GLESv2", "wayland-client"]
|
2023-01-20 14:11:43 -08:00
|
|
|
qt_env.PrependENVPath('PATH', Dir("#third_party/qt5/larch64/bin/").abspath)
|
2021-02-25 22:19:53 -08:00
|
|
|
elif arch != "Darwin":
|
|
|
|
|
qt_libs += ["GL"]
|
2023-04-23 18:02:54 -07:00
|
|
|
qt_env['QT3DIR'] = qt_env['QTDIR']
|
2021-02-25 22:19:53 -08:00
|
|
|
|
2023-04-23 18:02:54 -07:00
|
|
|
# compatibility for older SCons versions
|
2023-04-06 20:42:19 -07:00
|
|
|
try:
|
|
|
|
|
qt_env.Tool('qt3')
|
|
|
|
|
except SCons.Errors.UserError:
|
|
|
|
|
qt_env.Tool('qt')
|
|
|
|
|
|
2024-07-26 01:16:59 +08:00
|
|
|
qt_env['CPPPATH'] += qt_dirs + ["#third_party/qrcode"]
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_flags = [
|
|
|
|
|
"-D_REENTRANT",
|
|
|
|
|
"-DQT_NO_DEBUG",
|
|
|
|
|
"-DQT_WIDGETS_LIB",
|
|
|
|
|
"-DQT_GUI_LIB",
|
2021-07-02 14:01:59 +02:00
|
|
|
"-DQT_CORE_LIB",
|
|
|
|
|
"-DQT_MESSAGELOGCONTEXT",
|
2021-02-25 22:19:53 -08:00
|
|
|
]
|
|
|
|
|
qt_env['CXXFLAGS'] += qt_flags
|
2024-06-19 19:14:13 -07:00
|
|
|
qt_env['LIBPATH'] += ['#selfdrive/ui', ]
|
2021-02-25 22:19:53 -08:00
|
|
|
qt_env['LIBS'] = qt_libs
|
2023-08-17 10:30:55 -07:00
|
|
|
|
2021-02-25 22:19:53 -08:00
|
|
|
if GetOption("clazy"):
|
|
|
|
|
checks = [
|
|
|
|
|
"level0",
|
|
|
|
|
"level1",
|
|
|
|
|
"no-range-loop",
|
|
|
|
|
"no-non-pod-global-static",
|
|
|
|
|
]
|
|
|
|
|
qt_env['CXX'] = 'clazy'
|
|
|
|
|
qt_env['ENV']['CLAZY_IGNORE_DIRS'] = qt_dirs[0]
|
|
|
|
|
qt_env['ENV']['CLAZY_CHECKS'] = ','.join(checks)
|
2020-12-20 19:39:59 -08:00
|
|
|
|
2023-09-13 14:39:06 -07:00
|
|
|
Export('env', 'qt_env', 'arch', 'real_arch')
|
2020-01-17 10:22:00 -08:00
|
|
|
|
2023-09-13 14:39:06 -07:00
|
|
|
# Build common module
|
2022-05-18 14:11:57 -07:00
|
|
|
SConscript(['common/SConscript'])
|
2022-05-23 13:46:48 +02:00
|
|
|
Import('_common', '_gpucommon')
|
2021-07-29 13:13:47 +02:00
|
|
|
|
2024-08-19 15:25:05 -07:00
|
|
|
common = [_common, 'json11', 'zmq']
|
2023-09-13 14:39:06 -07:00
|
|
|
gpucommon = [_gpucommon]
|
2021-07-29 13:13:47 +02:00
|
|
|
|
|
|
|
|
Export('common', 'gpucommon')
|
|
|
|
|
|
2024-06-09 17:44:34 -07:00
|
|
|
# Build messaging (cereal + msgq + socketmaster + their dependencies)
|
2024-08-24 01:46:37 +08:00
|
|
|
# Enable swaglog include in submodules
|
|
|
|
|
env_swaglog = env.Clone()
|
|
|
|
|
env_swaglog['CXXFLAGS'].append('-DSWAGLOG="\\"common/swaglog.h\\""')
|
|
|
|
|
SConscript(['msgq_repo/SConscript'], exports={'env': env_swaglog})
|
2024-11-23 00:22:22 -06:00
|
|
|
SConscript(['opendbc_repo/SConscript'], exports={'env': env_swaglog})
|
2024-08-24 01:46:37 +08:00
|
|
|
|
2020-01-17 10:22:00 -08:00
|
|
|
SConscript(['cereal/SConscript'])
|
2024-08-24 01:46:37 +08:00
|
|
|
|
2024-06-09 17:44:34 -07:00
|
|
|
Import('socketmaster', 'msgq')
|
2025-01-31 02:30:54 +08:00
|
|
|
messaging = [socketmaster, msgq, 'capnp', 'kj',]
|
2024-06-09 17:44:34 -07:00
|
|
|
Export('messaging')
|
|
|
|
|
|
2023-09-13 14:39:06 -07:00
|
|
|
|
|
|
|
|
# Build other submodules
|
2024-08-24 01:46:37 +08:00
|
|
|
SConscript(['panda/SConscript'])
|
2021-04-08 13:09:11 +02:00
|
|
|
|
2023-11-22 13:25:29 -08:00
|
|
|
# Build rednose library
|
2021-04-08 13:09:11 +02:00
|
|
|
SConscript(['rednose/SConscript'])
|
2020-12-20 19:39:59 -08:00
|
|
|
|
2022-06-02 17:02:25 -07:00
|
|
|
# Build system services
|
2022-06-06 13:27:45 -07:00
|
|
|
SConscript([
|
|
|
|
|
'system/proclogd/SConscript',
|
2023-03-08 16:11:18 -08:00
|
|
|
'system/ubloxd/SConscript',
|
2023-05-12 13:01:00 -07:00
|
|
|
'system/loggerd/SConscript',
|
2022-06-06 13:27:45 -07:00
|
|
|
])
|
2022-06-02 17:02:25 -07:00
|
|
|
if arch != "Darwin":
|
2023-05-12 13:01:00 -07:00
|
|
|
SConscript([
|
|
|
|
|
'system/sensord/SConscript',
|
|
|
|
|
'system/logcatd/SConscript',
|
|
|
|
|
])
|
2022-06-02 17:02:25 -07:00
|
|
|
|
2024-04-17 16:33:13 -07:00
|
|
|
if arch == "larch64":
|
|
|
|
|
SConscript(['system/camerad/SConscript'])
|
|
|
|
|
|
2020-12-20 19:39:59 -08:00
|
|
|
# Build openpilot
|
2021-10-07 16:32:44 -07:00
|
|
|
SConscript(['third_party/SConscript'])
|
2020-12-20 19:39:59 -08:00
|
|
|
|
2024-02-28 14:41:42 -05:00
|
|
|
SConscript(['selfdrive/SConscript'])
|
2020-05-14 10:53:19 -07:00
|
|
|
|
2025-01-10 18:34:06 -05:00
|
|
|
SConscript(['sunnypilot/SConscript'])
|
|
|
|
|
|
2024-02-29 19:39:28 -08:00
|
|
|
if Dir('#tools/cabana/').exists() and GetOption('extras'):
|
2022-10-12 15:14:02 -07:00
|
|
|
SConscript(['tools/replay/SConscript'])
|
2024-03-06 09:26:36 -08:00
|
|
|
if arch != "larch64":
|
|
|
|
|
SConscript(['tools/cabana/SConscript'])
|
2022-10-04 06:19:42 +08:00
|
|
|
|
2021-01-18 14:32:29 +01:00
|
|
|
external_sconscript = GetOption('external_sconscript')
|
|
|
|
|
if external_sconscript:
|
|
|
|
|
SConscript([external_sconscript])
|