Commit 2d7b516e authored by Volker Hilsheimer's avatar Volker Hilsheimer

One build job to rule them all

Instead of having build-qt, build-qtmodule, and build-project, make
a single build job that discovers things.

Name the build directory based on the basename of the JOBDIR, and link
the build tool wrapper to the location in $build/bin if $build/qtbase/bin
doesn't exist.
parent 135a4b44
......@@ -14,14 +14,14 @@ For basebox maintenance documentation, see the [basebox directory](basebox).
```
$ cd ~/qt5/qtbase
$ minicoin run ubuntu1804 build-qtmodule
$ minicoin run ubuntu1804 build
$ cd ~/my_project
$ minicoin run ubuntu1804 build-project
$ minicoin run ubuntu1804 build
```
This will first build qtbase from the local ~/qt5/qtbase directory on the
ubuntu1804 box, and then build the project in ~/my_project on the same box,
using the qtbase that was just built before.
using the qtbase that was built just before.
# Setup
......
......@@ -105,21 +105,25 @@ step.
## Job documentation
For a list of available jobs, run
`$ minicoin jobs`
To see the documentation for a given job, run
`$ minicoin job-help job`
`$ minicoin job-help [job]`
The most important jobs are:
To run a job, invoke
`$ minicoin run [machines...] build-qtmodule`
`$ minicoin run [machines...] [job]`
Builds the Qt submodule in the local directory on the listed machines,
using the Qt from the last build of qtbase.
The most important job is:
`$ minicoin run [machines...] build-project`
`$ minicoin run [machines...] build`
Build the project in the current working directory on the listed machines,
using the Qt that was built last (via the build-qtmodule job).
This job builds the local source tree on the listed machines. The local
source tree can be a toplevel Qt repo, a single Qt module, or a Qt project.
The Qt toolkit from the last build of qtbase will be used.
# Machines
......
#!/usr/bin/env bash
. /minicoin/util/parse-opts.sh "$@"
sources=$JOBDIR
build_dir=~/qt-build
modules=
if [[ $PARAM_build != "" ]]; then
build_dir=$PARAM_build
fi
if [[ $PARAM_modules != "" ]]; then
modules=$PARAM_modules
fi
outputdir=$build_dir/qtbase/doc
echo "Building HTML docs for '$sources' into '$outputdir'"
mkdir -p $build_dir/qtbase/doc
cd $build_dir
if [[ $modules == "" ]]; then
make html_docs
else
module_array=()
IFS=',' read -r -a module_array <<< "$modules"
for module in "${module_array[@]}"; do
echo "Building $module"
cd $module
make html_docs
cd ..
done
fi
cd $outputdir
rm diff.txt
date > now.log # make sure there's a change
git init -q
git add .
git commit -q -m "Build of '$sources'"
git show > diff.txt
\ No newline at end of file
Configures and builds the Qt project from the sources in the current directory
Runs qmake and make, or cmake and ninja, for the most recently built Qt.
Supported job parameters:
--target Build a specific target
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
call C:\minicoin\util\parse-opts.cmd %*
call C:\minicoin\util\discover-make.cmd
SET sources=%JOBDIR%
IF "!sources!" == "" (
echo No project specified!
goto :errorargs
)
set projectpath=!sources!
IF %projectpath:~-1%==/ SET projectpath=%projectpath:~0,-1%
FOR %%P in ("%projectpath%") DO (
set projectname=%%~nP
)
echo Building '%projectpath%' into '%projectname%'
if not exist %projectname% (
mkdir %projectname%
)
cd %projectname%
if exist "%projectpath%\CMakeLists.txt" (
set generator=
if NOT "%NINJA%" == "" (
set generator=-GNinja
set MAKETOOL=%NINJA%
)
call qt-cmake.bat "%projectpath%" !generator!
) else (
call qmake.bat "%projectpath%"
)
set error=0
if exist build.ninja (
%NINJA% !PARAM_target!
echo %errorlevel%
) else if exist Makefile (
%MAKETOOL% !PARAM_target!
set error=%errorlevel%
) else (
echo Error generating build system
exit /B 2
)
if !error! EQU 0 (
echo Project '%projectname%' built successfully
) else (
echo Error building '%projectname'
)
exit /B !error!
:errorargs
exit /B 1
#!/usr/bin/env bash
. /minicoin/util/parse-opts.sh "$@"
sources=$JOBDIR
if [[ $sources == "" ]]; then
echo "No project specified"
exit 1
fi
project=$(basename $sources)
mkdir $project > /dev/null 2>&1
cd $project
printf "Building project in '$sources' into '$PWD' "
if [ -f "$sources/CMakeLists.txt" ]
then
printf "using cmake\n"
qt-cmake $sources
else
printf "using qmake\n"
qmake $sources
fi
export DISPLAY=:0.0
if [ -f build.ninja ]
then
ninja $PARAM_target
elif [ -f Makefile ]
then
make $PARAM_target -j$(nproc)
else
echo "Error generating build system"
exit 1
fi
Configures and builds the Qt module from the sources in the current directory
If the Qt module is "qtbase", the job generates a helper script on the guest
that runs "qmake" and "cmake" for this build. Other modules and projects will
then use those scripts.
The build directory on the guest is by default ~/qt-[module]-build
The build job supports Qt 5 (using qmake/make) and Qt 6 (using cmake/ninja).
By default, the job configures Qt with
-confirm-license -developer-build -opensource -nomake examples
and builds the src directory (as well the qmake target for Qt 6).
Supported job parameters:
--configure "configure line \"with spaces\""
Overrides the default configuration options.
--target target
Build a different target than src/all (or sub-src for Qt 5), e.g.
$ minicoin run windows10 build-qtmodule -- --target tst_qobject_check
$ minicoin run doc-server build-qtmodule -- --target html_docs
--build name
Specify a suffix for the build directory, e.g.
$minicoin run ubuntu1804 build-qtmodule -- --build 5.15
Will build the current module into qt-[module]-5.15
--clean
Delete the build tree before configuring and building.
@echo off
SETLOCAL ENABLEDELAYEDEXPANSION
call c:\minicoin\util\parse-opts.cmd %*
call c:\minicoin\util\discover-make.cmd
if NOT DEFINED JOBDIR (
echo Error: path to host clone of Qt module is required!
exit /B 1
)
set build=
set generate_qmake=false
set configure=
set target=
set "sources=!JOBDIR!"
set module=
for %%F in ("%sources%") do (
set module=%%~nF
)
if %module% == "" (
echo Can't identify the module for %sources%!
exit /B 2
)
if defined PARAM_target set "target=!PARAM_target!"
if NOT "!PARAM_build!" == "" set build=-!PARAM_build!
if NOT "!PARAM_configure!" == "" (
SET "configure=!PARAM_configure!"
if exist "%USERPROFILE%\!configure!.opt" (
SET "config_opt=%USERPROFILE%\!configure!\.opt"
)
) else (
SET "config_opt=%USERPROFILE%\config.opt"
)
if NOT "!FLAG_clean!" == "" if exist %module%-build!build! (
echo Cleaning existing build in %module%-build!build!
rmdir /S/Q %module%-build!build!
)
if not exist %module%-build!build! (
mkdir %module%-build!build!
)
cd %module%-build!build!
echo Building '%module%' from '%sources%' into '%module%-build!build!'
if exist CMakeCache.txt (
echo '%module%' already configured with cmake
) else (
if exist Makefile (
echo '%module%' already configured with qmake
) else (
if "%module%" == "qtbase" (
set "generate_toollink=qmake"
set "configure=-confirm-license -developer-build -opensource -nomake examples -debug !configure!"
if exist %sources%\CMakeLists.txt if not defined FLAG_qmake (
set "generate_toollink=!generate_toollink! qt-cmake"
set "configure=!configure! -cmake -cmake-generator Ninja"
) else (
set "configure=!configure! %QTCONFIGFLAGS%"
)
echo Calling '%sources%\configure !configure!'
call %sources%\configure.bat !configure!
) else (
if exist %sources%\CMakeLists.txt (
echo Generating cmake build for '%module%' for '%MAKETOOL%'
set generator=
if not "%NINJA%" == "" (
set "generator=-GNinja"
set MAKETOOL=%NINJA%
)
call %USERPROFILE%\bin\qt-cmake %sources% !generator!
) else (
echo Generating qmake build for '%module%'
call %USERPROFILE%\bin\qmake %sources%
)
)
)
)
for %%T in ( %generate_toollink% ) do (
set tool=%%T
echo Generating link to !tool!
set linkname=-latest
if defined PARAM_build (
set linkname=!build!
)
set toolname=!tool!!linkname!
if exist %USERPROFILE%\bin\!toolname!.bat (
del %USERPROFILE%\bin\!toolname!.bat
)
if exist %USERPROFILE%\bin\!tool!.bat (
del %USERPROFILE%\bin\!tool!.bat
)
echo @echo off >> %USERPOFILE%\bin\!toolname!.bat
echo SET PATH=%CD%\bin;%%PATH%% >> %USERPROFILE%\bin\!toolname!.bat
echo %CD%\bin\!tool! %%* >> %USERPROFILE%\bin\!toolname!.bat
del %USERPROFILE%\bin\!tool!.bat
mklink %USERPROFILE%\bin\!tool!.bat %USERPROFILE%\bin\!toolname!.bat
)
if exist build.ninja (
if "%target%" == "" (
set "target=src/all"
if "%module%" == "qtbase" set "target=!target! qmake"
)
echo Building '!target!' using '!ninja!'
call !ninja! !target!
) else (
if exist Makefile (
if "%target%" == "" set "target=sub-src"
echo Building '!target!' using '!MAKETOOL!'
call !MAKETOOL! "!target!"
) else (
echo No build system geneated, aborting
EXIT /B 1
)
)
EXIT /B %ERRORLEVEL%
#!/usr/bin/env bash
. /minicoin/util/parse-opts.sh "$@"
if [ -z $JOBDIR ]
then
echo "Error: path to host clone of Qt is required!"
exit 1
fi
if [[ $XAUTH_FILE != "" ]]
then
# make sure we are logged in
XAUTHORITY=$XAUTH_FILE sudo xdotool type "vagrant"
XAUTHORITY=$XAUTH_FILE sudo xdotool key --clearmodifiers Return
fi
# set defaults
build=
configure=
generate_toollink=()
target=
sources=$JOBDIR
module=$(basename -s .pro $(ls $sources/*.pro))
if [[ $(echo $module | wc -w) != 1 ]]; then
echo "$sources needs to have exactly one .pro file!"
exit 1
fi
[[ ! -z $PARAM_target ]] && target=$PARAM_target
[[ ! -z $PARAM_build ]] && build=-$PARAM_build
if [[ $PARAM_configure != "" ]]; then
configure=$PARAM_configure
if [[ -f "$HOME/$configure.opt" ]]; then
config_opt=$HOME/$configure.opt
fi
else
config_opt=$HOME/config.opt
fi
if [[ ! -z $FLAG_clean ]]
then
echo "Cleaning existing build in '$module-build$build'"
rm -rf $module-build$build
fi
mkdir $module-build$build 2> /dev/null
cd $module-build$build
echo "Building '$module' from '$sources' into '$module-build$build'"
if [ -f CMakeCache.txt ] && [ -z $configure ]
then
echo "'$module' already configured with cmake"
elif [ -f Makefile ] && [ -z $configure ]
then
echo "'$module' already configured with qmake"
elif [[ -f "$sources/configure" ]]
then
generate_toollink=( "qmake" )
configure="-confirm-license -developer-build -opensource -nomake examples $configure"
if [ -f $sources/CMakeLists.txt ] && [ -z $FLAG_qmake ]
then
generate_toollink=( $generate_toollink "qt-cmake" )
configure="$configure -cmake -cmake-generator Ninja"
fi
echo "Configuring '$module' with options '$configure'"
$sources/configure $configure
elif [ -f $sources/CMakeLists.txt ]
then
echo "Generating cmake build for '$module'"
~/qt-cmake $sources -GNinja
error=$?
else
echo "Generating qmake build for '$module'"
~/qmake $sources
error=$?
fi
for tool in "${generate_toollink[@]}"
do
echo "Creating link to $tool..."
linkname="-latest"
if [[ $build != "" ]]
then
linkname=$build
fi
toolname=$tool$linkname
rm ~/$toolname 2> /dev/null > /dev/null
echo "$PWD/bin/$tool \"\$@\"" > ~/$toolname
chmod +x ~/$toolname
rm ~/$tool 2> /dev/null > /dev/null
ln -s -f ~/$toolname ~/$tool
sudo ln -s -f ~/$toolname /usr/local/bin/$tool
done
if [ -f build.ninja ]
then
if [ -z $target ]
then
target="src/all"
[ $module == "qtbase" ] && target="$target qmake"
fi
echo "Building '$target' using ninja!"
ninja $target
error=$?
elif [ -f Makefile ]
then
[ -z $target ] && target="sub-src"
echo "Building '$target' using make!"
make $target -j$(nproc)
error=$?
else
>&2 echo "No build system generated, aborting"
fi
exit $error
Configures and builds Qt from toplevel sources in the current directory
Configures and builds the Qt project in the current directory
The job performs a top-level build of Qt, and supports Qt 5
(using qmake/make) and Qt 6 (using cmake/ninja).
The build directory on the guest defaults to ~/${basename}-build
The build directory on the guest is by default ~/qt-build
By default, the job configures Qt with
The job supports Qt 5 (using qmake/make) and Qt 6 (using cmake/ninja)
projects. If the current directory has a configure script, then
it will be used to generate the build system. Otherwise, the job will
use qt-cmake if there is a CMakeLists.txt file, and qmake if there
is a .pro file.
The configure script will be default be invoked with
-confirm-license -developer-build -opensource -nomake examples
and builds the default target (i.e. all).
The job then builds the default target.
Supported job parameters:
......@@ -21,8 +23,8 @@ Supported job parameters:
Build a different target than the default, e.g.
$ minicoin run windows10 build-qt -- --target tst_qobject_check
$ minicoin run doc-server build-qt -- --target html_docs
$ minicoin run windows10 build -- --target tst_qobject_check
$ minicoin run doc-server build -- --target html_docs
--build name
......@@ -34,15 +36,10 @@ Supported job parameters:
Delete the build tree before configuring and building.
--qmake
Use qmake build system also if a cmake build system is present.
Ignored if the build is already configured with cmake, combine with
--clean or use a separate --build to switch build systems.
--cc path
--cxx path
Use the C and C++ compiler at the specified path, e.g.
$ minicoin run ubuntu1804 build-qt -- -cc /usr/bin/clang-10 --cxx /usr/bin/clang++10
$ minicoin run ubuntu1804 build -- -cc /usr/bin/clang-10 --cxx /usr/bin/clang++10
$ minicoin run windows10 build -- -cc cl --cxx cl
......@@ -13,19 +13,26 @@ goto :main
REM Creates a batch wrapper in ~/bin (which is in the PATH) for qmake or cmake
:link_tool
set "toolname=%~n1"
set "toolext=%~x1"
if EXIST "%CD%\qtbase\bin\%1" (
echo @echo off > %USERPROFILE%\bin\!toolname!.bat
echo SET PATH=%CD%\qtbase\bin;%%PATH%% >> %USERPROFILE%\bin\!toolname!.bat
echo %CD%\qtbase\bin\!toolname! "%%*" >> %USERPROFILE%\bin\!toolname!.bat
set "toolname=%1"
set "binpath=%CD%\qtbase\bin"
if NOT EXIST "%binpath%\%toolname%" set "binpath=%CD%\bin"
if EXIST "%binpath%\%toolname%" (
set "toolbase=%~n1"
set "toolext=%~x1"
echo @echo off > %USERPROFILE%\bin\!toolbase!.bat
echo SET PATH=%binpath%;%%PATH%% >> %USERPROFILE%\bin\!toolbase!.bat
echo %binpath%\!toolbase! %%* >> %USERPROFILE%\bin\!toolbase!.bat
)
exit /B
:main
for /F %%i in ("!JOBDIR!") do set projectname=%%~ni
REM set defaults
if "!PARAM_build!"=="" SET "PARAM_build=qt-build"
if "!PARAM_build!"=="" (
SET "PARAM_build=!projectname!-build"
)
SET "build_dir=!PARAM_build!"
SET "target=!PARAM_target!"
......@@ -38,30 +45,41 @@ if DEFINED FLAG_clean (
if NOT EXIST !build_dir! mkdir !build_dir!
cd !build_dir!
echo Building '!JOBDIR!' into '!build_dir!'
echo Building '!projectname!' from '!JOBDIR!' into '!build_dir!'
if EXIST CMakeCache.txt (
if EXIST build.ninja (
echo Already configured with cmake - run with --clean to reconfigure
) else (
if EXIST Makefile (
echo Already configured with qmake - run with --clean to reconfigure
) else (
if EXIST %JOBDIR%/CMakeLists.txt (
if NOT DEFINED FLAG_qmake (
if "%PARAM_configure%"=="" SET "PARAM_configure=-GNinja -DFEATURE_developer_build=ON -DBUILD_EXAMPLES=OFF"
if NOT "!PARAM_cc==!" == "" SET "PARAM_configure=!PARAM_configure! -DCMAKE_C_COMPILER=!PARAM_cc!"
if NOT "!PARAM_cxx==!" == "" SET "PARAM_configure=!PARAM_configure! -DCMAKE_CXX_COMPILER=!PARAM_cxx!"
echo Configuring !JOBDIR! with cmake: !PARAM_configure!
echo Pass --configure "configure options" to override
cmake !PARAM_configure! !JOBDIR!
) else (
if EXIST %JOBDIR%/configure.bat (
if "%PARAM_configure%"=="" SET "PARAM_configure=-developer-build -confirm-license -opensource -nomake examples"
echo Configuring !JOBDIR! with qmake: !PARAM_configure!
echo Pass --configure "configure options" to override
!JOBDIR!/configure.bat !PARAM_configure!
if EXIST "!JOBDIR!\configure.bat" (
if "!PARAM_configure!"== "" SET "PARAM_configure=-developer-build -confirm-license -opensource -nomake examples"
if NOT "!PARAM_cc!" == "" SET "PARAM_configure=!PARAM_configure! -- -DCMAKE_C_COMPILER=!PARAM_cc!"
if NOT "!PARAM_cxx!" == "" SET "PARAM_configure=!PARAM_configure! -- -DCMAKE_CXX_COMPILER=!PARAM_cxx!"
echo Configuring '!JOBDIR!' with 'configure !PARAM_configure!'
echo Pass --configure "configure options" to override
call !JOBDIR!\configure.bat !PARAM_configure!
) else (
if EXIST !JOBDIR!\CMakeLists.txt (
if "!PARAM_configure!" == "" SET "PARAM_configure=-GNinja"
echo "Configuring '!JOBDIR!' with 'qt-cmake !PARAM_configure!'"
if NOT EXIST %USERPROFILE%\bin\qt-cmake.bat (
>&2 echo qt-cmake wrapper not found in '%USERPROFILE%\bin', build qtbase first!
) else (
>&2 echo No CMake or qmake build system found in %JOBDIR%
call qt-cmake !PARAM_configure! !JOBDIR!
)
) else (
if EXIST "!JOBDIR!\!projectname!.pro" (
echo "Configuring '!JOBDIR!' with 'qmake !PARAM_configure!'"
if NOT EXIST %USERPROFILE%\bin\qmake.bat (
>&2 echo qmake wrapper not found in '%USERPROFILE%\bin', build qtbase first!
) else (
call qmake !PARAM_configure! !JOBDIR!
)
) else (
>&2 echo No CMake or qmake build system found in !JOBDIR!
)
)
)
)
......
......@@ -28,15 +28,20 @@ export CXX=${PARAM_cxx:-$(search_highest "$(which g++ || which clang++)")}
function link_tool
{
toolname="$1"
if [ -f "$PWD/qtbase/bin/${toolname}" ]
binpath="$PWD/qtbase/bin"
[ -f "${binpath}/${toolname}" ] || binpath="$PWD/bin"
if [ -f "${binpath}/${toolname}" ]
then
echo "$PWD/qtbase/bin/${toolname} \"\$@\"" > "$HOME/${toolname}"
echo "${binpath}/${toolname} \"\$@\"" > "$HOME/${toolname}"
chmod +x "$HOME/${toolname}"
fi
}
projectname="$(basename $JOBDIR)"