// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
  \page vxworks.html
  \title Qt for VxWorks
  \brief Platform support for VxWorks.
  \keyword VxWorks
  \ingroup supportedplatform

  Contact The Qt Company for more information:
  \l {https://www.qt.io/contact-us/}

  \section1 Supported Architectures and VxWorks Releases

  \list
    \li Qt 6.7 is verified on VxWorks 23.09
    Supported architecture is ARM-v7.
  \endlist

  If you are interested in later Qt releases, please \l {https://www.qt.io/contact-us/}{contact} Qt professional services.

  \section1 Requirements for VxWorks

  \section2 Qt Widgets Applications

  \list
  \li POSIX support
  \li C++17 support
  \endlist

  \section2 Qt Quick 2 Applications

  All features which are required for Qt Widgets applications, and in addition the following:

  \list
  \li GPU device (GPUDEV) for OpenGL ES 2.0
  \endlist

  \section1 Supported Modules

  Most essential \l{All Modules}{Qt modules} and some add-on modules are supported.

  \section2 Supported Essential modules

  \table 80%
  \header
      \li Qt Module
      \li Supported Features
      \li Notes
  \row
      \li \l {Qt Core}
      \li
  \row
      \li \l {Qt GUI}
      \li
  \row
      \li \l {Qt Network}
      \li
  \row
      \li \l {Qt Qml}
      \li
  \row
      \li \l {Qt Quick}
      \li
  \row
      \li \l {Qt Quick Controls}
      \li
  \row
      \li \l {Qt Quick Dialogs}
      \li
  \row
      \li \l {Qt Quick Layouts}
      \li
  \row
      \li \l {Qt Quick Test}
      \li
  \row
      \li \l {Qt Test}
      \li
  \row
      \li \l {Qt Widgets}
      \li
  \endtable

  \section2 Supported Add-Ons

  \table 80%
  \header
      \li Qt Add-Ons
      \li Notes
  \row
      \li \l {Qt Concurrent}
      \li
  \row
      \li \l {Qt GRPC}{Qt GRPC/Protobuf}
      \li
  \row
      \li \l {Qt Graphs}
      \li
  \row
      \li \l {Qt Image Formats}
      \li
  \row
      \li \l {Qt Multimedia}
      \li
  \row
      \li \l {Native Interfaces}{Qt Native Interfaces}
      \li
  \row
      \li \l {Qt OpenGL}
      \li
  \row
      \li \l {Qt Quick 3D}
      \li
  \row
      \li \l {Qt Quick Compiler}
      \li
  \row
      \li \l {Qt Quick Effects}
      \li
  \row
      \li \l {Qt SQL}
      \li
  \row
      \li \l {Qt SVG}
      \li
  \row
      \li \l {Qt Virtual Keyboard}
      \li
  \endtable

  \note You can explicitly exclude unsupported or unused modules from the
  build via the -skip <module> option when running the configure tool.

  \section1 Platform Notes

  With the release of Qt 5.0, Qt no longer contains its own window system
  implementation: QWS is no longer a supported platform. For single-process use
  cases, the \l{Qt Platform Abstraction} is a superior solution.

  There is one plugin that is usable on VxWorks: EGLFS. The availability of this
  plugins depends on the configuration of Qt.

  \section1 Configuring for a Specific Device

  Prepare your environment by installing VxWorks SDK and obtaining WindRiver
  license which is needed by installer and for building VxWorks images.
  Search for appropriate installer in
  {https://gallery.windriver.com/portal/products}.

  Building Qt for a given device requires a Qt6 installation for compilation
  host, a toolchain and a sysroot. Additionally, some devices require vendor
  specific adaptation code for EGL and OpenGL 2.0 support.

  \section2 VxWorks image requirements

  Qt for VxWorks requires certain VxWorks image bundles and components to be
  embedded in base software to make Qt compile and work properly. The
  list is by no means complete as it depends on hardware, software and system
  requirements of your project. However, the following table contains those
  that are mandatory for certain functionalities to work. Note also that these
  might change with VxWorks version.

  \table 80%
    \header
        \li Layer
        \li Notes

    \row
        \li \c BUNDLE_POSIX
        \li This bundle is necessary for compatibility with POSIX-related
        functionalities which Qt requires.

    \row
        \li \c INCLUDE_TMP_DIR
            \c INCLUDE_RAM_DISK_FORMAT_HRFS
        \li Including these two components is necessary if you want to
            use \l {QTemporaryFile}. Note that you should also consider setting
            \c TMP_DIR_SIZE to appropriate value

  \endtable

  \section1 Building Qt6 for VxWorks

  \section2 Building Qt6 for host

  When cross-building Qt6 for VxWorks, it's best practice to use host tools
  that use the same source code as cross-build does. This requires building Qt6
  for host first, but only with limited subset of submodules:
    \list
    \li qtbase
    \li qtdeclarative
    \li qtquick3d
    \li qtshadertools
    \endlist

  Make sure to have all necessary prerequisites for building Qt6 for host. Check
  details in \l{Building Qt Sources}.

  The commands to configure, build, and install Qt6 for host are the following:

  \badcode
    ./configure \
        -cmake-generator "Ninja" \
        -extprefix <path_to_qt6_host_installation_dir> \
        -submodules qtbase,qtdeclarative,qtquick3d,qtshadertools \
        -nomake tests \
        -nomake examples \
        -- \
        -B <host_build_directory>
    cd <host_build_directory>
    ninja
    ninja install
  \endcode

  After these commands, Qt6 for host is installed in
  \c {<path_to_qt6_host_installation_dir>}.

  \section2 Building Qt6 for target

  Before running configure and building Qt 6 it is required to open \e {VxWorks
  Development Shell} in command prompt.

  \list
  \li Linux:
  \badcode
  cd <VxWorks installation directory>
  ./wrenv.sh -p vxworks
  \endcode

  \li Windows:
  \badcode
  cd <VxWorks installation directory>
  wrenv -p vxworks
  \endcode
  \endlist

  Below is an example build configuration for the BD-SL-i.MX6. For most VxWorks boards
  the configure command looks very similar. By default, Qt 6 is configured to
  use shared libraries. To build Qt 6 statically, add \c -static option for configure.

  Make sure that {WIND_CC_SYSROOT} environment variable is set to VxWorks VSB root
  directory.

  \badcode
    ./configure \
        -cmake-generator "Ninja" \
        -icu \
        -no-feature-timezone \
        -no-feature-vulkan \
        -platform vxworks-clang \
        -qt-host-path <path_to_qt6_host_installation_dir> \
        -sysroot <path_to_vxworks_vsb_dir>/fsl_imx6_<vsb_version>_VSB \
        -qpa "eglfs" \
        -DQT_QPA_EGLFS_INTEGRATION=eglfs_viv \
        -prefix /sd0:1/qt6rtp \
        -extprefix <path_to_host_dir>/qt6rtp \
        -nomake tools \
        -nomake examples \
        -- \
        -B <target_build_dir> \
        -DCMAKE_TOOLCHAIN_FILE="$WIND_CC_SYSROOT/mk/rtp.toolchain.cmake"
  \endcode

  In case of building for DKM rather than RTP, use \c -static option and change the
  \c CMAKE_TOOLCHAIN_FILE value to \c {"$WIND_CC_SYSROOT/mk/dkm.toolchain.cmake"}

  It is recommended to build Qt 6 using a \e{shadow build}. See \l {Qt Configure Options}
  for more information.

  When configuration is successful, building and installing Qt6 for VxWorks takes place
  as follows:

  \badcode
  cd <target_build_dir>
  ninja
  ninja install
  \endcode

  \section1 Platform Plugins for VxWorks Devices

  Qt for VxWorks supports EGLFS platform plugin for a \e {native window} substitution.
  Read more about its configuration in \l{embedded eglfs}{EGLFS}.

  \section1 Running Qt Applications

  The following example shows how to start an application when Qt 6 is built using
  shared libraries. With a statically built Qt 6, there is no need to use the
  LD_LIBRARY_PATH environment variable. This variable is only needed to point
  the location of VxWorks shared libraries (for example libc and OpenGL ES 2.0).
  It is not needed for Qt 6 static libraries.

  \badcode
  putenv "LD_LIBRARY_PATH=/sd0:1/lib"
  cd "/sd0:1"
  rtpSp("<Qt6_app>", 200, 0x100000, 0, 0x01000000)
  \endcode

  \section1 Limitations

  \section2 Video Memory

  Systems with a fixed amount of dedicated video memory may need extra care
  before running Qt application based on Qt Quick or classes like
  QOpenGLWidget. The default setting may be insufficient for such applications,
  especially when they are displayed on a high resolution (for example, full HD)
  screen. In this case they might start failing in unexpected ways. It is
  therefore recommended to ensure that there is at least 128 MB of GPU memory
  available. For systems that do not have a fixed amount of memory reserved for
  the GPU this is not an issue.

*/
