tame/build-aux/gen-c1make

96 lines
2.5 KiB
Plaintext
Raw Normal View History

#!/bin/bash
# Generates GNU Make recipes for c1map build
#
# Copyright (C) 2014-2019 Ryan Specialty Group, LLC.
#
# This program 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 of the License, or
# (at your option) any later version.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
##
set -euo pipefail
# Recursively produce list of dependencies for given package
#
# Since all compilation occurs on the base package in the root of the c1map
# directory, recursive dependencies are output as part of the recipe for the
# base package rather than as dependencies of individual sub-packages.
include-list()
{
local -r dir="${1?Missing base directory}"
local -r file="${2?Missing package filename}"
# get name of all includes, recursively
grep -o 'lvm:include name="[^"]\+"' "$file" \
| cut -d\" -f2 \
| tee >(
while read dep; do
include-list "$dir" "$dir/$dep.xml"
done
)
}
# Format includes for GNUMakefile recipe
#
# All unique dependencies will be prefixed with the appropriate base path
# and will be output on a single line.
format-includes()
{
local -r dir="${1?Missing base directory}"
sort -u \
| sed "s#^.*\$#$dir/&.xml#" \
| tr '\n' ' '
}
# Produce recipe for base package
#
# This should only be provided with the filename of a base package (that is,
# an immediate child of c1map).
#
# A recipe will be output for generating a PHP file from the source code
# and all package dependencies, recursively.
c1recipe()
{
local -r file="${1?Missing source filename}"
local -r dir=$( dirname "$file" )
local -r base=$( basename "$file" .xml )
local -r includes=$(
include-list "$dir" "$file" \
| format-includes "$dir" \
)
echo "$dir/$base.php: $file $includes"
Integrate new compilation scripts, remove cqueue and Makefile.2 This is a major step toward normalcy---removing the kluge of a build process that was causing so many issues. Rather than echoing all operations to a queue file before passing it off to dslc, the new build scripts in `bin/' are used to invoke tame normally, as needed. This solves all of the current issues with things not rebuilding when they should. And, as a bonus, tab completion on targets works. Sorry this took so long. There wasn't much motivation until we hired so many people that are suffering from this. This does a few major things, along with some miscellaneous others: - Invoke bin/tame directly; - Merge Makefile.2.in into Makefile.am; and - Fix up some targets. * build-aux/Makefile.2.in: Delete file. Mostly merged with Makefile.am. * build-aux/Makefile.am: Add a bunch of new targets and definitions from Makefile.2.in. Modify all that previously used .cqueue to now invoke `$(TAME)' directly. Remove miscellaneous targets for trying to proxy targets to Makefile.2. (saneout, _go): Remove definitions. (.NOTPARALLEL): Add to prevent parallel builds. (ui/program.expanded.xml)[.version.xml]: Remove dependency for now. (clean): Also clean generated PHP files. Follow symlinks to clean core. This is still incomplete (does not clean all rate table stuff). (suppliers.mk)[xmlo_cmd]: Remove. See `gen-make' and `gen-c1make'. (lvroot)[summary-html]: New dependency. (kill-tamed, tamed-die): New targets (former alias of latter) to kill tamed. * build-aux/gen-c1make: Generate `$(TAME)' invocation. * build-aux/gen-make: Likewise. Remove `xmlo_cmd' output. Ignore recursive `tame' symlink (this can be removed once we clean `rater/' up. * build-aux/m4/calcdsl.m4 (TAME): Update description to reflect that it should now be the path to `bin/tame'. Adjust `AC_CHECK_FILE' lines accordingly. (tame_needed_ver): Remove. We have been in the same repo as TAME itself for quite some time. Remove associated code. (AC_CONFIG_FILES): Remove `Makefile.2'. * src/current/src/com/lovullo/dslc/DslCompiler.java (_DslCompiler)[compile]: Perform validation prefore `compile' command rather than a separate `validate' step. Remove `rm'. [compileSrc]: Stop echoing command. This was only necessary because of the previous Makefile klugery; now Make echoes on its own correctly.
2018-10-08 23:27:02 -04:00
echo -e '\t$(TAME) c1map $< $@'
}
# Produce recipe for each provided base package
#
# This should only be provided with filenames of a base package (that is,
# an immediate children of c1map).
main()
{
while [ $# -gt 0 ]; do
c1recipe "$1"
shift
done
}
main "$@"