Browse Source

Small build system to build lectures

master
Dimitri Merejkowsky 5 years ago
parent
commit
d80a04413b
4 changed files with 24 additions and 4 deletions
  1. +1
    -0
      saison-2/cours/.gitignore
  2. +0
    -4
      saison-2/cours/Makefile
  3. +2
    -0
      saison-2/cours/build.in.ninja
  4. +21
    -0
      saison-2/cours/build.py

+ 1
- 0
saison-2/cours/.gitignore View File

@@ -1 +1,2 @@
*.pdf
build/

+ 0
- 4
saison-2/cours/Makefile View File

@@ -1,4 +0,0 @@
all: ./e2l-python-classes-01.pdf

%.pdf: %.md
pandoc --pdf-engine=xelatex $< -o $@

+ 2
- 0
saison-2/cours/build.in.ninja View File

@@ -0,0 +1,2 @@
rule pandoc
command = pandoc --pdf-engine=xelatex $in -o $out

+ 21
- 0
saison-2/cours/build.py View File

@@ -0,0 +1,21 @@
from path import Path
import sys
import subprocess


def main():
template = Path("build.in.ninja").text()
to_write = template
for md_file in Path(".").files("*.md"):
to_write += f"build ../{md_file.with_suffix('.pdf')}: pandoc ../{md_file}\n"
build_path = Path("build")
build_path.mkdir_p()
out = build_path / "build.ninja"
out.write_text(to_write)
process = subprocess.run(["ninja", "-C", build_path])
if process.returncode != 0:
sys.exit(1)


if __name__ == "__main__":
main()