diff options
author | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-03-06 21:58:15 +0000 |
commit | 974640d66e61e81cb197ad96fdff7b08343e4c5a (patch) | |
tree | 2e1f75f32f312b7f24ba82b4590ae230bcd6f399 /Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt | |
parent | b4fa72e61230aca75f7f6fbf988821f71edfb6b2 (diff) |
context
git-svn-id: svn://tug.org/texlive/trunk@58167 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt')
-rw-r--r-- | Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt new file mode 100644 index 00000000000..f8e4a990715 --- /dev/null +++ b/Master/texmf-dist/tex/context/base/mkxl/libs-imp-kpse.lmt @@ -0,0 +1,58 @@ +if not modules then modules = { } end modules ['libs-imp-kpse'] = { + version = 1.001, + comment = "companion to luat-imp-kpse.mkxl", + author = "Hans Hagen, PRAGMA-ADE, Hasselt NL", + copyright = "PRAGMA ADE / ConTeXt Development Team", + license = "see context related readme files" +} + +-- This is an experiment. It might make sense to have this available in case I want +-- more runners to use LuaMetaTeX in which case (as with mtxrun using LuaTeX) we +-- need to load kpse. + +local libname = "kpse" +local libfile = (os.platform == "win64" and "kpathsea*w64") + or (os.platform == "win32" and "kpathsea*w32") + or "libkpathsea" +local libkpse = resolvers.libraries.validoptional(libname) + +if package.loaded[libname] then + return package.loaded[libname] +end + +-- This is a variant that loaded directly: + +-- kpse = libkpse -- the library will issue warnings anyway +-- +-- resolvers.libraries.optionalloaded(libname,libfile) -- no need to chedk if true + +-- This variant delays loading and has a bit more protection: + +local function okay() + if libkpse and resolvers.libraries.optionalloaded(libname,libfile) then + okay = function() return true end + else + okay = function() return false end + end + return okay() +end + +local kpse = { } + +for k, v in next, libkpse do + kpse[k] = function(...) if okay() then return v(...) end end +end + +-- We properly register the module: + +package.loaded[libname] = kpse + +optional.loaded.kpse = kpse + +-- A simple test: + +-- kpse.set_program_name("pdftex") +-- print("find file:",kpse.find_file("oeps.tex")) +-- print("find file:",kpse.find_file("context.mkii")) + +return kpse |