hws/build.sc
author Christian Urban <christian.urban@kcl.ac.uk>
Mon, 25 Sep 2023 13:14:34 +0100
changeset 928 2f3c077359c4
child 937 dc5ab66b11cc
permissions -rwxr-xr-x
updated
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
928
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     1
#!/usr/bin/env amm
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     2
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     3
val files = Seq("hw01.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     4
	        "hw02.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     5
	        "hw03.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     6
	        "hw04.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     7
	        "hw05.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     8
                "hw06.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
     9
	        "hw07.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    10
	        "hw08.tex",
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    11
	        "hw09.tex")
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    12
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    13
val pdf_files = files.map(s => s.stripSuffix("tex") ++ "pdf")
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    14
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    15
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    16
@main
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    17
def make() = {
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    18
  for (f <- files) {
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    19
    println(s"Processing $f ...")
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    20
    os.proc("lualatex", f).call(stdout = os.Inherit, stdin = os.Inherit)
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    21
  }
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    22
}
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    23
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    24
@main
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    25
def make_sols() = {
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    26
  for (f <- files) {
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    27
    val old_pdf = f.stripSuffix(".tex") ++ ".pdf"
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    28
    val new_pdf = f.stripSuffix(".tex") ++ "-sol.pdf"
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    29
    println(s"Processing $f -> $new_pdf ...")
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    30
    os.proc("lualatex", f, "sol").call(stdout = os.Inherit, stdin = os.Inherit)
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    31
    os.move.over(os.pwd / old_pdf, os.pwd / new_pdf)
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    32
  }
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    33
}
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    34
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    35
@main
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    36
def hg() = {
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    37
  println(os.proc("hg", "commit", "-m texupdate", files ++ pdf_files).call())
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    38
  println(os.proc("hg", "push").call())
2f3c077359c4 updated
Christian Urban <christian.urban@kcl.ac.uk>
parents:
diff changeset
    39
}