Merge branch 'wip/meson' into 'master'
Build with meson. See merge request alatiera/Hammond!1
This commit is contained in:
commit
2339b4db45
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,3 +4,5 @@ Cargo.lock
|
|||||||
.vscode
|
.vscode
|
||||||
*.ui~
|
*.ui~
|
||||||
*.gresource
|
*.gresource
|
||||||
|
_build
|
||||||
|
vendor/
|
||||||
|
|||||||
@ -1,9 +1,15 @@
|
|||||||
# Optional: Install a C compiler, cmake and git into the container.
|
stages:
|
||||||
# You will often need this when you (or any of your dependencies) depends on C code.
|
# meson uses cargo to do the build
|
||||||
|
# so it's ok to have the tests first.
|
||||||
|
- test
|
||||||
|
# - build
|
||||||
|
- lint
|
||||||
|
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update -yqq
|
- apt-get update -yqq
|
||||||
- apt-get install -yqq --no-install-recommends build-essential
|
- apt-get install -yqq --no-install-recommends build-essential
|
||||||
- apt-get install -yqq --no-install-recommends libgtk-3-dev
|
- apt-get install -yqq --no-install-recommends libgtk-3-dev
|
||||||
|
# - apt-get install -yqq --no-install-recommends meson
|
||||||
|
|
||||||
# kcov
|
# kcov
|
||||||
# - apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev
|
# - apt-get install -y libcurl4-openssl-dev libelf-dev libdw-dev cmake gcc binutils-dev libiberty-dev
|
||||||
@ -11,30 +17,48 @@ before_script:
|
|||||||
# variables:
|
# variables:
|
||||||
# RUSTFLAGS: "-C link-dead-code"
|
# RUSTFLAGS: "-C link-dead-code"
|
||||||
|
|
||||||
|
# Currently doesnt work.
|
||||||
|
# # Build with meson
|
||||||
|
# build:stable:
|
||||||
|
# # Stable img
|
||||||
|
# # https://hub.docker.com/_/rust/
|
||||||
|
# image: "rust"
|
||||||
|
# script:
|
||||||
|
# - rustc --version && cargo --version
|
||||||
|
# - ./configure --prefix=/usr/local
|
||||||
|
# - make && sudo make install
|
||||||
|
|
||||||
|
# build:nightly:
|
||||||
|
# # Nightly
|
||||||
|
# # https://hub.docker.com/r/rustlang/rust/
|
||||||
|
# image: "rustlang/rust:nightly"
|
||||||
|
# script:
|
||||||
|
# - rustc --version && cargo --version
|
||||||
|
# - ./configure --prefix=/usr/local
|
||||||
|
# - make && sudo make install
|
||||||
|
|
||||||
test:stable:
|
test:stable:
|
||||||
# Stable img
|
# Stable img
|
||||||
# https://hub.docker.com/_/rust/
|
# https://hub.docker.com/_/rust/
|
||||||
image: "rust"
|
image: "rust"
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- rustc --version && cargo --version
|
||||||
- cargo build --all
|
- cargo build --all
|
||||||
- cargo test --all --verbose
|
- cargo test --all --verbose
|
||||||
# - cargo test --all --verbose --jobs 1
|
|
||||||
|
|
||||||
test:nightly:
|
test:nightly:
|
||||||
# Nightly
|
# Nightly
|
||||||
# https://hub.docker.com/r/rustlang/rust/
|
# https://hub.docker.com/r/rustlang/rust/
|
||||||
image: "rustlang/rust:nightly"
|
image: "rustlang/rust:nightly"
|
||||||
script:
|
script:
|
||||||
- rustc --version && cargo --version # Print version info for debugging
|
- rustc --version && cargo --version
|
||||||
- cargo build --all
|
- cargo build --all
|
||||||
- cargo test --all --verbose
|
- cargo test --all --verbose
|
||||||
# - cargo test --all --verbose --jobs 1
|
|
||||||
# - cargo bench
|
# - cargo bench
|
||||||
|
|
||||||
# Configure and run rustfmt on nightly
|
# Configure and run rustfmt on nightly
|
||||||
# Exits and builds fails if on bad format
|
# Exits and builds fails if on bad format
|
||||||
test:rustfmt:
|
lint:rustfmt:
|
||||||
image: "rustlang/rust:nightly"
|
image: "rustlang/rust:nightly"
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update -yqq
|
- apt-get update -yqq
|
||||||
@ -48,7 +72,7 @@ test:rustfmt:
|
|||||||
|
|
||||||
# Configure and run clippy on nightly
|
# Configure and run clippy on nightly
|
||||||
# Only fails on errors atm.
|
# Only fails on errors atm.
|
||||||
test:clippy:
|
lint:clippy:
|
||||||
image: "rustlang/rust:nightly"
|
image: "rustlang/rust:nightly"
|
||||||
before_script:
|
before_script:
|
||||||
- apt-get update -yqq
|
- apt-get update -yqq
|
||||||
|
|||||||
33
Makefile
33
Makefile
@ -1,33 +0,0 @@
|
|||||||
# Stolen from:
|
|
||||||
# https://github.com/mmstick/tv-renamer/blob/3f9e274e1b2300209172d4b3c991e9e7952b7259/Makefile
|
|
||||||
|
|
||||||
DESTDIR = /usr
|
|
||||||
|
|
||||||
all:
|
|
||||||
cargo build --release
|
|
||||||
|
|
||||||
install:
|
|
||||||
install -Dm 755 "target/release/hammond-gtk" "${DESTDIR}/bin/hammond"
|
|
||||||
ln -sf "${DESTDIR}/bin/hammond" "${DESTDIR}/bin/hammond-gtk"
|
|
||||||
install -Dm 644 "assets/hammond.desktop" "${DESTDIR}/share/applications/hammond.desktop"
|
|
||||||
install -Dm 644 README.md "${DESTDIR}/share/doc/hammond/README"
|
|
||||||
install -Dm 644 LICENSE "${DESTDIR}/share/licenses/hammond/COPYING"
|
|
||||||
|
|
||||||
tar:
|
|
||||||
install -Dm 755 "target/release/hammond-gtk" "hammond/bin/hammond"
|
|
||||||
ln -sf "hammond/bin/hammond" "hammond/bin/hammond-gtk"
|
|
||||||
install -Dm 644 "assets/hammond.desktop" "hammond/share/applications/hammond.desktop"
|
|
||||||
install -Dm 644 README.md "hammond/share/doc/hammond/README"
|
|
||||||
install -Dm 644 LICENSE "hammond/share/licenses/hammond/COPYING"
|
|
||||||
tar cf - "hammond" | xz -zf > "hammond_$(shell uname -m).tar.xz"
|
|
||||||
rm -rf hammond
|
|
||||||
|
|
||||||
uninstall:
|
|
||||||
rm "${DESTDIR}/bin/hammond"
|
|
||||||
rm "${DESTDIR}/bin/hammond-gtk"
|
|
||||||
rm "${DESTDIR}/share/applications/hammond.desktop"
|
|
||||||
rm "${DESTDIR}/share/doc/hammond/README"
|
|
||||||
rm "${DESTDIR}/share/licenses/hammond/COPYING"
|
|
||||||
|
|
||||||
clean:
|
|
||||||
cargo clean
|
|
||||||
@ -21,6 +21,7 @@ cargo run -p hammond-gtk --release
|
|||||||
```sh
|
```sh
|
||||||
git clone https://gitlab.gnome.org/alatiera/hammond.git
|
git clone https://gitlab.gnome.org/alatiera/hammond.git
|
||||||
cd Hammond/
|
cd Hammond/
|
||||||
|
./configure --prefix=/usr/local
|
||||||
make && sudo make install
|
make && sudo make install
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ Name=Hammond
|
|||||||
GenericName=Podcast Client
|
GenericName=Podcast Client
|
||||||
Comment=Play, Subscribe and Manage Podcast Feeds.
|
Comment=Play, Subscribe and Manage Podcast Feeds.
|
||||||
Icon=multimedia-player
|
Icon=multimedia-player
|
||||||
Exec=hammond-gtk
|
Exec=hammond
|
||||||
Terminal=false
|
Terminal=false
|
||||||
Type=Application
|
Type=Application
|
||||||
StartupNotify=true
|
StartupNotify=true
|
||||||
182
configure
vendored
Executable file
182
configure
vendored
Executable file
@ -0,0 +1,182 @@
|
|||||||
|
# Adapted from:
|
||||||
|
# https://gitlab.gnome.org/danigm/libgepub/blob/27f0d374e0c8f6fa972dbd111d4ce0c0f3096914/configure_meson
|
||||||
|
|
||||||
|
#!/bin/bash
|
||||||
|
# configure script adapter for Meson
|
||||||
|
# Based on build-api: https://github.com/cgwalters/build-api
|
||||||
|
# Copyright 2010, 2011, 2013 Colin Walters <walters@verbum.org>
|
||||||
|
# Copyright 2016, 2017 Emmanuele Bassi
|
||||||
|
# Copyright 2017 Iñigo Martínez <inigomartinez@gmail.com>
|
||||||
|
# Licensed under the new-BSD license (http://www.opensource.org/licenses/bsd-license.php)
|
||||||
|
|
||||||
|
# Build API variables:
|
||||||
|
|
||||||
|
# Little helper function for reading args from the commandline.
|
||||||
|
# it automatically handles -a b and -a=b variants, and returns 1 if
|
||||||
|
# we need to shift $3.
|
||||||
|
read_arg() {
|
||||||
|
# $1 = arg name
|
||||||
|
# $2 = arg value
|
||||||
|
# $3 = arg parameter
|
||||||
|
local rematch='^[^=]*=(.*)$'
|
||||||
|
if [[ $2 =~ $rematch ]]; then
|
||||||
|
read "$1" <<< "${BASH_REMATCH[1]}"
|
||||||
|
else
|
||||||
|
read "$1" <<< "$3"
|
||||||
|
# There is no way to shift our callers args, so
|
||||||
|
# return 1 to indicate they should do it instead.
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sanitycheck() {
|
||||||
|
# $1 = arg name
|
||||||
|
# $1 = arg command
|
||||||
|
# $2 = arg alternates
|
||||||
|
local cmd=$( which $2 2>/dev/null )
|
||||||
|
|
||||||
|
if [ -x "$cmd" ]; then
|
||||||
|
read "$1" <<< "$cmd"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
test -z $3 || {
|
||||||
|
for alt in $3; do
|
||||||
|
cmd=$( which $alt 2>/dev/null )
|
||||||
|
|
||||||
|
if [ -x "$cmd" ]; then
|
||||||
|
read "$1" <<< "$cmd"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
echo -e "\e[1;31mERROR\e[0m: Command '$2' not found"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
checkoption() {
|
||||||
|
# $1 = arg
|
||||||
|
option="${1#*--}"
|
||||||
|
action="${option%%-*}"
|
||||||
|
name="${option#*-}"
|
||||||
|
if [ ${default_options[$name]+_} ]; then
|
||||||
|
case "$action" in
|
||||||
|
enable) meson_options[$name]=true;;
|
||||||
|
disable) meson_options[$name]=false;;
|
||||||
|
*) echo -e "\e[1;33mINFO\e[0m: Ignoring unknown action '$action'";;
|
||||||
|
esac
|
||||||
|
else
|
||||||
|
echo -e "\e[1;33mINFO\e[0m: Ignoring unknown option '$option'"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
echooption() {
|
||||||
|
# $1 = option
|
||||||
|
if [ ${meson_options[$1]+_} ]; then
|
||||||
|
echo ${meson_options[$1]}
|
||||||
|
elif [ ${default_options[$1]+_} ]; then
|
||||||
|
echo ${default_options[$1]}
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
sanitycheck MESON 'meson'
|
||||||
|
sanitycheck MESONTEST 'mesontest'
|
||||||
|
sanitycheck NINJA 'ninja' 'ninja-build'
|
||||||
|
|
||||||
|
declare -A meson_options
|
||||||
|
|
||||||
|
while (($# > 0)); do
|
||||||
|
case "${1%%=*}" in
|
||||||
|
--prefix) read_arg prefix "$@" || shift;;
|
||||||
|
--bindir) read_arg bindir "$@" || shift;;
|
||||||
|
--sbindir) read_arg sbindir "$@" || shift;;
|
||||||
|
--libexecdir) read_arg libexecdir "$@" || shift;;
|
||||||
|
--datarootdir) read_arg datarootdir "$@" || shift;;
|
||||||
|
--datadir) read_arg datadir "$@" || shift;;
|
||||||
|
--sysconfdir) read_arg sysconfdir "$@" || shift;;
|
||||||
|
--libdir) read_arg libdir "$@" || shift;;
|
||||||
|
--mandir) read_arg mandir "$@" || shift;;
|
||||||
|
--includedir) read_arg includedir "$@" || shift;;
|
||||||
|
*) checkoption $1;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
|
||||||
|
# Defaults
|
||||||
|
test -z ${prefix} && prefix="/usr/local"
|
||||||
|
test -z ${bindir} && bindir=${prefix}/bin
|
||||||
|
test -z ${sbindir} && sbindir=${prefix}/sbin
|
||||||
|
test -z ${libexecdir} && libexecdir=${prefix}/bin
|
||||||
|
test -z ${datarootdir} && datarootdir=${prefix}/share
|
||||||
|
test -z ${datadir} && datadir=${datarootdir}
|
||||||
|
test -z ${sysconfdir} && sysconfdir=${prefix}/etc
|
||||||
|
test -z ${libdir} && libdir=${prefix}/lib
|
||||||
|
test -z ${mandir} && mandir=${prefix}/share/man
|
||||||
|
test -z ${includedir} && includedir=${prefix}/include
|
||||||
|
|
||||||
|
# The source directory is the location of this file
|
||||||
|
srcdir=$(dirname $0)
|
||||||
|
|
||||||
|
# The build directory is the current location
|
||||||
|
builddir=`pwd`
|
||||||
|
|
||||||
|
# If we're calling this file from the source directory then
|
||||||
|
# we automatically create a build directory and ensure that
|
||||||
|
# both Meson and Ninja invocations are relative to that
|
||||||
|
# location
|
||||||
|
if [[ -f "${builddir}/meson.build" ]]; then
|
||||||
|
mkdir -p _build
|
||||||
|
builddir="${builddir}/_build"
|
||||||
|
NINJA_OPT="-C ${builddir}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Wrapper Makefile for Ninja
|
||||||
|
cat > Makefile <<END
|
||||||
|
# Generated by configure; do not edit
|
||||||
|
|
||||||
|
all:
|
||||||
|
${NINJA} ${NINJA_OPT}
|
||||||
|
|
||||||
|
install:
|
||||||
|
DESTDIR="\$(DESTDIR)" ${NINJA} ${NINJA_OPT} install
|
||||||
|
|
||||||
|
uninstall:
|
||||||
|
${NINJA} ${NINJA_OPT} uninstall
|
||||||
|
|
||||||
|
release:
|
||||||
|
${NINJA} ${NINJA_OPT} release
|
||||||
|
|
||||||
|
check:
|
||||||
|
${MESONTEST} ${NINJA_OPT}
|
||||||
|
END
|
||||||
|
|
||||||
|
echo "
|
||||||
|
|
||||||
|
hammond
|
||||||
|
=======
|
||||||
|
|
||||||
|
meson: ${MESON}
|
||||||
|
ninja: ${NINJA}
|
||||||
|
prefix: ${prefix}
|
||||||
|
|
||||||
|
Now type 'make' to build
|
||||||
|
"
|
||||||
|
|
||||||
|
cmd_options=""
|
||||||
|
for key in "${!meson_options[@]}"; do
|
||||||
|
cmd_options="$cmd_options -Denable-$key=${meson_options[$key]}"
|
||||||
|
done
|
||||||
|
|
||||||
|
exec ${MESON} \
|
||||||
|
--prefix=${prefix} \
|
||||||
|
--libdir=${libdir} \
|
||||||
|
--libexecdir=${libexecdir} \
|
||||||
|
--datadir=${datadir} \
|
||||||
|
--sysconfdir=${sysconfdir} \
|
||||||
|
--bindir=${bindir} \
|
||||||
|
--includedir=${includedir} \
|
||||||
|
--mandir=${mandir} \
|
||||||
|
${cmd_options} \
|
||||||
|
${builddir} \
|
||||||
|
${srcdir}
|
||||||
36
meson.build
Normal file
36
meson.build
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
# Adatped from:
|
||||||
|
# https://gitlab.gnome.org/danigm/fractal/blob/6e2911f9d2353c99a18a6c19fab7f903c4bbb431/meson.build
|
||||||
|
|
||||||
|
project(
|
||||||
|
'hammond', 'rust',
|
||||||
|
version: '0.1.0',
|
||||||
|
license: 'GPLv3',
|
||||||
|
)
|
||||||
|
|
||||||
|
hammond_version = meson.project_version()
|
||||||
|
version_array = hammond_version.split('.')
|
||||||
|
hammond_major_version = version_array[0].to_int()
|
||||||
|
hammond_minor_version = version_array[1].to_int()
|
||||||
|
hammond_version_micro = version_array[2].to_int()
|
||||||
|
|
||||||
|
hammond_prefix = get_option('prefix')
|
||||||
|
hammond_bindir = join_paths(hammond_prefix, get_option('bindir'))
|
||||||
|
|
||||||
|
install_data('assets/org.gnome.Hammond.desktop', install_dir : get_option('datadir') + '/applications')
|
||||||
|
|
||||||
|
cargo = find_program('cargo', required: false)
|
||||||
|
gresource = find_program('glib-compile-resources', required: false)
|
||||||
|
cargo_vendor = find_program('cargo-vendor', required: false)
|
||||||
|
cargo_script = find_program('scripts/cargo.sh')
|
||||||
|
|
||||||
|
cargo_release = custom_target('cargo-build',
|
||||||
|
build_by_default: true,
|
||||||
|
output: ['hammond'],
|
||||||
|
install: true,
|
||||||
|
install_dir: hammond_bindir,
|
||||||
|
command: [cargo_script, '@CURRENT_SOURCE_DIR@', '@OUTPUT@'])
|
||||||
|
|
||||||
|
run_target('release', command: ['scripts/release.sh',
|
||||||
|
meson.project_name() + '-' + hammond_version
|
||||||
|
],
|
||||||
|
depends: [cargo_release])
|
||||||
3
scripts/cargo.sh
Executable file
3
scripts/cargo.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
cargo build --release && cp $1/target/release/hammond-gtk $2
|
||||||
41
scripts/release.sh
Executable file
41
scripts/release.sh
Executable file
@ -0,0 +1,41 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
VERSION=$1
|
||||||
|
DEST=${MESON_BUILD_ROOT}
|
||||||
|
DIST=$DEST/dist/$VERSION
|
||||||
|
|
||||||
|
|
||||||
|
cd "${MESON_SOURCE_ROOT}"
|
||||||
|
mkdir -p $DIST
|
||||||
|
|
||||||
|
# copying files
|
||||||
|
cp -rf hammond-data $DIST
|
||||||
|
cp -rf hammond-gtk $DIST
|
||||||
|
cp -rf hammond-downloader $DIST
|
||||||
|
cp build.rs $DIST
|
||||||
|
cp Cargo.toml $DIST
|
||||||
|
cp configure $DIST
|
||||||
|
cp meson.build $DIST
|
||||||
|
cp Hammond.doap $DIST
|
||||||
|
cp LICENSE $DIST
|
||||||
|
cp README.md $DIST
|
||||||
|
# cp -rf assets/org.gnome.Hammond.desktop $DIST
|
||||||
|
cp -rf assets $DIST
|
||||||
|
cp -rf scripts $DIST
|
||||||
|
|
||||||
|
# cargo vendor
|
||||||
|
cargo vendor
|
||||||
|
mkdir $DIST/.cargo
|
||||||
|
cat <<EOF > $DIST/.cargo/config
|
||||||
|
[source.crates-io]
|
||||||
|
replace-with = "vendored-sources"
|
||||||
|
|
||||||
|
[source.vendored-sources]
|
||||||
|
directory = "vendor"
|
||||||
|
EOF
|
||||||
|
cp -rf vendor $DIST/
|
||||||
|
|
||||||
|
# packaging
|
||||||
|
cd $DEST/dist
|
||||||
|
tar -czvf $VERSION.tar.gz $VERSION
|
||||||
|
|
||||||
Loading…
Reference in New Issue
Block a user