1#!/usr/bin/env texlua
2
3-- Build script for "beamer" files
4
5-- Identify the bundle and module
6bundle = ""
7module = "beamer"
8
9-- Non-standard structure
10docfiledir    = "./doc"
11sourcefiledir = "./base"
12flattentds = false
13
14-- Install all files from the source tree directly
15installfiles = {"**/*.cls", "**/*.sty", "**/beamericon*.*"}
16sourcefiles  = installfiles
17unpackfiles  = { }
18
19-- Typeset only the main documentation file,
20-- but make all sources available
21docfiles     =
22  {
23    "**/*.jpg",
24    "**/*.tex",
25    "**/*.txt",
26    "**/beamerlogo.pdf",
27    "**/beamerexample-lecture-logo.pdf"
28  }
29typesetfiles =
30  {
31    "beameruserguide.tex",
32    "beamerexample-conference-talk.tex",
33    "beamerexample-lecture-beamer-version.tex",
34    "beamerexample-lecture-print-version.tex"
35  }
36
37-- Only copy Markdown files to main dir
38textfiles = {"*.md"}
39
40-- Custom clean-up settings
41cleanfiles = {"beameruserguide.pdf", "*.zip"}
42
43-- Test set up
44checkengines   = {"pdftex"}
45checksuppfiles = {"*.tex"}
46
47-- Use standard MakeIndex style
48indexstyle = ""
49
50-- Auto-versioning
51tagfiles = {"beamer.cls", "beamerarticle.sty", "beameruserguide.tex", "CHANGELOG.md"}
52function update_tag(file,content,tagname,tagdate)
53  local tagdate = string.gsub(tagdate,"%-","/")
54  if string.match(file,"%.tex") then
55    return string.gsub(content,
56      "\\def\\beamerugversion{%d%.%d+}",
57      "\\def\\beamerugversion{" .. string.gsub(tagname,"^v","") .. "}")
58  elseif string.match(file,"CHANGELOG.md") then
59    local url = "https://github.com/josephwright/beamer/compare/"
60    local previous = string.match(content,"compare/(v%d%.%d%d)%.%.%.HEAD")
61    if tagname == previous then return content end
62    content = string.gsub(content,
63      "## %[Unreleased%]",
64      "## [Unreleased]\n\n## [" .. tagname .."]")
65    return string.gsub(content,
66      "v%d.%d%d%.%.%.HEAD",
67      tagname .. "...HEAD\n[" .. tagname .. "]: " .. url .. previous
68        .. "..." .. tagname)
69  else
70    return string.gsub(content,
71      "%d%d%d%d/%d%d/%d%d v?%d%.%d+",
72      tagdate .. " " .. tagname)
73  end
74end
75
76-- Release a TDS-style zip
77packtdszip = true
78
79-- Preserve structure for CTAN
80flatten = false
81
82-- Custom data for the theme demos
83themes =
84  {
85    core =
86      {
87        "AnnArbor", "Antibes", "Berkeley", "Berlin", "Bergen", "Boadilla",
88        "Copenhagen", "Darmstadt", "Dresden", "EastLansing", "Frankfurt",
89        "Goettingen", "Hannover", "Ilmenau", "JuanLesPins", "Luebeck",
90        "Malmoe", "Madrid", "Marburg", "Montpellier", "PaloAlto",
91        "Pittsburgh", "Rochester", "Singapore", "Szeged", "Warsaw",
92        "CambridgeUS", "default", "boxes"
93      },
94    font =
95      {
96        "default", "serif", "structurebold", "structureitalicserif",
97        "structuresmallcapsserif"
98      },
99    color =
100      {
101        "default", "crane", "albatross", "seahorse", "whale", "dolphin",
102        "rose", "orchid", "sidebartab", "lily", "structure", "dove", "seagull",
103        "beetle", "fly", "wolverine", "spruce", "beaver", "monarca",
104        "albatrossstylish" -- This is a special case: see the .tex file
105      },
106    outer =
107      {
108        "default", "infolines", "miniframes", "shadow", "sidebar",
109        "smoothbars", "smoothtree", "split", "tree"
110      },
111    inner = {"default", "circles", "rectangles", "rounded", "inmargin"}
112  }
113
114function typeset_demo_tasks()
115  local errorlevel = 0
116  for type,themelist in pairs(themes) do
117    local themetype = ""
118    if  type~= "core" then themetype = tostring(type) end
119    local name = "beamer" .. themetype .. "themeexample.tex"
120    for _,theme in pairs(themelist) do
121      errorlevel = errorlevel + runcmd(
122        "pdflatex \"\\def\\themename{" .. theme .. "}"
123          .. "\\input " .. name .. "\" ",
124          typesetdir, {"TEXINPUTS"}
125      )
126      if errorlevel ~= 0 then
127        return errorlevel
128      end
129      ren(typesetdir,
130        string.gsub(name, "%.tex$", ".pdf"),
131        "beamerug" .. themetype .. "theme" .. theme .. ".pdf")
132    end
133  end
134  return 0
135end
136
137-- Find and run the build system
138kpse.set_program_name ("kpsewhich")
139if not release_date then
140  dofile(kpse.lookup("l3build.lua"))
141end
142