From 5b34e978a75f89b0be8c5828696bd5f39c028806 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Fri, 17 Jul 2015 07:57:38 +0200 Subject: [status, doc] remove references to override script --- scripts/mkstatus | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mkstatus b/scripts/mkstatus index e18abb7..ba9cb06 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -56,7 +56,7 @@ local names = { { "src", "luaotfload-log.lua", }, { "src", "luaotfload-main.lua", }, { "src/fontloader/runtime", "fontloader-fontloader.lua", }, - { "src", "luaotfload-override.lua", }, + --{ "src", "luaotfload-override.lua", }, --> part of init now { "src", "luaotfload-parsers.lua", }, { "src", "luaotfload-tool.lua", }, { "scripts", "mkcharacters", }, -- cgit v1.2.3 From 33228c6a2c0d633d91c917d9f782b365c7ddbb99 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Mon, 20 Jul 2015 08:21:43 +0200 Subject: [import] move merge result into build destination --- scripts/mkimport | 51 +++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 8 deletions(-) mode change 100644 => 100755 scripts/mkimport (limited to 'scripts') diff --git a/scripts/mkimport b/scripts/mkimport old mode 100644 new mode 100755 index a430587..e393a7a --- a/scripts/mkimport +++ b/scripts/mkimport @@ -1,7 +1,7 @@ #!/usr/bin/env texlua ------------------------------------------------------------------------------- -- FILE: mkimport.lua --- USAGE: ./mkimport.lua +-- USAGE: texlua ./mkimport.lua -- DESCRIPTION: check luaotfload imports against Context -- REQUIREMENTS: luatex, the lualibs package, Context MkIV -- AUTHOR: Philipp Gesang (Phg), @@ -12,12 +12,15 @@ ------------------------------------------------------------------------------- --- PURPOSE ---- +--- --- - Facilitate detecting changes in the fontloader source. --- - Assist in updating source code and (partially) automate importing. +--- --- - Account for files in the plain fontloader distribution, alert in case of --- additions or deletions. ---- +--- +--- - Fontloader packaging. +--- ------------------------------------------------------------------------------- local debug = false @@ -26,6 +29,7 @@ kpse.set_program_name "luatex" local lfs = require "lfs" local md5 = require "md5" +local os = require "os" require "lualibs" @@ -37,7 +41,9 @@ local lfschdir = lfs.chdir local lfsisdir = lfs.isdir local lfsisfile = lfs.isfile local md5sumhexa = md5.sumhexa +local osdate = os.date local osgettimeofday = os.gettimeofday +local osrename = os.rename local stringformat = string.format local tableconcat = table.concat @@ -71,6 +77,26 @@ local prefixes = { fontloader = "luatex", } +--[[doc-- + + The output name is fixed so we have to deal with it but maybe we + can get a patch to mtx-package upstreamed in the future. In any + case, we are content with renaming the result for the time being. + + The target name is constructed on the fly from the current date. + TODO It should be possible to supply a name and possibly + destination path on the command line. + + Paths are relative to the base directory (``$PWD``). + +--doc]]-- + +local loader_merge_name = "luaotfload-package.lua" +local loader_output_name = "luaotfload-package-merged.lua" +local loader_target_name = "fontloader-%s.lua" +local loader_orig_dir = "/src/fontloader/" +local loader_target_dir = "/build/" + ------------------------------------------------------------------------------- -- helpers ------------------------------------------------------------------------------- @@ -662,15 +688,16 @@ end local package = function (args) local t0 = osgettimeofday () local orig_dir = lfs.currentdir () - local base_dir = orig_dir .. "/src/fontloader/" - local merge_name = base_dir .. "luaotfload-package.lua" + local base_dir = orig_dir .. loader_orig_dir + local merge_name = base_dir .. loader_merge_name --- output name is fixed so we have to deal with it but maybe we can --- get a patch to mtx-package upstreamed in the future - local output_name = base_dir .. "luaotfload-package-merged.lua" - local target_name = stringformat ("fontloader-%s.lua", - os.date ("%F")) + local output_name = base_dir .. loader_output_name + local target_name = orig_dir .. loader_target_dir + .. stringformat (loader_target_name, os.date ("%F")) status ("assuming fontloader source in %s", base_dir) status ("reading merge instructions from %s", merge_name) + status ("mtx-package result at %s", output_name) status ("writing output to %s", target_name) --- check preconditions @@ -731,8 +758,16 @@ local package = function (args) --- at this point we know that mtxrun was invoked correctly and the --- result file has been created + local res, err = osrename (output_name, target_name) + + if res == nil then + die ("merge failed; failed to move package from %s to %s", + output_name, target_name) + end + status ("merge complete; operation finished in %.0f ms", (osgettimeofday() - t0) * 1000) + status ("a fresh fontloader at %s is ready to roll", target_name) end local help = function () -- cgit v1.2.3 From ff06e0639bd20b070e3fedef486c106ce6316086 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 Jul 2015 00:54:56 +0200 Subject: [import] batch create packaging paths in one place --- scripts/mkimport | 83 +++++++++++++++++++++++++++++++++----------------------- 1 file changed, 49 insertions(+), 34 deletions(-) (limited to 'scripts') diff --git a/scripts/mkimport b/scripts/mkimport index e393a7a..cd44450 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -667,6 +667,23 @@ local tell = function (arg) return describe (target, location) end +local build_paths = function (argv) + if not argv or type (argv) ~= "table" then die "build_paths" end + + local orig_dir = lfs.currentdir () + local base_dir = orig_dir .. loader_orig_dir + + local ret = { + orig_dir = orig_dir, + base_dir = base_dir, + merge_name = base_dir .. loader_merge_name, + target_name = orig_dir .. loader_target_dir + .. stringformat (loader_target_name, os.date ("%F")), + output_name = base_dir .. loader_output_name, + } + return ret +end + --[[doc-- Packaging works as follows: @@ -685,44 +702,40 @@ end --doc]]-- -local package = function (args) - local t0 = osgettimeofday () - local orig_dir = lfs.currentdir () - local base_dir = orig_dir .. loader_orig_dir - local merge_name = base_dir .. loader_merge_name - --- output name is fixed so we have to deal with it but maybe we can - --- get a patch to mtx-package upstreamed in the future - local output_name = base_dir .. loader_output_name - local target_name = orig_dir .. loader_target_dir - .. stringformat (loader_target_name, os.date ("%F")) - status ("assuming fontloader source in %s", base_dir) - status ("reading merge instructions from %s", merge_name) - status ("mtx-package result at %s", output_name) - status ("writing output to %s", target_name) +local package = function (argv) + local t0 = osgettimeofday () + local paths = build_paths (argv) + + status ("assuming fontloader source in %s", paths.base_dir) + status ("reading merge instructions from %s", paths.merge_name) + status ("mtx-package result at %s", paths.output_name) + status ("writing output to %s", paths.target_name) --- check preconditions - if not lfsisdir (base_dir) then die ("directory %s does not exist", emphasis (base_dir )) end - if not lfsisfile (merge_name) then die ("missing merge file at %s", emphasis (merge_name )) end - if not fileiswritable (output_name) then die ("cannot write to %s", emphasis (output_name)) end - if not fileiswritable (target_name) then die ("cannot write to %s", emphasis (target_name)) end - if not lfschdir (base_dir) then die ("failed to cd into %s", emphasis (base_dir )) end + if not lfsisdir (paths.base_dir) then die ("directory %s does not exist", emphasis (paths.base_dir )) end + if not lfsisfile (paths.merge_name) then die ("missing merge file at %s", emphasis (paths.merge_name )) end + if not fileiswritable (paths.output_name) then die ("cannot write to %s", emphasis (paths.output_name)) end + if not fileiswritable (paths.target_name) then die ("cannot write to %s", emphasis (paths.target_name)) end + if not lfschdir (paths.base_dir) then die ("failed to cd into %s", emphasis (paths.base_dir )) end - if lfsisfile (output_name) then - status ("output file already exists at “%s”, unlinking", output_name) - local ret, err = os.remove (output_name) + if lfsisfile (paths.output_name) then + status ("output file already exists at “%s”, unlinking", + paths.output_name) + local ret, err = os.remove (paths.output_name) if ret == nil then - if not lfschdir (orig_dir) then - status ("warning: failed to cd retour into %s", emphasis (orig_dir)) + if not lfschdir (paths.orig_dir) then + status ("warning: failed to cd retour into %s", + emphasis (paths.orig_dir)) end die ("failed to remove existing merge package") end end - --die ("missing merge file at %s", emphasis (merge_name )) end + --die ("missing merge file at %s", emphasis (paths.merge_name )) end --- perform merge - local cmd = { "mtxrun", "--script", "package", "--merge", merge_name } + local cmd = { "mtxrun", "--script", "package", "--merge", paths.merge_name } local shl = tableconcat (cmd, " ") status ("invoking %s as “%s”", emphasis "mtx-package", shl) @@ -730,8 +743,9 @@ local package = function (args) local fh = iopopen (shl, "r") if not fh then - if not lfschdir (orig_dir) then - status ("warning: failed to cd retour into %s", emphasis (orig_dir)) + if not lfschdir (paths.orig_dir) then + status ("warning: failed to cd retour into %s", + emphasis (paths.orig_dir)) end die ("merge failed; failed to invoke mtxrun") end @@ -747,27 +761,28 @@ local package = function (args) --- clean up - if not lfschdir (orig_dir) then - status ("warning: failed to cd retour into %s", emphasis (orig_dir)) + if not lfschdir (paths.orig_dir) then + status ("warning: failed to cd retour into %s", + emphasis (paths.orig_dir)) end --- check postconditions - if not lfsisfile (output_name) then die ("merge failed; package not found at " .. output_name) end + if not lfsisfile (paths.output_name) then die ("merge failed; package not found at " .. paths.output_name) end --- at this point we know that mtxrun was invoked correctly and the --- result file has been created - local res, err = osrename (output_name, target_name) + local res, err = osrename (paths.output_name, paths.target_name) if res == nil then die ("merge failed; failed to move package from %s to %s", - output_name, target_name) + paths.output_name, paths.target_name) end status ("merge complete; operation finished in %.0f ms", (osgettimeofday() - t0) * 1000) - status ("a fresh fontloader at %s is ready to roll", target_name) + status ("a fresh fontloader at %s is ready to roll", paths.target_name) end local help = function () -- cgit v1.2.3 From d6a31eacfaefe016d57c5caaf9ab5e12d3d50618 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 Jul 2015 01:20:29 +0200 Subject: [import] automate merge with parameters passed from makefile --- scripts/mkimport | 50 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'scripts') diff --git a/scripts/mkimport b/scripts/mkimport index cd44450..89c74e7 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -33,11 +33,13 @@ local os = require "os" require "lualibs" +local filedirname = file.dirname local fileiswritable = file.is_writable local ioloaddata = io.loaddata local iopopen = io.popen local iowrite = io.write local lfschdir = lfs.chdir +local lfscurrentdir = lfs.currentdir local lfsisdir = lfs.isdir local lfsisfile = lfs.isfile local md5sumhexa = md5.sumhexa @@ -670,16 +672,42 @@ end local build_paths = function (argv) if not argv or type (argv) ~= "table" then die "build_paths" end - local orig_dir = lfs.currentdir () - local base_dir = orig_dir .. loader_orig_dir + local orig_dir = lfscurrentdir () + local base_dir = orig_dir .. loader_orig_dir + local target_name = orig_dir .. loader_target_dir + .. stringformat (loader_target_name, os.date ("%F")) + local merge_name = base_dir .. loader_merge_name + local output_name = base_dir .. loader_output_name + + if #argv >= 2 then + local fname = argv[2] + local dir = filedirname (fname) .. "/" + if not lfsisdir (dir) then + die ("second argument must be point into existing directory, not “%s”", + argv[2]) + end + base_dir = dir + merge_name = fname + output_name = dir .. loader_output_name + end + + if #argv == 3 then + --- also set the target name + local fname = argv[3] + local dir = filedirname (fname) + if not lfsisdir (dir) then + die ("third argument must be point into writable directory, not “%s”", + argv[3]) + end + target_name = fname + end local ret = { orig_dir = orig_dir, base_dir = base_dir, - merge_name = base_dir .. loader_merge_name, - target_name = orig_dir .. loader_target_dir - .. stringformat (loader_target_name, os.date ("%F")), - output_name = base_dir .. loader_output_name, + merge_name = merge_name, + target_name = target_name, + output_name = output_name, } return ret end @@ -717,7 +745,7 @@ local package = function (argv) if not lfsisfile (paths.merge_name) then die ("missing merge file at %s", emphasis (paths.merge_name )) end if not fileiswritable (paths.output_name) then die ("cannot write to %s", emphasis (paths.output_name)) end if not fileiswritable (paths.target_name) then die ("cannot write to %s", emphasis (paths.target_name)) end - if not lfschdir (paths.base_dir) then die ("failed to cd into %s", emphasis (paths.base_dir )) end +---- not lfschdir (paths.base_dir) then die ("failed to cd into %s", emphasis (paths.base_dir )) end if lfsisfile (paths.output_name) then status ("output file already exists at “%s”, unlinking", @@ -768,11 +796,17 @@ local package = function (argv) --- check postconditions - if not lfsisfile (paths.output_name) then die ("merge failed; package not found at " .. paths.output_name) end + if not lfsisfile (paths.output_name) then + die ("merge failed; package not found at " .. paths.output_name) + end --- at this point we know that mtxrun was invoked correctly and the --- result file has been created + if lfsisfile (paths.target_name) then + status ("target file %s exists, overwriting", emphasis (paths.target_name)) + end + local res, err = osrename (paths.output_name, paths.target_name) if res == nil then -- cgit v1.2.3 From a42d7ef08ecacaef8e0429d80979c9943fd5d83e Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 Jul 2015 07:05:31 +0200 Subject: [import,fontloader] move imported package out of the way --- scripts/mkimport | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts') diff --git a/scripts/mkimport b/scripts/mkimport index 89c74e7..0833ccb 100755 --- a/scripts/mkimport +++ b/scripts/mkimport @@ -197,7 +197,7 @@ local imports = { { name = "fonts-ext" , ours = nil , kind = kind_merged }, { name = "fonts-inj" , ours = nil , kind = kind_merged }, { name = "fonts-lua" , ours = nil , kind = kind_merged }, - { name = "fonts-merged" , ours = "fontloader" , kind = kind_essential }, + { name = "fonts-merged" , ours = "reference" , kind = kind_essential }, { name = "fonts-ota" , ours = nil , kind = kind_merged }, { name = "fonts-otn" , ours = nil , kind = kind_merged }, { name = "fonts" , ours = nil , kind = kind_merged }, -- cgit v1.2.3 From c4ed163680db9a566b29f5f1d8b98a928f8055a0 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 Jul 2015 07:39:52 +0200 Subject: [status] allow passing additional files on command line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit During a build process, the name of a freshly created fontloader package will be passed to ``mkstatus`` so it’ll be considered in the status file. --- scripts/mkstatus | 49 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 5 deletions(-) (limited to 'scripts') diff --git a/scripts/mkstatus b/scripts/mkstatus index ba9cb06..9e10c03 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -55,7 +55,7 @@ local names = { { "src", "luaotfload-loaders.lua", }, { "src", "luaotfload-log.lua", }, { "src", "luaotfload-main.lua", }, - { "src/fontloader/runtime", "fontloader-fontloader.lua", }, + { "src/fontloader/runtime", "fontloader-reference.lua", }, --{ "src", "luaotfload-override.lua", }, --> part of init now { "src", "luaotfload-parsers.lua", }, { "src", "luaotfload-tool.lua", }, @@ -121,8 +121,9 @@ end local hash_all hash_all = function (list, acc) - if list == nil then - return hash_all (table.fastcopy (names), { }) + if acc == nil then + local base = table.fastcopy (names) + return hash_all (table.append (base, list), { }) end local finfo = list[#list] @@ -156,9 +157,47 @@ hash_all = function (list, acc) return acc end +local handle_argv = function (argv) + local argc = #argv + if argc < 1 then return { } end + local argoff = 1 + if argv [1] == "-v" then + verbose = true + if argc == 1 then return { } end + argoff = 2 + end + local aux aux = function (acc, i) + if i > argc then return acc else + local cur = argv[i] + if type (cur) == "string" and lfs.isfile (cur) then + acc[#acc + 1] = cur + else + die ("file not found: %s", tostring (cur)) + end + return aux (acc, i + 1) + end + end + return aux ({ }, argoff) +end + +local add_files +add_files = function (lst, acc) + if lst == nil then return end + if acc == nil then return add_files (lst, { }) end + local len = #lst + if len == 0 then return acc end + local cur = lst[len] + local fname = file.basename (cur) + local path = file.dirname (cur) + acc[#acc + 1] = { path, fname } + lst[len] = nil + return add_files (lst, acc) +end + local main = function () - if arg [1] == "-v" then verbose = true end - local hashes = hash_all () + local raw_extra = handle_argv (arg) + local cuit_extra = add_files (raw_extra) + local hashes = hash_all (cuit_extra) local notes = git_info () local serialized = table.serialize ({ notes = notes, hashes = hashes }, true) -- cgit v1.2.3 From 6eff203e9bf3348d090b6b5046466415bcd6530a Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Tue, 21 Jul 2015 08:11:21 +0200 Subject: [mkstatus,build,conf] default to packaged fontloader via status file This adds an entry ``loader`` on the ``notes`` hash in the status table by means of which the fontloader can be specified. The status file is read when building the configuration table, and if it is present the entry in the ``loader`` table will be used as the default fontloader. Otherwise, Luaotfload falls back on the reference loader. --- scripts/mkstatus | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) (limited to 'scripts') diff --git a/scripts/mkstatus b/scripts/mkstatus index 9e10c03..809d4af 100755 --- a/scripts/mkstatus +++ b/scripts/mkstatus @@ -26,6 +26,7 @@ local iosavedata = io.savedata local iopopen = io.popen local iowrite = io.write local lfsisdir = lfs.isdir +local stringmatch = string.match ----------------------------------------------------------------------- -- settings @@ -158,26 +159,35 @@ hash_all = function (list, acc) end local handle_argv = function (argv) + local ret = { files = { }, loader = nil } local argc = #argv - if argc < 1 then return { } end + if argc < 1 then return ret end local argoff = 1 if argv [1] == "-v" then verbose = true - if argc == 1 then return { } end + if argc == 1 then return ret end argoff = 2 end local aux aux = function (acc, i) if i > argc then return acc else local cur = argv[i] - if type (cur) == "string" and lfs.isfile (cur) then - acc[#acc + 1] = cur + if type (cur) == "string" then + local loader = stringmatch (cur, "--fontloader=(.+)$") + if loader then + cur = loader + acc.loader = file.basename (cur) + end + if lfs.isfile (cur) then + local files = acc.files + files[#files + 1] = cur + end else die ("file not found: %s", tostring (cur)) end return aux (acc, i + 1) end end - return aux ({ }, argoff) + return aux (ret, argoff) end local add_files @@ -196,9 +206,10 @@ end local main = function () local raw_extra = handle_argv (arg) - local cuit_extra = add_files (raw_extra) + local cuit_extra = add_files (raw_extra.files) local hashes = hash_all (cuit_extra) local notes = git_info () + notes.loader = raw_extra.loader local serialized = table.serialize ({ notes = notes, hashes = hashes }, true) local success = io.savedata (filelist, serialized) -- cgit v1.2.3