Files
opu/cmake/GitVersion.cmake
yann64andClaude Opus 5.5 384aaf78c6 gtk: interface GTK4, préférences, versions, traductions, licence MIT
- interface gtkmm-4 : véhicules, ajout par VIN, mises à jour, dossier,
  téléchargement avec reprise et arrêt, choix de la clé, confirmation,
  écriture avec progression, fin avec guide d'installation ; travail
  dans un thread, résultats renvoyés via Glib::Dispatcher
- préférences : dossier de téléchargement, langue (système par défaut),
  recherche automatique de nouvelle version d'OpenPU
- recherche de nouvelle version (releases GitHub, format tags Gitea
  accepté) avec ouverture de la page dans le navigateur ;
  openpu-cli app-update
- versions : project(VERSION) + git describe régénéré à chaque build,
  openpu-cli --version, À propos, User-Agent, CHANGELOG, tools/release.sh
  (étiquette annotée, push vers tous les remotes, release GitHub)
- traductions gettext : textes anglais, fr.po complet (96 chaînes),
  extracteur de secours sans xgettext
- core : module job (téléchargement licence/fw/carte), liens des guides
  PDF, ordre des véhicules conservé (ordered_json)
- licence MIT (LICENSE, en-têtes SPDX) ; dépôt principal sur GitHub
- validé dans WSLg : parcours complet jusqu'à l'écriture d'une clé loop
  (FAT32 propre, fichiers téléchargés supprimés)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WDASLCiN764v685boRVYar
2026-11-28 19:54:04 +01:00

67 lines
2.3 KiB
CMake

# SPDX-License-Identifier: MIT
# Run at build time (cmake -P): writes ${OUTPUT} with the release version (from project()) and the
# build description from `git describe`, rewriting the file only when it changes.
#
# Inputs: SOURCE_DIR, OUTPUT, VERSION (x.y.z), GIT_EXECUTABLE (may be empty)
#
# Description examples:
# 0.2.0 built exactly from tag v0.2.0, clean tree
# 0.2.0+3.g1a2b3c4 3 commits after v0.2.0
# 0.2.0+3.g1a2b3c4.dirty ... with uncommitted changes
# 0.2.0 no git (release tarball, HaikuPorts recipe)
set(description "${VERSION}")
if(GIT_EXECUTABLE AND EXISTS "${SOURCE_DIR}/.git")
execute_process(
COMMAND "${GIT_EXECUTABLE}" describe --tags --long --dirty --match "v[0-9]*"
WORKING_DIRECTORY "${SOURCE_DIR}"
OUTPUT_VARIABLE describe
RESULT_VARIABLE rc
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
# v0.2.0-3-g1a2b3c4[-dirty]
if(rc EQUAL 0 AND describe MATCHES "^v([0-9]+\\.[0-9]+\\.[0-9]+)-([0-9]+)-(g[0-9a-f]+)(-dirty)?$")
set(tag_version "${CMAKE_MATCH_1}")
set(distance "${CMAKE_MATCH_2}")
set(hash "${CMAKE_MATCH_3}")
set(dirty "${CMAKE_MATCH_4}")
if(NOT tag_version VERSION_EQUAL VERSION AND distance EQUAL 0)
message(WARNING "tag v${tag_version} does not match project(VERSION ${VERSION})")
endif()
if(NOT distance EQUAL 0)
string(APPEND description "+${distance}.${hash}")
endif()
if(dirty)
if(distance EQUAL 0)
string(APPEND description "+${hash}")
endif()
string(APPEND description ".dirty")
endif()
else()
# No tag yet: use the commit hash only.
execute_process(
COMMAND "${GIT_EXECUTABLE}" rev-parse --short HEAD
WORKING_DIRECTORY "${SOURCE_DIR}"
OUTPUT_VARIABLE hash RESULT_VARIABLE rc
OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(rc EQUAL 0)
string(APPEND description "+g${hash}")
endif()
endif()
endif()
set(content "// Generated by cmake/GitVersion.cmake — do not edit.
#include \"openpu/version.hpp\"
namespace openpu {
const char* version() noexcept { return \"${VERSION}\"; }
const char* versionDescription() noexcept { return \"${description}\"; }
} // namespace openpu
")
if(EXISTS "${OUTPUT}")
file(READ "${OUTPUT}" previous)
endif()
if(NOT previous STREQUAL content)
file(WRITE "${OUTPUT}" "${content}")
endif()