From 7daa58c720f86c29f3f8980eddb7537f5a766309 Mon Sep 17 00:00:00 2001 From: Hans Hagen Date: Tue, 21 Jan 2014 15:48:00 +0100 Subject: beta 2014.01.21 15:48 --- scripts/context/lua/mtx-context.lua | 9 ++++++--- scripts/context/stubs/source/mtxrun_dll.c | 20 +++++++++++++++----- scripts/context/stubs/unix/mtxrunjit | 2 ++ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100755 scripts/context/stubs/unix/mtxrunjit (limited to 'scripts') diff --git a/scripts/context/lua/mtx-context.lua b/scripts/context/lua/mtx-context.lua index 4c6672051..9b620603e 100644 --- a/scripts/context/lua/mtx-context.lua +++ b/scripts/context/lua/mtx-context.lua @@ -87,14 +87,17 @@ scripts.context = scripts.context or { } -- for the moment here -if getargument("jit") or getargument("jiton") then +if jit then -- already luajittex + setargument("engine","luajittex") + setargument("jit",nil) +elseif getargument("jit") or getargument("jiton") then -- relaunch luajittex -- bonus shortcut, we assume than --jit also indicates the engine -- although --jit and --engine=luajittex are independent setargument("engine","luajittex") end -local engine_new = getargument("engine") or directives.value("system.engine") -local engine_old = environment.ownbin +local engine_new = file.nameonly(getargument("engine") or directives.value("system.engine")) +local engine_old = file.nameonly(environment.ownbin) local function restart(engine_old,engine_new) local command = format("%s --luaonly %q %s --redirected",engine_new,environment.ownname,environment.reconstructcommandline()) diff --git a/scripts/context/stubs/source/mtxrun_dll.c b/scripts/context/stubs/source/mtxrun_dll.c index 400ed6778..dc312a145 100644 --- a/scripts/context/stubs/source/mtxrun_dll.c +++ b/scripts/context/stubs/source/mtxrun_dll.c @@ -55,7 +55,6 @@ return 1; \ } -char texlua_name[] = "texlua"; // just a bare name, luatex strips the rest anyway static char cmdline[MAX_CMD]; static char dirpath[MAX_PATH]; static char progname[MAX_PATH]; @@ -73,6 +72,7 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) char *s, *luatexfname, *argstr, **lua_argv; int k, quoted, lua_argc; int passprogname = 0; + unsigned char is_jit=0; // directory of this module/executable @@ -93,6 +93,14 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) s = progname; if ( s = strrchr(s, '.') ) *s = '\0'; // remove file extension part + /* check "jit" : strlen("jit") = 3 */ + if (strncmp(s + strlen(s) - 3, "jit", 3) == 0) { + is_jit = 1; + *(s+strlen(s)-2) = "\0" ; + } else { + is_jit = 0; + } + // script path strcpy( scriptpath, dirpath ); @@ -122,7 +130,7 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) if ( !SearchPath( getenv( "PATH" ), // path to search (optional) - "texlua.exe", // file name to search + (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search NULL, // file extension to add (optional) MAX_PATH, // output buffer size luatexpath, // output buffer pointer @@ -130,7 +138,7 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) ) if ( !SearchPath( dirpath, // path to search (optional) - "texlua.exe", // file name to search + (is_jit ? "luajittex.exe":"luatex.exe"), // file name to search NULL, // file extension to add (optional) MAX_PATH, // output buffer size luatexpath, // output buffer pointer @@ -151,7 +159,8 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) lua_argv = (char **)malloc( (argc + 4) * sizeof(char *) ); if ( lua_argv == NULL ) DIE( "out of memory\n" ); - lua_argv[lua_argc=0] = texlua_name; + lua_argv[lua_argc=0] = (is_jit ? "luajittex.exe":"luatex.exe"); + lua_argv[++lua_argc] = "--luaonly"; lua_argv[++lua_argc] = scriptpath; // script to execute if (passprogname) { lua_argv[++lua_argc] = "--script"; @@ -170,7 +179,8 @@ __declspec(dllexport) int dllrunscript( int argc, char *argv[] ) // we are still here, so no luatex.dll; spawn texlua.exe instead - strcpy( luatexfname, "texlua.exe" ); + strcpy( luatexfname,(is_jit ? "luajittex.exe":"luatex.exe")); + strcpy( cmdline, " --luaonly " ); strcpy( cmdline, "\"" ); strcat( cmdline, luatexpath ); strcat( cmdline, "\" \"" ); diff --git a/scripts/context/stubs/unix/mtxrunjit b/scripts/context/stubs/unix/mtxrunjit new file mode 100755 index 000000000..171721497 --- /dev/null +++ b/scripts/context/stubs/unix/mtxrunjit @@ -0,0 +1,2 @@ +#!/bin/sh +luajittex --luaonly $(dirname $0)/mtxrun "$@" -- cgit v1.2.3