Skip to content

Commit

Permalink
Changed project file and build scripts to allow configuration using e…
Browse files Browse the repository at this point in the history
…nvironment variables.

Updated build instructions.
Added deploy target and build scripts for Linux.
albar965/littlenavmap#387
  • Loading branch information
albar965 committed Mar 24, 2019
1 parent 8f8e7ec commit aa32dc7
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 126 deletions.
102 changes: 57 additions & 45 deletions BUILD.txt
Original file line number Diff line number Diff line change
@@ -1,68 +1,80 @@
Build Instructions
------------------------------------------------------
# Build Instructions

Qt development packages of Core, Widgets, XML and SQL are needed with minimum version 5.4.
Additionally my atools static library is needed.
The atools static library is required. Clone atools (`git clone https://github.com/albar965/atools.git`)
and follow the build instructions there. The instructions in this `BUILD.txt` file assume that atools was installed
and compiled successfully and Qt Creator was configured accordingly.

- Clone atools GIT repository
- Clone navdatareader GIT repository into the same directory
Clone the navdatareader GIT repository into the same directory as atools. You can use another
directory but then you need to adapt the configuration by changing environment variables.

Windows
------------------------------------------------------
Look at the `navdatareader.pro` file. There is a list of documented environment variables that can
be set to customize the build. Most of these variables are optional and use a reasonable default
value. Set these variables in the Qt Creator GUI or on the command line.

- Get and install Qt Creator from http://www.qt.io. Preferrably use the default installation
directory "C:\Qt"
There is no need to edit the `*.pro` files.

- Clone atools from GIT to e.g.: "C:\Projects\atools"
- Clone navdatareader from GIT to e.g.: "C:\Projects\navdatareader"
Both projects have to reside in the same directory.
## Default paths and Environment Variables

- Use "../build-%{CurrentProject:Name}-%{CurrentBuild:Name}" for "Default build directory"
in the Qt Creator options dialog.
- Import atools and navdatareader into the Qt creator workspace.
- Configure the projects and enable shadow build for release or debug versions.
The projects can be built with almost no configuration changes since all project files fall back to sensible
default paths if the corresponding environment variables are not set. `APROJECTS` is the placeholder for the base directory in
the examples below. Avoid paths with spaces if possible.

If the shadow build is configured properly:
- atools uses the build directory of e.g.: "C:\Projects\build-atools-release"
- navdatareader uses the build directory of e.g.: "C:\Projects\build-navdatareader-release"
* `APROJECTS/atools/src` Sources. `ATOOLS_INC_PATH`
* `APROJECTS/build-atools-debug` atools debug build. `ATOOLS_LIB_PATH`
* `APROJECTS/build-atools-release` atools release build. `ATOOLS_LIB_PATH`
* `APROJECTS/build-navdatareader-debug` Navdatareader debug build.
* `APROJECTS/build-navdatareader-release` Navdatareader release build.
* `APROJECTS/deploy` Target for `make deploy`. `DEPLOY_BASE`
* `APROJECTS/navdatareader` Sources.

- Set the build kit for atools and navdatareader to MinGW 32bit. MSVC is untested.
- Add "DEFINES+=SIMCONNECT_DUMMY DEFINES-=SIMCONNECT_REAL" to
atools and navdatareader qmake parameters if FSX/P3D SimConnect is not installed.
## Windows

- Run qmake from Qt Creator for both projects
- Build both projects from Qt Creator
- Deploy navdatareader
- Clone navdatareader from GIT (`git clone https://github.com/albar965/navdatareader.git`)
to e.g.: `C:\Projects\navdatareader`
- For navdatareader use the build directory of e.g.: `C:\Projects\build-navdatareader-release`. Otherwise
change the paths with envronment variables (see `navdatareader.pro` file).
- Import navdatareader into the Qt Creator workspace (atools should be already there).
- Configure the project and enable the shadow build for release or debug versions.
- Set the build kit for atools and navdatareader to MinGW 32bit.
- Run qmake from Qt Creator for all projects
- Build all projects from Qt Creator
- Create and run the target `deploy`. This will create a directory `DEPLOY_BASE\Navdatareader` with the program.

This comment has been minimized.

Copy link
@cogwheel

cogwheel Apr 22, 2023

Could you elaborate on this step? I'm not sure what to do to "create" the deploy step. I'm able to build and run navdata reader from within Qt, but I can't figure out how to get it to run on its own.

When I go into the Build menu there is a "Deploy" option but it doesn't seem to do anything.

image

This comment has been minimized.

Copy link
@albar965

albar965 Apr 22, 2023

Author Owner

You have to add a deploy step in Qt Creator which calls make copydata and make deploy.
The program and all required files are then copied `../deploy/Navdatareader


Do not use the default shadow build directory names, this will break project dependencies.
The navdatareader project can be built using the MinGW environment only. MSVC will not work.

## Linux

Linux / macOS
------------------------------------------------------
Install Qt development packages. Version at least 5.6.

Build atools according to instructions in BUILD.txt.
You can build the program on Linux or macOS similar to the Windows instructions above either using
the Qt Creator GUI or the command line.

The following assumes that atools was already installed and built.

### To build the navdatareader release version:

Create all build directories on the same level as the source directories "atools" and "navdatareader".
```
mkdir build-navdatareader-release
cd build-navdatareader-release
qmake ../navdatareader/navdatareader.pro CONFIG+=release
make
```

To build the release version:
- mkdir build-navdatareader-release
- cd build-navdatareader-release
- qmake ../navdatareader/navdatareader.pro CONFIG+=release
- make
### To build the navdatareader debug version:

To build the debug version:
- mkdir build-navdatareader-debug
- cd build-navdatareader-debug
- qmake ../navdatareader/navdatareader.pro CONFIG+=debug
- make
```
mkdir build-navdatareader-debug
cd build-navdatareader-debug
qmake ../navdatareader/navdatareader.pro CONFIG+=debug
make
```

Branches / Project Dependencies
------------------------------------------------------
## Branches / Project Dependencies

Make sure to use the correct branches to avoid breaking dependencies.
The branch master is the unstable development branch but all software should compile there.

For releases check the release/MAJOR.MINOR branches to get the correct dependencies.
The atools branch is usually one MAJOR number ahead.
The atools branch is one MAJOR number ahead.

So a project branch release/1.2 should work well with atools release/2.2 for example.
So Navdatareader branch `release/1.2` should work well with atools `release/2.2` for example.
59 changes: 59 additions & 0 deletions build/linux/build_release.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Echo all commands and exit on failure
set -e
set -x

# Error checking for required variable APROJECTS
if [ -z "$APROJECTS" ] ; then echo APROJECTS environment variable not set ; exit 1 ; fi
if [ ! -d "$APROJECTS" ]; then echo "$APROJECTS" does not exist ; exit 1 ; fi

# =============================================================================
# Set the required environment variable APROJECTS to the base directory for
# atools and navdatareader.

# =============================================================================
# Configuration can be overloaded on the command line by setting the
# variables below before calling this script.
#
# See the *.pro project files for more information.
#
# Example:
# export QMAKE_STATIC=~/Projekte/build-qt-5.12.0-release/bin/qmake
# export MARBLE_LIB_PATH=~/Programme/Marble-debug/lib
# export MARBLE_INC_PATH=~/Programme/Marble-debug/include

export CONF_TYPE=${CONF_TYPE:-"release"}
export ATOOLS_INC_PATH=${ATOOLS_INC_PATH:-"${APROJECTS}/atools/src"}
export ATOOLS_LIB_PATH=${ATOOLS_LIB_PATH:-"${APROJECTS}/build-atools-${CONF_TYPE}"}

# Defines the used Qt for all builds
export QMAKE_SHARED=${QMAKE_SHARED:-"${HOME}/Qt/5.9.5/gcc_64/bin/qmake"}

# Do not change the DEPLOY_BASE since some scripts depend on it
export DEPLOY_BASE="${APROJECTS}/deploy"

# ===========================================================================
# ========================== navdatareader - shared Qt
# ===========================================================================

# ===========================================================================
# ========================== atools
rm -rf ${APROJECTS}/build-atools-${CONF_TYPE}
mkdir -p ${APROJECTS}/build-atools-${CONF_TYPE}
cd ${APROJECTS}/build-atools-${CONF_TYPE}

${QMAKE_SHARED} ${APROJECTS}/atools/atools.pro -spec linux-g++ CONFIG+=${CONF_TYPE}
make -j4

# ===========================================================================
# ========================== navdatareader
rm -rf ${APROJECTS}/build-navdatareader-${CONF_TYPE}
mkdir -p ${APROJECTS}/build-navdatareader-${CONF_TYPE}
cd ${APROJECTS}/build-navdatareader-${CONF_TYPE}

${QMAKE_SHARED} ${APROJECTS}/navdatareader/navdatareader.pro -spec linux-g++ CONFIG+=${CONF_TYPE}
make -j4

make copydata
make deploy
12 changes: 12 additions & 0 deletions build/linux/do_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash

set -e
set -x

bash pull_all.sh

bash build_release.sh

bash pack_deploy.sh


24 changes: 24 additions & 0 deletions build/linux/pack_deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

# Echo all commands and exit on failure
set -e
set -x

# Error checking for required variable APROJECTS
if [ -z "$APROJECTS" ] ; then echo APROJECTS environment variable not set ; exit 1 ; fi
if [ ! -d "$APROJECTS" ]; then echo "$APROJECTS" does not exist ; exit 1 ; fi

# Override by envrionment variable for another target
export SSH_DEPLOY_TARGET=${SSH_DEPLOY_TARGET:-"darkon:/data/alex/Public/Releases"}

export FILENAME=`date "+20%y%m%d-%H%M"`

(
cd ${APROJECTS}/deploy

tar cfvz Navdatareader.tar.gz "Navdatareader"
)

scp ${APROJECTS}/deploy/Navdatareader.tar.gz ${SSH_DEPLOY_TARGET}/Navdatareader-linux-${FILENAME}.tar.gz


18 changes: 18 additions & 0 deletions build/linux/pull_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

# Echo all commands and exit on failure
set -e
set -x

# Error checking for required variable APROJECTS
if [ -z "$APROJECTS" ] ; then echo APROJECTS environment variable not set ; exit 1 ; fi
if [ ! -d "$APROJECTS" ]; then echo "$APROJECTS" does not exist ; exit 1 ; fi

cd ${APROJECTS}/atools

git pull --verbose --tags

cd ${APROJECTS}/navdatareader

git pull --verbose --tags

29 changes: 27 additions & 2 deletions build/win/build_release.cmd
Original file line number Diff line number Diff line change
@@ -1,5 +1,31 @@
@echo off

setlocal enableextensions

if defined APROJECTS ( echo %APROJECTS% ) else ( echo APROJECTS not set && exit /b 1 )

rem =============================================================================
rem Set the required environment variable APROJECTS to the base directory for
rem atools and navdatareader.
rem
rem =============================================================================
rem Configuration can be overloaded on the command line by setting the
rem variables below before calling this script.
rem
rem See the *.pro project files for more information.
rem
rem Example:
rem set PATH_SHARED=C:\Qt\5.9.5\mingw53_32\bin;C:\Qt\Tools\mingw530_32\bin

if defined CONF_TYPE ( echo %CONF_TYPE% ) else ( set CONF_TYPE=release)
if defined ATOOLS_INC_PATH ( echo %ATOOLS_INC_PATH% ) else ( set ATOOLS_INC_PATH=%APROJECTS%\atools\src)
if defined ATOOLS_LIB_PATH ( echo %ATOOLS_LIB_PATH% ) else ( set ATOOLS_LIB_PATH=%APROJECTS%\build-atools-%CONF_TYPE%)
if defined DEPLOY_BASE ( echo %DEPLOY_BASE% ) else ( set DEPLOY_BASE=%APROJECTS%\deploy)
if defined ATOOLS_GIT_PATH ( echo %ATOOLS_GIT_PATH% ) else ( set ATOOLS_GIT_PATH=C:\Git\bin\git)

rem Defines the used Qt for all builds
if defined PATH_SHARED ( echo %PATH_SHARED% ) else ( set PATH_SHARED=C:\Qt\5.9.5\mingw53_32\bin;C:\Qt\Tools\mingw530_32\bin)

rem === Build atools and navdatareader =============================

rem ===========================================================================
Expand All @@ -12,7 +38,7 @@ IF ERRORLEVEL 1 goto :err
popd

setlocal
set PATH=%PATH%;C:\Qt\5.9.5\mingw53_32\bin;C:\Qt\Tools\mingw530_32\bin
set PATH=%PATH%;%PATH_SHARED%

rem ===========================================================================
rem ========================== atools 32 bit
Expand Down Expand Up @@ -45,7 +71,6 @@ IF ERRORLEVEL 1 goto :err
popd
endlocal


echo ---- Success ----

if not "%1" == "nopause" pause
Expand Down
Loading

0 comments on commit aa32dc7

Please sign in to comment.