ports: Add some defaults for CMake projects as well
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
apio 2023-07-24 18:50:51 +02:00
parent a990cc145e
commit c70790bf62
Signed by: apio
GPG Key ID: B8A7D06E42258954
3 changed files with 21 additions and 23 deletions

View File

@ -113,8 +113,9 @@ do_configure()
The first two flags `--host=$LUNA_ARCH-luna --prefix=/usr` are required if using a standard configure script, to indicate that we're cross-compiling (compiling the program for another system).
Alternatively, you can simply set `use_default_configure=true` without a `do_configure` function, which will simply run the configure script with these two flags, if you don't need anything else.
If using CMake and not needing any extra parameters, setting `use_cmake_configure=true` will have the same effect.
This function is required (unless setting `use_default_configure` to `true`), if you don't need it you can simply make it an empty function.
This function is required (unless setting `use_default_configure` or `use_cmake_configure` to `true`), if you don't need it you can simply make it an empty function.
#### Building
This step is self-explanatory, and is done using the `do_build` function.
@ -131,6 +132,7 @@ As always, you can refer to the source directory with `srcdir`.
If you're using make, you can use the variable `MAKEJOBS` to run the build process in parallel.
Alternatively, if you're invoking make without any specific parameters, you can set `default_build_make=true` and skip the `do_build` function. This is the equivalent of doing `make -j$MAKEJOBS`.
Alternatively, if using CMake, you can set `default_build_cmake=true` to do the same thing.
In any other case, the `do_build` function is required.
@ -151,6 +153,7 @@ do_install()
}
```
If you're invoking `make install` without any specific parameters, you can set `default_install_make=true` and skip the `do_install` function.
If the project uses CMake and you don't need to pass any extra parameters, you can set `default_install_cmake=true`.
In any other case, the `do_install` function is required.
@ -168,28 +171,22 @@ url="https://git.cloudapio.eu/apio/minitar.git"
tag="$version"
# Build instructions
do_configure()
{
cmake -S $srcdir -B $builddir -DCMAKE_C_COMPILER=$LUNA_ARCH-luna-gcc
}
use_cmake_configure=true
do_build()
{
# Also build the examples
cmake --build $builddir --target examples
cmake --build . --target examples
}
do_install()
{
mkdir -p $installdir/usr/lib/
cp $builddir/libmtar.a $installdir/usr/lib/
cmake --install . --prefix /usr
mkdir -p $installdir/usr/bin/
cp $builddir/examples/pack $builddir/examples/untar $builddir/examples/list $installdir/usr/bin/
mkdir -p $installdir/usr/include/
cp $srcdir/minitar.h $installdir/usr/include/
cp examples/pack examples/untar examples/list $installdir/usr/bin/
}
```
This port is downloaded using git and built using cmake. Since the defaults are geared towards make, all the functions must be defined. The `do_install` function is a bit manual because cmake is a bit more complicated.
This port is downloaded using git and built using cmake. Since we're building some extra components, `do_build` and `do_install` cannot be set to the default.
#### nasm
```

View File

@ -8,23 +8,17 @@ url="https://git.cloudapio.eu/apio/minitar.git"
tag="$version"
# Build instructions
do_configure()
{
cmake -S $srcdir -B $builddir -DCMAKE_C_COMPILER=$LUNA_ARCH-luna-gcc
}
use_cmake_configure=true
do_build()
{
# Also build the examples
cmake --build $builddir --target examples
cmake --build . --target examples
}
do_install()
{
mkdir -p $installdir/usr/lib/
cp $builddir/libmtar.a $installdir/usr/lib/
cmake --install . --prefix /usr
mkdir -p $installdir/usr/bin/
cp $builddir/examples/pack $builddir/examples/untar $builddir/examples/list $installdir/usr/bin/
mkdir -p $installdir/usr/include/
cp $srcdir/minitar.h $installdir/usr/include/
cp examples/pack examples/untar examples/list $installdir/usr/bin/
}

View File

@ -70,8 +70,10 @@ echo "Configuring $name..."
if [ "$use_default_configure" = "true" ]; then
$srcdir/configure --host=$LUNA_ARCH-luna --prefix=/usr
elif [ "$use_cmake_configure" = "true" ]; then
cmake -S $srcdir -B . -DCMAKE_C_COMPILER=$LUNA_ARCH-luna-gcc -DCMAKE_CXX_COMPILER=$LUNA_ARCH-luna-g++ -G "Unix Makefiles"
else
declare -F do_configure &>/dev/null || show_error "error: If not using the default configure line, the PACKAGE file must provide a 'do_configure' function."
declare -F do_configure &>/dev/null || show_error "error: If not using a default configure line, the PACKAGE file must provide a 'do_configure' function."
do_configure
fi
@ -81,6 +83,8 @@ export MAKEJOBS=$(nproc)
if [ "$default_build_make" = "true" ]; then
make -j$MAKEJOBS
elif [ "$default_build_cmake" = "true" ]; then
cmake --build .
else
declare -F do_build &>/dev/null || show_error "error: If not using a default build preset, the PACKAGE file must provide a 'do_build' function."
do_build
@ -88,10 +92,13 @@ fi
echo "Installing $name..."
mkdir -p $installdir
export DESTDIR=$installdir
if [ "$default_install_make" = "true" ]; then
make install
elif [ "$default_install_cmake" = "true" ]; then
cmake --install $builddir --prefix /usr
else
declare -F do_install &>/dev/null || show_error "error: If not using a default install preset, the PACKAGE file must provide a 'do_install' function."
do_install