summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorng0 <ng0@taler.net>2019-10-28 15:16:51 +0000
committerng0 <ng0@taler.net>2019-10-28 15:16:51 +0000
commitbddc04cb137959eae9349a3c36156b21637092c8 (patch)
tree5b9e7b09d1aeff5f535e93d1cace740a65501819
parent0e9e0f082918191bc514599c6605a5e59cb1eecc (diff)
downloadwww-bddc04cb137959eae9349a3c36156b21637092c8.tar.gz
www-bddc04cb137959eae9349a3c36156b21637092c8.tar.bz2
www-bddc04cb137959eae9349a3c36156b21637092c8.zip
rewrite build mechanism to use build-script.
-rw-r--r--.gitignore2
-rw-r--r--GNUmakefile104
-rwxr-xr-xbootstrap14
-rw-r--r--config.mk7
-rwxr-xr-xconfigure53
-rw-r--r--configure.py31
6 files changed, 204 insertions, 7 deletions
diff --git a/.gitignore b/.gitignore
index e1ce6c4..a7f5ed8 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,3 +21,5 @@ __pycache__
*.pyc
node_modules
+
+config.mk
diff --git a/GNUmakefile b/GNUmakefile
new file mode 100644
index 0000000..46fc58e
--- /dev/null
+++ b/GNUmakefile
@@ -0,0 +1,104 @@
+# This file is in the public domain.
+
+# Hardly anyone seems to read README files anymore, so keep this note here:
+# Don't remove the variables for python etc. They exist
+# because one system sticks with PEPs, and others opt
+# for installing every version side-by-side,
+# Same goes for babel.
+
+include config.mk
+
+# All: build HTML pages in all languages and compile the
+# TypeScript logic in web-common.
+.PHONY: all
+all: locale template
+ cd web-common && $(tsc)
+ $(sh) make_sitemap.sh
+ for x in en de fr it es ru pt ; do $(cp) robots.txt rendered/$$x ; done
+ for x in en de fr it es ru pt ; do $(cp) favicon.ico rendered/$$x ; done
+ for x in en de fr it es ru pt ; do $(cp) rendered/sitemap.xml rendered/$$x ; done
+ $(cp) styles.css rendered/
+ $(cp) -R images rendered/
+ for x in en de fr it es ru pt ; do $(cp) -R images rendered/$$x ; done
+ for x in en de fr it es ru pt ; do $(cp) -R web-common rendered/$$x ; done
+ $(cp) -R dist rendered/
+ $(cp) -R icons rendered/
+ $(cp) -R papers rendered/
+ $(cp) -R pdf rendered/
+ $(cp) -R presentations rendered/
+
+# Extract translateable strings from jinja2 templates.
+locale/messages.pot: template/*.j2 common/*.j2 common/*.j2.inc
+ $(env) PYTHONPATH="." $(BABEL) extract -F locale/babel.map -o locale/messages.pot .
+
+# Update translation (.po) files with new strings.
+.PHONY: locale-update
+locale-update: locale/messages.pot
+ $(msgmerge) -U -m --previous locale/en/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/de/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/fr/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/es/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/it/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/ru/LC_MESSAGES/messages.po locale/messages.pot
+ $(msgmerge) -U -m --previous locale/pt/LC_MESSAGES/messages.po locale/messages.pot
+
+ if $(grep) -nA1 '#-#-#-#-#' locale/*/LC_MESSAGES/messages.po; then $(echo) -e "\nERROR: Conflicts encountered in PO files.\n"; exit 1; fi
+
+# Compile translation files for use.
+.PHONY: locale-compile
+locale-compile:
+ $(pybabel) compile -d locale -l en --use-fuzzy
+ $(pybabel) compile -d locale -l de --use-fuzzy
+ $(pybabel) compile -d locale -l fr --use-fuzzy
+ $(pybabel) compile -d locale -l it --use-fuzzy
+ $(pybabel) compile -d locale -l es --use-fuzzy
+ $(pybabel) compile -d locale -l ru --use-fuzzy
+ $(pybabel) compile -d locale -l pt --use-fuzzy
+
+# Process everything related to gettext translations.
+.PHONY: locale
+locale: locale-update locale-compile
+
+# Run the jinja2 templating engine to expand templates to HTML
+# incorporating translations.
+template: locale-compile
+ $(python) ./template.py
+
+.PHONY: run
+run: all
+ $(browser) http://0.0.0.0:8000 &
+ $(python) -m http.server
+
+.PHONY: install
+install: all
+ $(mkdir) -p $(prefix)/share/taler-www
+ $(cp) -r rendered/* $(prefix)/share/taler-www
+
+.PHONY: uninstall
+ $(rm) -rf $(prefix)/share/taler-www
+
+.PHONY: clean
+clean:
+ $(rm) -rf __pycache__ *.pyc *~ \.*~ \#*\#
+ $(rm) -rf en/ de/ fr/ it/ es/ ru/
+ $(rm) -rf rendered/
+
+submodules/init:
+ $(git) submodule update --init --recursive
+
+submodules/update:
+ $(git) submodule update --recursive --remote
+
+.SILENT: show-help
+show-help:
+ $(printf) "install:\t\tInstall the website\n"
+ $(printf) "all:\t\t\tBuild the website\n"
+ $(printf) "locale/messages.pot:\tExtract translateable strings from jinja2 templates.\n"
+ $(printf) "locale-update:\t\tUpdate translation files with new strings.\n"
+ $(printf) "locale-compile:\t\tCompile translation files for use.\n"
+ $(printf) "locale:\t\t\tProcess everything related to gettext translations.\n"
+ $(printf) "template:\t\texpand jinja2 templates to html.\n"
+ $(printf) "run:\t\t\tspawn python webserver and open the current directory.\n"
+ $(printf) "clean:\t\t\tclean.\n"
+ $(printf) "submodules/init:\tinit git submodules\n"
+ $(printf) "submodules/update:\tupdate git submodules\n"
diff --git a/bootstrap b/bootstrap
new file mode 100755
index 0000000..82700e1
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,14 @@
+#!/bin/sh
+
+# Bootstrap the repository. Used when the repository is checked out from git.
+# When using the source tarball, running this script is not necessary.
+
+set -eu
+
+if ! git --version >/dev/null; then
+ echo "git not installed"
+ exit 1
+fi
+
+git submodule update --init
+cp build-system/taler-build-scripts/configure ./configure
diff --git a/config.mk b/config.mk
deleted file mode 100644
index 6d0dae0..0000000
--- a/config.mk
+++ /dev/null
@@ -1,7 +0,0 @@
-# config.mk Makefile fragment to set custom variables.
-
-TSC=tsc
-PYTHON=python3
-BABEL=pybabel
-
-RUN_BROWSER=$(BROWSER)
diff --git a/configure b/configure
new file mode 100755
index 0000000..4ffb738
--- /dev/null
+++ b/configure
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# This file is part of TALER
+# (C) 2019 GNUnet e.V.
+#
+# This is very simple POSIX sh script which
+# identifies the first matching
+# python3 identifier in $PATH and produces
+# configure.py from configure.py.in, and then
+# calls the new executable configure.py.
+#
+# It should be portable on Unices. Report bugs on
+# the bugtracker if you discover that it isn't
+# working as intended.
+#
+# Authors:
+# Author: ng0 <ng0@taler.net>
+#
+# Permission to use, copy, modify, and/or distribute this software for any
+# purpose with or without fee is hereby granted.
+#
+# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE
+# LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES
+# OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
+# WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
+# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
+# THIS SOFTWARE.
+#
+# SPDX-License-Identifier: 0BSD
+
+# we invoke configure not as a symlink but as a copy,
+# so we have to use a fixed location for the repository!
+dir=$(dirname "$(readlink -f -- "$0")")/build-system/taler-build-scripts
+. $dir/sh/lib.sh/existence.sh
+. $dir/sh/lib.sh/existence_python.sh
+
+scriptpath=build-system/taler-build-scripts
+
+if ! test -d "$scriptpath"; then
+ echo "fatal error: taler-build-scripts not found at $scriptpath" >&2
+ exit 1
+fi
+
+export PYTHONPATH="$scriptpath:${PYTHONPATH:-}"
+
+# Call configure.py, assuming all went well.
+# $1 is read by configure.py as the prefix.
+# If $1 is empty, the python script checks the
+# environment for PREFIX. We might need more
+# variables and switches, such as DESTDIR.
+exec "$PYTHON" ./configure.py $@
diff --git a/configure.py b/configure.py
new file mode 100644
index 0000000..beea0c2
--- /dev/null
+++ b/configure.py
@@ -0,0 +1,31 @@
+import sys
+from pathlib import Path
+
+base_dir = Path(__file__, "../build-system/taler-build-scripts").resolve()
+
+if not base_dir.exists():
+ print(f"build system directory (${base_dir}) missing", file=sys.stderr)
+ sys.exit(1)
+
+sys.path.insert(0, str(base_dir))
+
+from talerbuildconfig import *
+
+b = BuildConfig()
+b.enable_prefix()
+b.enable_configmk()
+b.add_tool(PythonTool())
+b.add_tool(PyBabelTool())
+b.add_tool(PosixTool("cp"))
+b.add_tool(PosixTool("echo"))
+b.add_tool(PosixTool("env"))
+b.add_tool(PosixTool("printf"))
+b.add_tool(PosixTool("grep"))
+b.add_tool(PosixTool("mkdir"))
+b.add_tool(PosixTool("rm"))
+b.add_tool(PosixTool("sh"))
+b.add_tool(PosixTool("msgmerge"))
+b.add_tool(PosixTool("tsc"))
+b.add_tool(PosixTool("git"))
+b.add_tool(BrowserTool())
+b.run()