diff --git a/custom-example/README.md b/custom-example/README.md index e7bc05a5ff005e1e7f17596ef949362523f044d1..eee240f38dba37c32d0a847729bb3b722452b6d6 100644 --- a/custom-example/README.md +++ b/custom-example/README.md @@ -2,4 +2,27 @@ ## Custom Build Example -To build this sample custom version, simply rename the directory from `custom-example` to `custom` before launching Qt Creator. The build system will automatically find anything in `custom` and incorporate into the build. If you had already run a build before renaming the directory, delete the build directory before running the build. To restore a stock QGroundControl build, rename it back to `custom-example`. +To build this sample custom version, simply rename the directory from `custom-example` to `custom` before running `qmake` (or launching Qt Creator.) The build system will automatically find anything in `custom` and incorporate it into the build. If you had already run a build before renaming the directory, delete the build directory before running `qmake`. To restore the build to a stock QGroundControl one, rename the directory back to `custom-example` (making sure to clean the build directory again.) + +### Custom Builds + +The root project file (`qgroundcontrol.pro`) will look and see if `custom/custom.pri` exists. If it does, it will load it before anything else is setup. This allows you to modify the build in any way necessary for a custom build. This example shows you how to: + +* Fully brand your build +* Define a single flight stack to avoid carrying over unnecessary code +* Implement your own, autopilot and firmware plugin overrides +* Implement your own camera manager and plugin overrides +* Implement your own QtQuick interface module +* Implement your own toolbar, toolbar indicators and UI navigation +* Implement your own Fly View overlay (and how to hide elements from QGC such as the flight widget) +* Implement your own, custom QtQuick camera control +* Implement your own, custom Pre-flight Checklist +* Define your own resources for all of the above + +Note that within `qgroundcontrol.pro`, most main build steps are surrounded by flags, which you can define to override them. For example, if you want to have your own Android build, done in some completely different way, you simply: + +``` +DEFINES += DISABLE_BUILTIN_ANDROID +``` + +With this defined within your `custom.pri` file, it is up to you to define how to do the Android build. You can either replace the entire process or prepare it before invoking QGC’s own Android project file on your own. You would do this if you want to have your own branding within the Android manifest. The same applies to iOS (`DISABLE_BUILTIN_IOS`). diff --git a/custom-example/custom.pri b/custom-example/custom.pri index c5695296443475a969aedf6a204c92cd4c348099..03cd01094ad2646e004f5a088730d160e8e11920 100644 --- a/custom-example/custom.pri +++ b/custom-example/custom.pri @@ -7,8 +7,8 @@ CUSTOM_QGC_VER_MAJOR = 0 CUSTOM_QGC_VER_MINOR = 0 CUSTOM_QGC_VER_FIRST_BUILD = 0 -# Build number is automatic -# Uses the current branch. This way it works on any branch including build-server's PR branches +# Build number is automatic +# Uses the current branch. This way it works on any branch including build-server's PR branches CUSTOM_QGC_VER_BUILD = $$system(git --git-dir ../.git rev-list $$GIT_BRANCH --first-parent --count) win32 { CUSTOM_QGC_VER_BUILD = $$system("set /a $$CUSTOM_QGC_VER_BUILD - $$CUSTOM_QGC_VER_FIRST_BUILD") @@ -22,19 +22,15 @@ DEFINES += GIT_VERSION=\"\\\"$$CUSTOM_QGC_VERSION\\\"\" message(Custom QGC Version: $${CUSTOM_QGC_VERSION}) -# Disable APM support +# Build a single flight stack by disabling APM support MAVLINK_CONF = common CONFIG += QGC_DISABLE_APM_MAVLINK -CONFIG += QGC_DISABLE_APM_PLUGIN QGC_DISABLE_APM_PLUGIN_FACTORY QGC_DISABLE_PX4_PLUGIN_FACTORY +CONFIG += QGC_DISABLE_APM_PLUGIN QGC_DISABLE_APM_PLUGIN_FACTORY -# MAVLink Development -exists($$PWD/mavlink_dev) { - MAVLINKPATH_REL = $$PWD/mavlink_dev - MAVLINKPATH = $$PWD/mavlink_dev - message($$sprintf("Using user-supplied mavlink development path '%1'", $$MAVLINKPATH)) -} +# We implement our own PX4 plugin factory +CONFIG += QGC_DISABLE_PX4_PLUGIN_FACTORY -# Branding +# Branding DEFINES += CUSTOMHEADER=\"\\\"CustomPlugin.h\\\"\" DEFINES += CUSTOMCLASS=CustomPlugin @@ -45,9 +41,6 @@ DEFINES += QGC_APPLICATION_NAME=\"\\\"CustomQGC\\\"\" DEFINES += QGC_ORG_NAME=\"\\\"qgroundcontrol.org\\\"\" DEFINES += QGC_ORG_DOMAIN=\"\\\"org.qgroundcontrol\\\"\" -RESOURCES += \ - $$QGCROOT/custom/custom.qrc - QGC_APP_NAME = "Custom GS" QGC_BINARY_NAME = "CustomQGC" QGC_ORG_NAME = "Custom" @@ -55,9 +48,14 @@ QGC_ORG_DOMAIN = "org.qgroundcontrol" QGC_APP_DESCRIPTION = "Custom QGC Ground Station" QGC_APP_COPYRIGHT = "Copyright (C) 2019 QGroundControl Development Team. All rights reserved." +# Our own, custom resources +RESOURCES += \ + $$QGCROOT/custom/custom.qrc + QML_IMPORT_PATH += \ $$QGCROOT/custom/res +# Our own, custom sources SOURCES += \ $$PWD/src/CustomPlugin.cc \ $$PWD/src/CustomQuickInterface.cc