diff --git a/.dir-locals.el b/.dir-locals.el index 4735d45..fdbce32 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -5,6 +5,9 @@ (c-basic-offset . 2) (display-fill-column-indicator-column . 100) )) + (rust-mode . ( + (indent-tabs-mode . nil) + )) (setq auto-mode-alist (cons '("\\.ui$" . nxml-mode) auto-mode-alist)) (nxml-mode . ( (indent-tabs-mode . nil) @@ -13,8 +16,10 @@ (css-indent-offset . 2) )) (js-mode . ( - (indent-tabs-mode . nil) + (indent-tabs-mode . nil) (js-indent-level . 2) )) + (meson-mode . ( + (indent-tabs-mode . nil) + )) ) - diff --git a/.editorconfig b/.editorconfig index 4f7618f..18d7f03 100644 --- a/.editorconfig +++ b/.editorconfig @@ -4,32 +4,33 @@ root = true charset = utf-8 end_of_line = lf insert_final_newline = true +trim_trailing_whitespace = true +max_line_length = 100 [meson.build] indent_size = 2 tab_size = 2 indent_style = space -[*.{c,h,h.in}] +[*.{c,h,c.in,h.in}] indent_size = 2 tab_size = 2 indent_style = space -max_line_length = 80 [*.css] indent_size = 2 tab_size = 2 indent_style = space -[*.xml] -indent_size = 2 -tab_size = 2 -indent_style = space - [*.json] indent_size = 2 tab_size = 2 indent_style = space +[*.{xml,ui}] +indent_size = 2 +tab_size = 2 +indent_style = space + [NEWS] max_line_length = 72 diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 2e40900..714f853 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,6 +1,6 @@ include: - remote: 'https://gitlab.freedesktop.org/freedesktop/ci-templates/-/raw/34039cd573a2df832d465bc9e4c5f543571f5241/templates/ci-fairy.yml' - - remote: 'https://gitlab.gnome.org/guidog/meta-phosh/-/raw/f3c92e90dcc0d65322888217429b75dd101bd0d3/ci/phosh-common-jobs.yml' + - remote: 'https://gitlab.gnome.org/guidog/meta-phosh/-/raw/0ed15edd821f8afacbf7a9c0f2a6266873289115/ci/phosh-common-jobs.yml' stages: - build diff --git a/.gitlab-ci/check-consistency b/.gitlab-ci/check-consistency new file mode 100755 index 0000000..6fd1fb0 --- /dev/null +++ b/.gitlab-ci/check-consistency @@ -0,0 +1,102 @@ +#!/bin/bash +# +# Copyright (C) 2024 The Phosh developers +# SPDX-License-Identifier: GPL-3.0-or-later +# Author: Guido Günther +# +# Check if NEWS, changelog, meson and metainfo are in sync + +set -e + +COLOR= +if [ -n "${TERM}" ] && [ "${TERM}" != "dumb" ]; then + COLOR=1 +fi + +function log +{ + local level="${1}" + local fd=2 + local use_color + + shift + if [ -n "${COLOR}" ]; then + [ "${level}" == warn ] || [ "${level}" == error ] || fd=1 + ! [ -t "${fd}" ] || use_color=1 + + if [ -n "${use_color}" ]; then + case "${level}" in + warn) + tput setaf 1 + ;; + error) + tput bold; tput setaf 1 + ;; + info) + tput setaf 2 + ;; + esac + fi + fi + + echo "$@" + + [ -z "${use_color}" ] || tput sgr0 +} + + +if [ -f debian/changelog ]; then + log info "Fetching version from d/changelog" + VERSION=$(dpkg-parsechangelog -SVersion) +elif [ -f meson.build ]; then + log info "Fetching version from meson build file" + VERSION=$(sed -n "s/.*version\s*:\s*'\([0-9].*\)'.*/\1/p" meson.build) +else + log error "E: Don't know how to get version information" + exit 1 +fi + +echo "I: Checking for '${VERSION}'" + +# News +if ! head -1 NEWS | grep -E -qs "\s+${VERSION}\s*$"; then + log error "E: Version ${VERSION} not in NEWS file" + if [[ "${VERSION}" =~ (~|-)dev ]]; then + log info "I: Unreleased development version, no need to check NEWS" + else + exit 1 + fi +else + log info "I: Found matching news entry" +fi + +# meson.build +MESON_VERSION="${VERSION/\~/.}" +if [ -f meson.build ]; then + if ! grep -qs "version\s*:\s*'$MESON_VERSION'" meson.build; then + log error "E: Version ${MESON_VERSION} not in meson.build file" + exit 1 + else + log info "I: Found matching meson version entry" + fi +else + log info "I: no meson project" +fi + +# appstream info +METAINFO=$(ls data/*metainfo.xml.in* 2>/dev/null || true) +if [ -z "${METAINFO}" ]; then + log warn "W: No metainfo" + exit 0 +fi + +if ! grep -qs "$MESON_VERSION\"" "${METAINFO}"; then + log error "E: Version ${MESON_VERSION} not in metainfo ${METAINFO}" + if [[ "${VERSION}" =~ (~|-)(alpha|beta|dev|rc) ]]; then + log info "I: Not a stable release, no metainfo is fine" + else + exit 1 + fi +else + log info "I: Found matching metainfo entry" +fi diff --git a/.gitlab-ci/check-meson b/.gitlab-ci/check-meson new file mode 100755 index 0000000..3f48adc --- /dev/null +++ b/.gitlab-ci/check-meson @@ -0,0 +1,39 @@ +#!/bin/bash +# +# Copyright (C) 2025 The Phosh developers +# +# SPDX-License-Identifier: GPL-3.0-or-later +# +# Author: Guido Günther + +ret=0 + +TMPDIR=$(mktemp -d) + +# We check files individually so we can print the diff: +while IFS= read -r -d '' file; do + if ! meson format -e --check-only "$file"; then + echo + echo "Meson file '${file}' needs reformat:" + meson format -e "$file" > "${TMPDIR}/meson.build" + diff -u "$file" "${TMPDIR}/meson.build" + rm -f "${TMPDIR}/meson.build" + ret=1 + fi +done < <(find . -name '*.build' -print0) + +if [ -n "$TMPDIR" ]; then + rmdir "${TMPDIR}" +fi + +if [ $ret -ne 0 ]; then + cat < cd po/ || exit 1 # barf on untranslated C files. Seems intltool # can't be told to exit with non-zero exit status # in this case -if intltool-update -m 2>&1 | grep -E -qs '/.*\.(c|ui)'; then +if intltool-update -m 2>&1 | grep -E -qs '/.*\.(c|ui|in)'; then intltool-update -m exit 1 fi diff --git a/.gitlab-ci/uncrustify.cfg b/.gitlab-ci/uncrustify.cfg index 7db08d9..98a3a81 100644 --- a/.gitlab-ci/uncrustify.cfg +++ b/.gitlab-ci/uncrustify.cfg @@ -110,6 +110,8 @@ sp_cmt_cpp_start = add # # Add or remove space between #else or #endif and a trailing comment. sp_endif_cmt = add +# Offset value that controls the indentation of the body of a multiline #define +pp_multiline_define_body_indent = 2 # Newlines at the start and end of the file. nl_start_of_file = remove @@ -143,3 +145,4 @@ sp_before_sparen = add # Add spaces around assignments and arithmethic operators sp_assign = add sp_arith = add +