import os
Import ( ' env ' , ' arch ' , ' real_arch ' , ' common ' , ' messaging ' , ' gpucommon ' , ' visionipc ' , ' cereal ' )
qt_env = None
if arch in [ " x86_64 " , " Darwin " , " larch64 " ] :
qt_env = env . Clone ( )
if arch == " Darwin " :
qt_env [ ' QTDIR ' ] = " /usr/local/opt/qt "
QT_BASE = " /usr/local/opt/qt/ "
qt_dirs = [
QT_BASE + " include/ " ,
QT_BASE + " include/QtWidgets " ,
QT_BASE + " include/QtGui " ,
QT_BASE + " include/QtCore " ,
QT_BASE + " include/QtDBus " ,
QT_BASE + " include/QtMultimedia " ,
QT_BASE + " include/QtNetwork " ,
]
qt_env [ " LINKFLAGS " ] + = [ " -F " + QT_BASE + " lib " ]
else :
qt_env [ ' QTDIR ' ] = " /usr "
qt_dirs = [
f " /usr/include/ { real_arch } -linux-gnu/qt5 " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtWidgets " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtGui " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtCore " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtDBus " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtMultimedia " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtNetwork " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtGui/5.5.1/QtGui " ,
f " /usr/include/ { real_arch } -linux-gnu/qt5/QtGui/5.12.8/QtGui " ,
]
qt_env . Tool ( ' qt ' )
qt_env [ ' CPPPATH ' ] + = qt_dirs + [ " #selfdrive/ui/qt/ " ]
qt_flags = [
" -D_REENTRANT " ,
" -DQT_NO_DEBUG " ,
" -DQT_WIDGETS_LIB " ,
" -DQT_GUI_LIB " ,
" -DQT_CORE_LIB "
]
qt_env [ ' CXXFLAGS ' ] + = qt_flags
qt_env [ ' LIBPATH ' ] + = [ ' #selfdrive/ui ' ]
src = [ ' ui.cc ' , ' paint.cc ' , ' sidebar.cc ' , ' #phonelibs/nanovg/nanovg.c ' ]
libs = [ common , ' zmq ' , ' capnp ' , ' kj ' , ' m ' , cereal , messaging , gpucommon , visionipc ]
if qt_env is None :
libs + = [ ' EGL ' , ' GLESv3 ' , ' gnustl_shared ' , ' log ' , ' utils ' , ' gui ' , ' hardware ' ,
' ui ' , ' CB ' , ' gsl ' , ' adreno_utils ' , ' OpenSLES ' , ' cutils ' , ' uuid ' , ' OpenCL ' ]
linkflags = [ ' -Wl,-rpath=/system/lib64,-rpath=/system/comma/usr/lib ' ]
src + = [ " android/ui.cc " , " android/sl_sound.cc " ]
env . Program ( ' _ui ' , src ,
LINKFLAGS = linkflags ,
LIBS = libs )
else :
qt_libs = [ " pthread " , " ssl " , " crypto " ]
qt_modules = [ " Widgets " , " Gui " , " Core " , " DBus " , " Multimedia " , " Network " ]
if arch == " larch64 " :
qt_libs + = [ " GLESv2 " , " wayland-client " ]
elif arch != " Darwin " :
qt_libs + = [ " GL " ]
if arch == " Darwin " :
qt_env [ " FRAMEWORKS " ] + = [ f " Qt { m } " for m in qt_modules ] + [ " OpenGL " ]
else :
qt_libs + = [ f " Qt5 { m } " for m in qt_modules ]
widgets = qt_env . Library ( " qt_widgets " ,
[ " qt/qt_window.cc " , " qt/qt_sound.cc " , " qt/widgets/keyboard.cc " , " qt/widgets/input_field.cc " , " qt/widgets/drive_stats.cc " ,
" qt/offroad/wifi.cc " , " qt/offroad/wifiManager.cc " , " qt/widgets/toggle.cc " , " qt/widgets/offroad_alerts.cc " ] ,
LIBS = qt_libs )
qt_libs . append ( widgets )
qt_src = [ " qt/ui.cc " , " qt/window.cc " , " qt/home.cc " , " qt/offroad/settings.cc " , " qt/offroad/onboarding.cc " ] + src
qt_env . Program ( " _ui " , qt_src , LIBS = qt_libs + libs )
# spinner and text window
qt_env . Program ( " qt/text " , [ " qt/text.cc " ] , LIBS = qt_libs + libs )
qt_env . Program ( " qt/spinner " , [ " qt/spinner.cc " ] , LIBS = qt_libs + libs )
# build setup, factory resetter, and installer
if " BUILD_SETUP " in os . environ :
qt_env . Program ( " qt/setup/reset " , [ " qt/setup/reset.cc " ] , LIBS = qt_libs )
qt_env . Program ( " qt/setup/setup " , [ " qt/setup/setup.cc " ] , LIBS = qt_libs + [ ' curl ' , ' common ' ] )
installers = [
( " openpilot " , " master " ) ,
( " openpilot_test " , " master " ) ,
#("dashcam", "dashcam"),
#("dashcam_test", "dashcam"),
]
for name , branch in installers :
flags = qt_env [ " CXXFLAGS " ] + [ f " -D { branch } " ]
qt_env . Program ( f " qt/setup/installer_ { name } " , [ " qt/setup/installer.cc " ] , LIBS = qt_libs , CXXFLAGS = flags )