|
| 1 | +#!/usr/bin/python |
| 2 | + |
| 3 | +import sys |
| 4 | +from makefile_builder import MakefileBuilder |
| 5 | + |
| 6 | +# to add a table to the build process, add a tuple to the ``tables_to_build`` list. |
| 7 | + |
| 8 | +tables_to_build = [ |
| 9 | +# (input_file, output_file, makefile_block) |
| 10 | + ('$(rst-include)/table-sql-to-agg-terms.yaml', '$(rst-include)/table-sql-to-agg-terms.rst', 'agg'), |
| 11 | + ('$(rst-include)/table-sql-to-agg-examples.yaml','$(rst-include)/table-sql-to-agg-examples.rst', 'agg'), |
| 12 | + ('$(rst-include)/table-sql-to-mongo-executables.yaml', '$(rst-include)/table-sql-to-mongo-executables.rst', 'sql'), |
| 13 | + ('$(rst-include)/table-sql-to-mongo-terms.yaml', '$(rst-include)/table-sql-to-mongo-terms.rst', 'sql'), |
| 14 | + ('$(rst-include)/table-sql-to-mongo-schema-examples.yaml', '$(rst-include)/table-sql-to-mongo-schema-examples.rst', 'sql'), |
| 15 | + ('$(rst-include)/table-sql-to-mongo-insert-examples.yaml', '$(rst-include)/table-sql-to-mongo-insert-examples.rst', 'sql'), |
| 16 | + ('$(rst-include)/table-sql-to-mongo-select-examples.yaml', '$(rst-include)/table-sql-to-mongo-select-examples.rst', 'sql'), |
| 17 | + ('$(rst-include)/table-sql-to-mongo-update-examples.yaml', '$(rst-include)/table-sql-to-mongo-update-examples.rst', 'sql'), |
| 18 | + ('$(rst-include)/table-sql-to-mongo-delete-examples.yaml', '$(rst-include)/table-sql-to-mongo-delete-examples.rst', 'sql'), |
| 19 | +] |
| 20 | + |
| 21 | +m = MakefileBuilder() |
| 22 | + |
| 23 | +def build_all_tables(tables): |
| 24 | + m.comment('each table is compiled into rst from a yaml file using the table_builder.py file.', block='header') |
| 25 | + m.newline(block='header') |
| 26 | + |
| 27 | + for table in tables: |
| 28 | + makefile_table(table[0], table[1], table[2]) |
| 29 | + |
| 30 | + m.comment('meta-targets for testing/integration with rest of the build. must apear at the end', block='footer') |
| 31 | + m.newline(block='footer') |
| 32 | + |
| 33 | + m.target('.PHONY', 'tables clean-tables', block='footer') |
| 34 | + m.target('tables', '$(output-tables)', block='footer') |
| 35 | + m.job('git update-index --assume-unchanged', block='footer') |
| 36 | + m.msg('[build]: clensing git index of compiled tables', block='footer') |
| 37 | + m.newline(block='footer') |
| 38 | + m.target('clean-tables', block='footer') |
| 39 | + m.job('rm -rf $(output-tables)', True) |
| 40 | + |
| 41 | +def makefile_table(input, output, block): |
| 42 | + m.append_var('output-tables', output, block) |
| 43 | + m.target(output, input, block) |
| 44 | + m.job('$(PYTHONBIN) bin/table_builder.py $< $@', block) |
| 45 | + m.msg('[table-builder]: \(re\)generate $@ table for inclusion in build', block) |
| 46 | + m.newline(block=block) |
| 47 | + |
| 48 | +def main(): |
| 49 | + build_all_tables(tables_to_build) |
| 50 | + |
| 51 | + m.write(sys.argv[1]) |
| 52 | + |
| 53 | + print('[meta-build]: built "' + sys.argv[1] + '" to specify table builders.') |
| 54 | + |
| 55 | +if __name__ == '__main__': |
| 56 | + main() |
0 commit comments