From ca74fd49f5e22a051c38e8bdc6e39e9d50169a92 Mon Sep 17 00:00:00 2001 From: "Br. Samuel Springuel" Date: Sun, 31 Jul 2016 21:02:51 -0400 Subject: [PATCH] Add version check for executable We need to make sure that the gregorio executable being used by the auto compilation feature is version matched to the GregorioTeX version being used. --- tex/gregoriosyms.sty | 8 ++++---- tex/gregoriotex-main.tex | 22 ++++++++++++++-------- tex/gregoriotex.lua | 19 ++++++++++++++++++- 3 files changed, 36 insertions(+), 13 deletions(-) diff --git a/tex/gregoriosyms.sty b/tex/gregoriosyms.sty index abffd417f..4362bda91 100644 --- a/tex/gregoriosyms.sty +++ b/tex/gregoriosyms.sty @@ -39,7 +39,7 @@ % The version of gregorio. All gregoriotex*.tex files must have the same. % All gtex files must also have the same version. -\xdef\gre@gregorioversion{4.2.0-rc2}% GREGORIO_VERSION - VersionManager.py +\xdef\gre@gregoriotexversion{4.2.0-rc2}% GREGORIO_VERSION - VersionManager.py \providecommand{\gre@declarefileversion}[2]{\relax} @@ -102,11 +102,11 @@ \long\def\gre@ifnotlatex#1{} \input gregoriotex-symbols.tex -\xdef\gre@gregoriotexluaversion{\directlua{tex.write(gregoriotex.get_gregorioversion())}}% +\xdef\gre@gregoriotexluaversion{\directlua{tex.write(gregoriotex.get_gregoriotexluaversion())}}% % Test to make sure that gregoriotex.lua is of the same version. -\IfStrEq*{\gre@gregoriotexluaversion}{\gre@gregorioversion}{}{%else - \gre@error{uncoherent file versions: gregoriosyms.sty is in version \number\gre@gregorioversion \space\space while gregoriotex.lua is in version \gre@gregoriotexluaversion}}% +\IfStrEq*{\gre@gregoriotexluaversion}{\gre@gregoriotexversion}{}{%else + \gre@error{uncoherent file versions: gregoriosyms.sty is in version \number\gre@gregoriotexversion \space\space while gregoriotex.lua is in version \gre@gregoriotexluaversion}}% %%%%%%%%% %% Color definitions diff --git a/tex/gregoriotex-main.tex b/tex/gregoriotex-main.tex index 997b94178..e61d4fe84 100644 --- a/tex/gregoriotex-main.tex +++ b/tex/gregoriotex-main.tex @@ -159,7 +159,7 @@ % The version of gregorio. All gregoriotex*.tex files must have the same. % All gtex files must also have the same version. -\xdef\gre@gregorioversion{4.2.0-rc2}% GREGORIO_VERSION - VersionManager.py +\xdef\gre@gregoriotexversion{4.2.0-rc2}% GREGORIO_VERSION - VersionManager.py % first some macros to allow checks for version: % Tests that all gregoriotex files are of the same version. @@ -167,8 +167,8 @@ % #2 is the version \def\gre@declarefileversion#1#2{% - \IfStrEq*{#2}{\gre@gregorioversion}{}{%else - \gre@error{uncoherent file versions: gregoriotex-main.tex is in version \number\gre@gregorioversion \space\space while #1 is in version \number#2}}% + \IfStrEq*{#2}{\gre@gregoriotexversion}{}{%else + \gre@error{Version Inconsistency!\MessageBreak gregoriotex-main.tex is in version \number\gre@gregoriotexversion \space\space while #1 is in version \number#2}}% }% % Macro called by scores. @@ -177,9 +177,9 @@ % #1 is the version of GregorioTeX the score is made for. \def\GregorioTeXAPIVersion#1{% - \StrBefore{\gre@gregorioversion}{.}[\gre@gregoriomajorversion]% + \StrBefore{\gre@gregoriotexversion}{.}[\gre@gregoriomajorversion]% \IfBeginWith{#1}{\gre@gregoriomajorversion}{\relax}{%else - \gre@error{GregorioTeX is in version \gre@gregorioversion \space\space while a score you included requires version #1. Please recompile your scores}}% + \gre@error{Version Inconsistency!\MessageBreak GregorioTeX is in version \gre@gregoriotexversion \space\space while a score you included requires version #1. Please recompile your scores}}% }% \RequireLuaModule{gregoriotex}% @@ -189,11 +189,17 @@ \directlua{gregoriotex.init(arg, true)}% \fi % -\xdef\gre@gregoriotexluaversion{\directlua{tex.write(gregoriotex.get_gregorioversion())}}% +\xdef\gre@gregoriotexluaversion{\directlua{tex.write(gregoriotex.get_gregoriotexluaversion())}}% % Test to make sure that gregoriotex.lua is of the same version. -\IfStrEq*{\gre@gregoriotexluaversion}{\gre@gregorioversion}{}{%else - \gre@error{uncoherent file versions: gregoriotex-main.tex is in version \number\gre@gregorioversion \space\space while gregoriotex.lua is in version \gre@gregoriotexluaversion}}% +\IfStrEq*{\gre@gregoriotexluaversion}{\gre@gregoriotexversion}{}{%else + \gre@error{Version Inconsistency!\MessageBreak gregoriotex-main.tex is in version \number\gre@gregoriotexversion \space\space while gregoriotex.lua is in version \gre@gregoriotexluaversion}}% + +% Test to make sure gregorio executable is of the same version. +\xdef\gre@gregorioversion{\directlua{tex.write(gregoriotex.get_gregorioversion())}}% +\IfBeginWith*{\gre@gregorioversion}{\gre@gregoriotexversion} + {\relax} % true + {\gre@error{Version Inconsistency!\MessageBreak GregorioTeX is in version \gre@gregoriotexversion\MessageBreak while Gregorio executable is in version \gre@gregorioversion}} %false %%%%%%%%%%%%%%%%%%%%%%%% diff --git a/tex/gregoriotex.lua b/tex/gregoriotex.lua index b449aa221..4a475125d 100644 --- a/tex/gregoriotex.lua +++ b/tex/gregoriotex.lua @@ -862,10 +862,26 @@ local function direct_gabc(gabc, header, allow_deprecated) os.remove(snippet_logname) end -local function get_gregorioversion() +local function get_gregoriotexluaversion() return internalversion end +local function get_gregorioversion() + local p = io.popen('gregorio --version', 'r') + if p == nil then + err("\nSomething went wrong when executing\n gregorio --version\n" + .."shell-escape mode may not be activated. Try\n\n" + .."%s --shell-escape %s.tex\n\n" + .."See the documentation of gregorio or your TeX\n" + .."distribution to automatize it.", tex.formatname, tex.jobname) + else + gregorioversion = p:read("*a") + p:close() + gregorioversion = string.sub(gregorioversion,10,string.find(gregorioversion,'\n')-2) + end + return gregorioversion +end + local function check_font_version() local gregoriofont = get_font_by_name('gre@font@music') if gregoriofont then @@ -1286,6 +1302,7 @@ gregoriotex.atScoreEnd = atScoreEnd gregoriotex.atScoreBeginning = atScoreBeginning gregoriotex.check_font_version = check_font_version gregoriotex.get_gregorioversion = get_gregorioversion +gregoriotex.get_gregoriotexluaversion = get_gregoriotexluaversion gregoriotex.map_font = map_font gregoriotex.init_variant_font = init_variant_font gregoriotex.change_score_glyph = change_score_glyph