From d8c224ae8e8f00c6f895e108c00961cc98456d5d Mon Sep 17 00:00:00 2001 From: "Dirk-Jan C. Binnema" Date: Sat, 14 Oct 2023 16:22:31 +0300 Subject: [PATCH] build: use date.py instead of date MacOS (and others) "date" command don't support all the options that GNU date has. So don't depend on that, add a small python program for this. --- .gitignore | 1 - build-aux/date.py | 9 +++++++++ meson.build | 16 ++++++++-------- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100755 build-aux/date.py diff --git a/.gitignore b/.gitignore index 88ee280a3..7d785f6be 100644 --- a/.gitignore +++ b/.gitignore @@ -105,7 +105,6 @@ configure.lineno /lib/doxyfile /version.texi /compile -build-aux/ /TAGS parse diff --git a/build-aux/date.py b/build-aux/date.py new file mode 100755 index 000000000..7cb0c067e --- /dev/null +++ b/build-aux/date.py @@ -0,0 +1,9 @@ +#!/bin/env python +#The MacOS 'date' is not quite up to GNU standards +import sys +from datetime import datetime +date=datetime.strptime(sys.argv[1],'%Y-%m-%d') +print(date.strftime(sys.argv[2])) +# +# ./date.py 2023-10-14 "The year-month is %y %m" +# diff --git a/meson.build b/meson.build index e50f7f828..ef0e3891f 100644 --- a/meson.build +++ b/meson.build @@ -99,21 +99,22 @@ endforeach cxx.check_header('charconv', required:true) +build_aux = join_paths(meson.current_source_dir(), 'build-aux') ################################################################################ # derived date values (based on 'mu-date'); used in docs -date=find_program('date', required:true) +# we can't use the 'date' because MacOS 'date' is incompatible with GNU's. +pdate=join_paths(build_aux, 'date.py') env = environment() env.set('LANG', 'C') -mu_day_month_year = run_command(date, '-u', '+%d %B %Y', '--date', mu_date, +mu_day_month_year = run_command(pdate, mu_date, '%d %B %Y', check:true, capture:true, env: env).stdout().strip() -mu_month_year = run_command(date, '-u', '+%B %Y', '--date', mu_date, +mu_month_year = run_command(pdate, mu_date, '%B %Y', check:true, capture:true, env: env).stdout().strip() -mu_year = run_command(date, '-u', '+%Y', '--date', mu_date, +mu_year = run_command(pdate, mu_date, '%Y', check:true, capture:true, env: env).stdout().strip() - ################################################################################ # config.h setup # @@ -239,8 +240,7 @@ else if not install_info.found() message('install-info not found') else - install_info_script=join_paths(meson.current_source_dir(), 'build-aux', - 'meson-install-info.sh') + install_info_script=join_paths(build_aux, 'meson-install-info.sh') endif endif @@ -267,7 +267,7 @@ version_texi_data.set('UPDATED', mu_day_month_year) version_texi_data.set('UPDATEDMONTH', mu_month_year) version_texi_data.set('UPDATEDYEAR', mu_year) -configure_file(input: join_paths('build-aux', 'version.texi.in'), +configure_file(input: join_paths(build_aux, 'version.texi.in'), output: 'version.texi', configuration: version_texi_data)