commit d775278abdc10146b7234bcd8388f210bdf7d69e
parent 2770561cecf417efc195b306e3a1ae3f08b8d91a
Author: Florian Dold <florian@dold.me>
Date: Tue, 9 Jun 2026 23:03:12 +0200
generate sql via meson
Diffstat:
6 files changed, 104 insertions(+), 52 deletions(-)
diff --git a/src/challengerdb/Makefile.sql b/src/challengerdb/Makefile.sql
@@ -1,13 +0,0 @@
-procedures.sql: procedures.sql.in challenger_do_*.sql
- chmod +w $@ || true
- gcc -E -P -undef - < procedures.sql.in 2>/dev/null | sed -e "s/--.*//" | awk 'NF' - >$@
- chmod ugo-w $@
-
-
-CLEANFILES = \
- procedures.sql
-
-all: ${CLEANFILES}
-
-clean:
- rm ${CLEANFILES}
diff --git a/src/challengerdb/amalgamate-sql.sh b/src/challengerdb/amalgamate-sql.sh
@@ -0,0 +1,46 @@
+#!/bin/sh
+
+# This file is part of TALER
+# Copyright (C) 2026 Taler Systems SA
+#
+# TALER is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3, or (at your option) any later version.
+#
+# TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+
+set -eu
+
+if [ $# -lt 1 ]; then
+ echo "Usage: $0 SQLFILES..." >&2
+ exit 1
+fi
+
+cat <<'EOF'
+--
+-- This file is part of TALER
+-- Copyright (C) 2014--2025 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+EOF
+
+for x in $@; do
+ echo -- generated from $x
+ # Remove SQL comments and empty lines
+ cat $x | sed -e "s/--.*//" | awk 'NF'
+done
diff --git a/src/challengerdb/commit.sql b/src/challengerdb/commit.sql
@@ -0,0 +1,17 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+COMMIT;
diff --git a/src/challengerdb/meson.build b/src/challengerdb/meson.build
@@ -5,26 +5,33 @@ install_data('challenger_db_postgres.conf', install_dir: pkgcfgdir)
sqldir = get_option('datadir') / 'challenger' / 'sql'
-# FIXME possibly provide this output in the tgz through dist script
-run_command('make', '-f', 'Makefile.sql', 'all', check: true)
-
-sql_DATA = [
- 'versioning.sql',
- 'procedures.sql',
- 'challenger-0001.sql',
- 'challenger-0002.sql',
- 'drop.sql',
+procedures_sql = [
+ 'procedures-prelude.sql',
+ 'challenger_do_challenge_set_address_and_pin.sql',
+ 'challenger_do_validate_and_solve_pin.sql',
+ 'commit.sql',
]
-install_data(sources: sql_DATA, install_dir: sqldir)
+generated_sql = [
+ ['versioning.sql', ['versioning.sql']],
+ ['drop.sql', ['drop.sql']],
+ ['procedures.sql', procedures_sql],
+ ['challenger-0001.sql', ['challenger-0001.sql']],
+ ['challenger-0002.sql', ['challenger-0002.sql']],
+]
-# This makes meson copy the files into the build directory for testing
-foreach f : sql_DATA
- configure_file(input: f, output: f, copy: true)
+foreach g : generated_sql
+ custom_target(
+ 'gen-challengerdb-' + g[0],
+ input: g[1],
+ output: g[0],
+ capture: true,
+ command: ['./amalgamate-sql.sh', '@INPUT@'],
+ install: true,
+ install_dir: sqldir,
+ )
endforeach
-
-
libchallengerdb_SOURCES = [
'address_get.c',
'client_add.c',
diff --git a/src/challengerdb/procedures-prelude.sql b/src/challengerdb/procedures-prelude.sql
@@ -0,0 +1,19 @@
+--
+-- This file is part of TALER
+-- Copyright (C) 2024 Taler Systems SA
+--
+-- TALER is free software; you can redistribute it and/or modify it under the
+-- terms of the GNU General Public License as published by the Free Software
+-- Foundation; either version 3, or (at your option) any later version.
+--
+-- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
+-- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+-- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+--
+-- You should have received a copy of the GNU General Public License along with
+-- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+--
+
+BEGIN;
+
+SET search_path TO challenger;
diff --git a/src/challengerdb/procedures.sql.in b/src/challengerdb/procedures.sql.in
@@ -1,24 +0,0 @@
---
--- This file is part of TALER
--- Copyright (C) 2024 Taler Systems SA
---
--- TALER is free software; you can redistribute it and/or modify it under the
--- terms of the GNU General Public License as published by the Free Software
--- Foundation; either version 3, or (at your option) any later version.
---
--- TALER is distributed in the hope that it will be useful, but WITHOUT ANY
--- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
--- A PARTICULAR PURPOSE. See the GNU General Public License for more details.
---
--- You should have received a copy of the GNU General Public License along with
--- TALER; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
---
-
-BEGIN;
-
-SET search_path TO challenger;
-
-#include "challenger_do_challenge_set_address_and_pin.sql"
-#include "challenger_do_validate_and_solve_pin.sql"
-
-COMMIT;