From ba7a533d2793a7bc818793ee21435064706085b0 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Thu, 9 May 2013 22:49:27 +0000 Subject: lualibs (9may13) git-svn-id: svn://tug.org/texlive/trunk@30350 c570f23f-e606-0410-a88d-b1316a301751 --- Master/texmf-dist/source/luatex/lualibs/Makefile | 26 +++-- .../texmf-dist/source/luatex/lualibs/lualibs.dtx | 126 ++++++++++----------- .../source/luatex/lualibs/test-lualibs.lua | 81 +++++++++++++ 3 files changed, 159 insertions(+), 74 deletions(-) create mode 100644 Master/texmf-dist/source/luatex/lualibs/test-lualibs.lua (limited to 'Master/texmf-dist/source/luatex') diff --git a/Master/texmf-dist/source/luatex/lualibs/Makefile b/Master/texmf-dist/source/luatex/lualibs/Makefile index a3d2e228696..4a08cf0b716 100644 --- a/Master/texmf-dist/source/luatex/lualibs/Makefile +++ b/Master/texmf-dist/source/luatex/lualibs/Makefile @@ -6,20 +6,21 @@ DOC_DTX = $(patsubst %.dtx, %.pdf, $(DTX)) MODULES = $(wildcard lualibs-*.lua) # Files grouped by generation mode -UNPACKED= lualibs.lua -COMPILED = $(DOC_DTX) -GENERATED = $(UNPACKED) $(DOC_DTX) $(MERGED) -SOURCE = $(DTX) $(MODULES) LICENSE README Makefile NEWS -MERGED = lualibs-basic-merged.lua lualibs-extended-merged.lua +TESTSCRIPT = test-lualibs.lua +UNPACKED = lualibs.lua lualibs-extended.lua lualibs-basic.lua +COMPILED = $(DOC_DTX) +GENERATED = $(UNPACKED) $(DOC_DTX) $(MERGED) +SOURCE = $(DTX) $(MODULES) $(TESTSCRIPT) LICENSE README Makefile NEWS +MERGED = lualibs-basic-merged.lua lualibs-extended-merged.lua # Files grouped by installation location RUNFILES = $(UNPACKED) $(MODULES) DOCFILES = $(DOC_DTX) LICENSE README NEWS -SRCFILES = $(DTX) $(SRC_TEX) Makefile +SRCFILES = $(DTX) $(SRC_TEX) Makefile $(TESTSCRIPT) # The following definitions should be equivalent # ALL_FILES = $(RUNFILES) $(DOCFILES) $(SRCFILES) -ALL_FILES = $(GENERATED) $(SOURCE) $(MERGED) +ALL_FILES = $(GENERATED) $(SOURCE) # Installation locations FORMAT = luatex @@ -33,17 +34,20 @@ TDS_ZIP = $(NAME).tds.zip ZIPS = $(CTAN_ZIP) $(TDS_ZIP) DO_TEX = luatex --interaction=batchmode $< >/dev/null -DO_PDFLATEX = lualatex --interaction=batchmode $< >/dev/null +DO_PDFLATEX = latexmk -pdf -e '$$pdflatex = q(lualatex %O %S)' -silent $< >/dev/null DO_MAKEINDEX = makeindex -s gind.ist $(subst .dtx,,$<) >/dev/null 2>&1 DO_PACKAGE = mtxrun --script package --merge $< >/dev/null -all: $(GENERATED) $(DOC_TEX) $(MERGED) +all: $(GENERATED) $(DOC_TEX) doc: $(COMPILED) unpack: $(UNPACKED) -ctan: $(CTAN_ZIP) +ctan: check $(CTAN_ZIP) tds: $(TDS_ZIP) world: all ctan +check: $(TESTSCRIPT) + @texlua $(TESTSCRIPT) + .PHONY: all doc unpack ctan tds world %.pdf: %.dtx @@ -58,7 +62,7 @@ world: all ctan $(UNPACKED): lualibs.dtx $(DO_TEX) -$(CTAN_ZIP): $(SOURCE) $(COMPILED) $(TDS_ZIP) +$(CTAN_ZIP): $(SOURCE) $(COMPILED) $(GENERATED) $(TDS_ZIP) @echo "Making $@ for CTAN upload." @$(RM) -- $@ @zip -9 $@ $^ >/dev/null diff --git a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx index c154f155ddf..b8c74c01373 100644 --- a/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx +++ b/Master/texmf-dist/source/luatex/lualibs/lualibs.dtx @@ -356,59 +356,59 @@ and the derived file lualibs.lua. % % \section{Packaging} % - By default, \identifier{lualibs} will not load the libraries individually. - Instead, it includes two \emphasis{merged packages} that have been compiled - from the original files. - This is achieved by means of \identifier{mtx-package}, a script for bundling - \LUA code shipped with \CONTEXT. - This concatenates the code of several \LUA files into a single file that is - both easier to distribute and loading (marginally) faster. - \identifier{mtx-package} ensures that the code from each file gets its - own closure and strips newlines and comments, resulting in a smaller payload. - Another package that relies on it heavily is the font loader as contained in - \identifier{luaotfload} and \identifier{luatex-fonts}. - - If \CONTEXT is installed on the system, the merge files can be created - by running: - - \begin{quote}\begin{verbatim} - mtxrun --script package --merge lualibs-basic.lua - mtxrun --script package --merge lualibs-extended.lua - \end{verbatim}\end{quote} - - \noindent - Of course there is a make target for that: - - \begin{quote}\begin{verbatim} - make merge - \end{verbatim}\end{quote} - \noindent - will take care of assembling the packages from the files distributed with - \identifier{lualibs}. - - For this to work, the syntax of the \LUA file needs to be well-formed: - files that should be merged must be included via a function - \verb|loadmodule()|. - It doesn’t matter if the function actually does something; a dummy will - suffice. - Also, the argument to \verb|loadmodule()| must be wrapped in parentheses. - This rule is quite convenient, actually, since it allows excluding files - from the merge while still using \verb|loadmodule()| consistently. - - \begin{quote}\begin{verbatim} - ... - loadmodule("my-lua-file.lua") -- <= will be merged - loadmodule('my-2nd-file.lua') -- <= will be merged - loadmodule "my-3rd-file.lua" -- <= will be ignored - ... - \end{verbatim}\end{quote} - - Note that there is one exception to the packaging: - \fileent{lualibs-util-jsn.lua} cannot be successfully packaged because - it follows a different coding convention, returning a \LUA table on exit. - Therefore, the file is loaded separately as part of the \identifier{extended} - set like any other \LUA module. - +% By default, \identifier{lualibs} will not load the libraries individually. +% Instead, it includes two \emphasis{merged packages} that have been compiled +% from the original files. +% This is achieved by means of \identifier{mtx-package}, a script for bundling +% \LUA code shipped with \CONTEXT. +% This concatenates the code of several \LUA files into a single file that is +% both easier to distribute and loading (marginally) faster. +% \identifier{mtx-package} ensures that the code from each file gets its +% own closure and strips newlines and comments, resulting in a smaller payload. +% Another package that relies on it heavily is the font loader as contained in +% \identifier{luaotfload} and \identifier{luatex-fonts}. +% +% If \CONTEXT is installed on the system, the merge files can be created +% by running: +% +% \begin{quote}\begin{verbatim} +% mtxrun --script package --merge lualibs-basic.lua +% mtxrun --script package --merge lualibs-extended.lua +% \end{verbatim}\end{quote} +% +% \noindent +% Of course there is a make target for that: +% +% \begin{quote}\begin{verbatim} +% make merge +% \end{verbatim}\end{quote} +% \noindent +% will take care of assembling the packages from the files distributed with +% \identifier{lualibs}. +% +% For this to work, the syntax of the \LUA file needs to be well-formed: +% files that should be merged must be included via a function +% \verb|loadmodule()|. +% It doesn’t matter if the function actually does something; a dummy will +% suffice. +% Also, the argument to \verb|loadmodule()| must be wrapped in parentheses. +% This rule is quite convenient, actually, since it allows excluding files +% from the merge while still using \verb|loadmodule()| consistently. +% +% \begin{quote}\begin{verbatim} +% ... +% loadmodule("my-lua-file.lua") -- <= will be merged +% loadmodule('my-2nd-file.lua') -- <= will be merged +% loadmodule "my-3rd-file.lua" -- <= will be ignored +% ... +% \end{verbatim}\end{quote} +% +% Note that there is one exception to the packaging: +% \fileent{lualibs-util-jsn.lua} cannot be successfully packaged because +% it follows a different coding convention, returning a \LUA table on exit. +% Therefore, the file is loaded separately as part of the \identifier{extended} +% set like any other \LUA module. +% % %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % \part{\fileent{lualibs.lua}} @@ -450,13 +450,9 @@ lualibs.module_info = { config = config or { } config.lualibs = config.lualibs or { } -if config.lualibs.prefer_merged == nil then - lualibs.prefer_merged = true -end -if config.lualibs.load_extended == nil then - lualibs.load_extended = true -end -config.lualibs.verbose = config.lualibs.verbose == false +lualibs.prefer_merged = config.lualibs.prefer_merged or true +lualibs.load_extended = config.lualibs.load_extended or true +config.lualibs.verbose = config.lualibs.verbose or false % \end{macrocode} % The lualibs may be loaded in scripts. @@ -526,13 +522,17 @@ lualibs.loadmodule = loadmodule % % \begin{macrocode} -if lualibs.basic_loaded ~= true then +if lualibs.basic_loaded ~= true +or config.lualibs.force_reload == true +then loadmodule"lualibs-basic.lua" loadmodule"lualibs-compat.lua" --- restore stuff gone since v1.* end -if lualibs.load_extended == true -and lualibs.extended_loaded ~= true then +if lualibs.load_extended == true +and lualibs.extended_loaded ~= true +or config.lualibs.force_reload == true +then loadmodule"lualibs-extended.lua" end diff --git a/Master/texmf-dist/source/luatex/lualibs/test-lualibs.lua b/Master/texmf-dist/source/luatex/lualibs/test-lualibs.lua new file mode 100644 index 00000000000..b74fde16f94 --- /dev/null +++ b/Master/texmf-dist/source/luatex/lualibs/test-lualibs.lua @@ -0,0 +1,81 @@ +#!/usr/bin/env texlua + +local luafiles = { + "lualibs-boolean.lua", "lualibs-compat.lua", + "lualibs-dir.lua", "lualibs-file.lua", + "lualibs-function.lua", "lualibs-io.lua", + "lualibs-lpeg.lua", "lualibs-lua.lua", + "lualibs-math.lua", "lualibs-md5.lua", + "lualibs-number.lua", "lualibs-os.lua", + "lualibs-package.lua", "lualibs-set.lua", + "lualibs-string.lua", "lualibs-table.lua", + "lualibs-trac-inf.lua", "lualibs-unicode.lua", + "lualibs-url.lua", "lualibs-util-deb.lua", + "lualibs-util-dim.lua", "lualibs-util-env.lua", + "lualibs-util-jsn.lua", "lualibs-util-lua.lua", + "lualibs-util-prs.lua", "lualibs-util-sta.lua", + "lualibs-util-sto.lua", "lualibs-util-str.lua", + "lualibs-util-tab.lua", "lualibs-util-fmt.lua", + "lualibs-util-tpl.lua", "lualibs.lua", + "lualibs-basic.lua", "lualibs-basic-merged.lua", + "lualibs-extended.lua", "lualibs-extended-merged.lua", +} + +local test_cmd = "texluac -p %s &> /dev/null" + +local check_wellformed = function (file) + io.write"testing " + io.write(file) + io.write" ... " + local exit_status = os.execute(string.format(test_cmd, file)) + if exit_status == 0 then + io.write"SUCCESS!\n" + return true + end + io.write"FAIL :-/\n" + return false +end + +local check_files check_files = function (lst, n) + if n == nil then + return check_files(lst, 1) + end + local this = lst[n] + if this then + if check_wellformed(this) then + return check_files(lst, n+1) + else + return false + end + end + return true +end + +config = { lualibs = { force_reload = true } } + +local load_all = function ( ) + + io.write"testing merged packages ... " + config.lualibs.prefer_merged = true + if not pcall(function () dofile"lualibs.lua"end) then + io.write"FAIL :-/\n" + end + io.write"SUCCESS\n" + + io.write"testing files ... " + config.lualibs.prefer_merged = false + if not pcall(function () dofile"lualibs.lua"end) then + io.write"FAIL :-/\n" + end + io.write"SUCCESS\n" + return true +end + +local main = function ( ) + local retval = 0 + retval = check_files(luafiles) and retval or 1 + retval = load_all() and retval or 1 + os.exit(retval) +end + +return main() -- cgit v1.2.3