diff options
author | Karl Berry <karl@freefriends.org> | 2019-04-30 22:36:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-04-30 22:36:50 +0000 |
commit | b9d1e8848fb4f8e45796a706a0391734b0c88c7c (patch) | |
tree | 8e97fb607639f6bc1bf187b6a31cb76a4c53a5c8 /Master/texmf-dist/doc/support/cluttex/build.lua | |
parent | f6aba0a218c3b19afb4ff78799e8f0760e584397 (diff) |
cluttex (30apr19)
git-svn-id: svn://tug.org/texlive/trunk@50913 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/doc/support/cluttex/build.lua')
-rw-r--r-- | Master/texmf-dist/doc/support/cluttex/build.lua | 56 |
1 files changed, 42 insertions, 14 deletions
diff --git a/Master/texmf-dist/doc/support/cluttex/build.lua b/Master/texmf-dist/doc/support/cluttex/build.lua index bda6cf637a2..24d0674ffc9 100644 --- a/Master/texmf-dist/doc/support/cluttex/build.lua +++ b/Master/texmf-dist/doc/support/cluttex/build.lua @@ -28,6 +28,7 @@ elseif arg[1] == "--windows-batchfile" then table.remove(arg, 1) end local outfile = arg[1] +local preserve_location_info = false local modules = { { @@ -82,6 +83,10 @@ local modules = { name = "texrunner.message", path = "texrunner/message.lua", }, + { + name = "texrunner.fswatcher_windows", + path = "texrunner/fswatcher_windows.lua", + }, } local imported_globals = {"io", "os", "string", "table", "package", "require", "assert", "error", "ipairs", "type", "select", "arg"} @@ -102,7 +107,13 @@ local function strip_global_imports(code) end local function strip_test_code(code) - return (code:gsub("%-%- TEST CODE\n(.-)%-%- END TEST CODE\n", "")) + if preserve_location_info then + return (code:gsub("%-%- TEST CODE\n.-%-%- END TEST CODE\n", function(s) + return (s:gsub("[^\n]","")) + end)) + else + return (code:gsub("%-%- TEST CODE\n(.-)%-%- END TEST CODE\n", "")) + end end local function load_module_code(path) @@ -133,8 +144,10 @@ else end end -table.insert(lines, string.format("local %s = %s\n", table.concat(imported_globals, ", "), table.concat(imported_globals, ", "))) -table.insert(lines, "local CLUTTEX_VERBOSITY, CLUTTEX_VERSION\n") +if not preserve_location_info then + table.insert(lines, string.format("local %s = %s\n", table.concat(imported_globals, ", "), table.concat(imported_globals, ", "))) + table.insert(lines, "local CLUTTEX_VERBOSITY, CLUTTEX_VERSION\n") +end if default_os then table.insert(lines, string.format("os.type = os.type or %q\n", default_os)) @@ -142,19 +155,34 @@ end -- LuajitTeX doesn't seem to set package.loaded table... table.insert(lines, "if lfs and not package.loaded['lfs'] then package.loaded['lfs'] = lfs end\n") - -for _,m in ipairs(modules) do - if m.path_windows or m.path_unix then - table.insert(lines, 'if os.type == "windows" then\n') - table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path_windows or m.path))) - table.insert(lines, 'else\n') - table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path_unix or m.path))) - table.insert(lines, 'end\n') - else - table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path))) +if preserve_location_info then + table.insert(lines, "local loadstring = loadstring or load\n") + for _,m in ipairs(modules) do + if m.path_windows or m.path_unix then + table.insert(lines, 'if os.type == "windows" then\n') + table.insert(lines, string.format("package.preload[%q] = assert(loadstring(%q, %q))\n", m.name, load_module_code(m.path_windows or m.path), "=" .. (m.path_windows or m.path))) + table.insert(lines, 'else\n') + table.insert(lines, string.format("package.preload[%q] = assert(loadstring(%q, %q))\n", m.name, load_module_code(m.path_unix or m.path), "=" .. (m.path_unix or m.path))) + table.insert(lines, 'end\n') + else + table.insert(lines, string.format("package.preload[%q] = assert(loadstring(%q, %q))\n", m.name, load_module_code(m.path), "=" .. m.path)) + end + end + table.insert(lines, string.format("assert(loadstring(%q, %q))(...)\n", main, "=cluttex.lua")) +else + for _,m in ipairs(modules) do + if m.path_windows or m.path_unix then + table.insert(lines, 'if os.type == "windows" then\n') + table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path_windows or m.path))) + table.insert(lines, 'else\n') + table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path_unix or m.path))) + table.insert(lines, 'end\n') + else + table.insert(lines, string.format("package.preload[%q] = function(...)\n%send\n", m.name, load_module_code(m.path))) + end end + table.insert(lines, strip_global_imports(main)) end -table.insert(lines, strip_global_imports(main)) if outfile then io.output(assert(io.open(outfile, "wb"))) |