hws/build.sc
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 03 Feb 2025 12:31:28 +0000
changeset 977 1e6eca42d90b
parent 937 dc5ab66b11cc
permissions -rwxr-xr-x
updated

#!/usr/bin/env amm

val files = Seq("hw01.tex",
	        "hw02.tex",
	        "hw03.tex",
	        "hw04.tex",
	        "hw05.tex",
                "hw06.tex",
	        "hw07.tex",
	        "hw08.tex",
	        "hw09.tex")

val pdf_files = files.map(s => s.stripSuffix("tex") ++ "pdf")


@main
def make() = {
  for (f <- files) {
    println(s"Processing $f ...")
    os.proc("lualatex", f).call(stdout = os.Inherit, stdin = os.Inherit)
  }
}

@main
def make_sols() = {
  for (f <- files) {
    val old_pdf = f.stripSuffix(".tex") ++ ".pdf"
    val new_pdf = f.stripSuffix(".tex") ++ "-sol.pdf"
    println(s"Processing $f -> $new_pdf ...")
    os.proc("lualatex", f, "sol").call(stdout = os.Inherit, stdin = os.Inherit)
    os.move.over(os.pwd / old_pdf, os.pwd / new_pdf)
  }
}

@main
def all() = {
  make_sols()
  make()
}

@main
def hg() = {
  println(os.proc("hg", "commit", "-m texupdate", files ++ pdf_files).call())
  println(os.proc("hg", "push").call())
}

// extensions of files to be deleted
val todelete =
  List("fdb_latexmk",
       "log",
       "aux",
       "xdv",
       "out", 
       "fls")


@main
def clean() = {
  for (f <- os.list.stream(os.pwd) if todelete.contains(f.ext)) {
    println(s"Delete: ${f.last}")
    os.remove(f)
  }
}