Skip to content

Commit

Permalink
Merge d74aba7 into dff4557
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Apr 26, 2023
2 parents dff4557 + d74aba7 commit f48a3c9
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 118 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -76,6 +76,7 @@ tags
Makefile-distfiles
documentation/*.pdf
gource.webm
*.rockspec
.fonts/*
.sources/*
/sile
Expand All @@ -87,6 +88,7 @@ sile.1
*.so
core/version.lua
core/features.lua
core/pathsetup.lua

# Nix symlink to builds
/result
1 change: 1 addition & 0 deletions .luacheckrc
Expand Up @@ -26,6 +26,7 @@ globals = {
"luautf8",
"pl",
"fluent",
"extendSilePath",
"SYSTEM_SILE_PATH",
"SHARED_LIB_EXT"
}
Expand Down
1 change: 1 addition & 0 deletions .luarc.json
Expand Up @@ -7,6 +7,7 @@
"luautf8",
"pl",
"fluent",
"extendSilePath",
"SYSTEM_SILE_PATH",
"SHARED_LIB_EXT"
],
Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Expand Up @@ -64,7 +64,7 @@ EXTRA_DIST += default.nix flake.nix flake.lock libtexpdf.git-rev shell.nix
EXTRA_DIST += package.json # imported by both Nix and Docker
EXTRA_DIST += $(MANUAL)

BUILT_SOURCES = .version core/features.lua core/version.lua Makefile-distfiles
BUILT_SOURCES = .version core/features.lua core/pathsetup.lua core/version.lua Makefile-distfiles

CLEANFILES = $(bin_SCRIPTS) $(dist_man_MANS) $(BUILT_SOURCES) $(DEPFILES) $(ACTUALS) $(TESTPDFS) $(MANUAL) $(_BUILT_SUBDIRS) .version-prev

Expand Down
6 changes: 5 additions & 1 deletion configure.ac
Expand Up @@ -245,11 +245,15 @@ adl_RECURSIVE_EVAL(["${libdir}/${TRANSFORMED_PACKAGE_NAME}"], [SILE_LIB_PATH])
AC_DEFINE_UNQUOTED([SILE_LIB_PATH],["${SILE_LIB_PATH}"],[Path for SILE libraries])
AC_SUBST([SILE_LIB_PATH])

AC_SUBST([ROCKSPECWARNING], ["DO NOT EDIT! Modify template sile.rockspec.in"])
AC_SUBST([ROCKREV], [1])

AX_SUBST_MAN_DATE

AC_CONFIG_FILES([build-aux/list-dist-files.sh], [chmod +x build-aux/list-dist-files.sh])
AC_CONFIG_FILES([Makefile src/Makefile sile.1 core/features.lua core/version.lua])
AC_CONFIG_FILES([Makefile src/Makefile sile.1 core/features.lua core/pathsetup.lua core/version.lua])
AC_CONFIG_FILES([sile tests/regressions.pl], [chmod +x sile tests/regressions.pl])
AC_CONFIG_FILES([sile-dev-1.rockspec:sile.rockspec.in])

AC_ARG_PROGRAM

Expand Down
5 changes: 0 additions & 5 deletions core/cli.lua
Expand Up @@ -47,11 +47,6 @@ cli.parseArguments = function ()
opts.INPUT = "-"
end
SILE.input.filename = opts.INPUT
-- Turn slashes around in the event we get passed a path from a Windows shell
local filename = opts.INPUT:gsub("\\", "/")
-- Strip extension
SILE.masterFilename = string.match(filename, "(.+)%..-$") or filename
SILE.masterDir = SILE.masterFilename:match("(.-)[^%/]+$")
end
if opts.backend then
SILE.backend = opts.backend
Expand Down
75 changes: 75 additions & 0 deletions core/pathsetup.lua.in
@@ -0,0 +1,75 @@
local executable = debug.getinfo(3, "S").source
local luaversion = _VERSION:match("%d+%.%d+")

-- Normalize possibly dirty Lua path formatting shortcut: /./ → /
-- Even leafo/gh-actions-luarocks takes this shortcut which inhibits duplicate cleanup
package.path = package.path:gsub("/%./", "/")
package.cpath = package.cpath:gsub("/%./", "/")

local function prepend_and_dedup (segment, path)
local escaped = segment:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1') -- copied from pl.utils.escape() which we can't load yet
local striped = path:gsub(("^%s"):format(escaped), ""):gsub((";%s"):format(escaped), "")
return ("%s;%s"):format(segment, striped)
end

local function prependPath (path)
package.path = prepend_and_dedup(path .. "/?/init.lua", package.path)
package.path = prepend_and_dedup(path .. "/?.lua", package.path)
end

local function prependCPath (path)
package.cpath = prepend_and_dedup(path .. "/?.@SHARED_LIB_EXT@", package.cpath)
end

local function extendPaths (path, ours)
prependCPath(path)
prependPath(path)
if ours then
prependPath(path .. "/lua-libraries")
if "@SYSTEM_LUAROCKS_FALSE@" == "" then -- see ./configure --with[out]-system-luarocks
prependCPath(path .. "/lua_modules/lib/lua/" .. luaversion)
prependPath(path .. "/lua_modules/share/lua/" .. luaversion)
end
else
prependCPath(path .. "/sile")
prependPath(path .. "/sile")
end
end

-- Facilitate loading SILE classes & packages from system LuaRocks
-- Also weed out CWD relative paths, we add them in a different order later
local luapath = {}
local extpath = {}
for path in package.path:gmatch("[^;]+") do
table.insert(extpath, tostring(path:gsub("%?", "sile/?")))
table.insert(luapath, path)
end
package.path = table.concat(luapath, ";")

extendPaths("@SILE_PATH@", true)
extendPaths("@SILE_LIB_PATH@", true)

package.path = table.concat(extpath, ";") .. ";" .. package.path

local pathvar = os.getenv("SILE_PATH")
if pathvar then
for path in string.gmatch(pathvar, "[^;]+") do
if not path:match("^./") and path:len() >= 1 then
extendPaths(path)
end
end
end

local cwd = executable:gsub("(.*)(/.*)", "%1")
if cwd:match("^@") then -- Consider "ours" for the sake of Nix Flake
extendPaths(".", true)
else
if cwd ~= "./" then extendPaths(cwd) end
extendPaths(".")
end

_G.extendSilePath = extendPaths

return function ()
return executable
end
14 changes: 13 additions & 1 deletion core/sile.lua
Expand Up @@ -306,6 +306,18 @@ function SILE.processFile (filename, format, options)
filename = "STDIN"
doc = io.stdin:read("*a")
else
-- Turn slashes around in the event we get passed a path from a Windows shell
filename = filename:gsub("\\", "/")
if not SILE.masterFilename then
-- Strip extension
SILE.masterFilename = string.match(filename, "(.+)%..-$") or filename
end
if SILE.masterFilename and not SILE.masterDir then
SILE.masterDir = SILE.masterFilename:match("(.-)[^%/]+$")
end
if SILE.masterDir and SILE.masterDir:len() >= 1 then
extendSilePath(SILE.masterDir)
end
filename = SILE.resolveFile(filename)
if not filename then
SU.error("Could not find file")
Expand Down Expand Up @@ -356,7 +368,7 @@ function SILE.resolveFile (filename, pathprefix)
candidates[#candidates+1] = "?"
-- Iterate through the directory of the master file, the SILE_PATH variable, and the current directory
-- Check for prefixed paths first, then the plain path in that fails
if SILE.masterFilename then
if SILE.masterDir then
for path in SU.gtoke(SILE.masterDir..";"..tostring(os.getenv("SILE_PATH")), ";") do
if path.string and path.string ~= "nil" then
if pathprefix then candidates[#candidates+1] = pl.path.join(path.string, pathprefix, "?") end
Expand Down
36 changes: 0 additions & 36 deletions sile-dev-1.rockspec

This file was deleted.

76 changes: 2 additions & 74 deletions sile.in
Expand Up @@ -4,75 +4,7 @@
SYSTEM_SILE_PATH = "@SILE_PATH@"
SHARED_LIB_EXT = "@SHARED_LIB_EXT@"

local executable = debug.getinfo(1, "S").source
local luaversion = _VERSION:match("%d+%.%d+")

-- Normalize possibly dirty Lua path formatting shortcut: /./ → /
-- Even leafo/gh-actions-luarocks takes this shortcut which inhibits duplicate cleanup
package.path = package.path:gsub("/%./", "/")
package.cpath = package.cpath:gsub("/%./", "/")

local function prepend_and_dedup (segment, path)
local escaped = segment:gsub('[%-%.%+%[%]%(%)%$%^%%%?%*]','%%%1') -- copied from pl.utils.escape() which we can't load yet
local striped = path:gsub(("^%s"):format(escaped), ""):gsub((";%s"):format(escaped), "")
return ("%s;%s"):format(segment, striped)
end

local function prependPath (path)
package.path = prepend_and_dedup(path .. "/?/init.lua", package.path)
package.path = prepend_and_dedup(path .. "/?.lua", package.path)
end

local function prependCPath (path)
package.cpath = prepend_and_dedup(path .. "/?.@SHARED_LIB_EXT@", package.cpath)
end

local function extendPaths (path, ours)
prependCPath(path)
prependPath(path)
if ours then
prependPath(path .. "/lua-libraries")
if "@SYSTEM_LUAROCKS_FALSE@" == "" then -- see ./configure --with[out]-system-luarocks
prependCPath(path .. "/lua_modules/lib/lua/" .. luaversion)
prependPath(path .. "/lua_modules/share/lua/" .. luaversion)
end
else
prependCPath(path .. "/sile")
prependPath(path .. "/sile")
end
end

-- Facilitate loading SILE classes & packages from system LuaRocks
-- Also weed out CWD relative paths, we add them in a different order later
local luapath = {}
local extpath = {}
for path in package.path:gmatch("[^;]+") do
table.insert(extpath, tostring(path:gsub("%?", "sile/?")))
table.insert(luapath, path)
end
package.path = table.concat(luapath, ";")

extendPaths("@SILE_PATH@", true)
extendPaths("@SILE_LIB_PATH@", true)

package.path = table.concat(extpath, ";") .. ";" .. package.path

local pathvar = os.getenv("SILE_PATH")
if pathvar then
for path in string.gmatch(pathvar, "[^;]+") do
if not path:match("^./") and path:len() >= 1 then
extendPaths(path)
end
end
end

local cwd = executable:gsub("(.*)(/.*)", "%1")
if cwd:match("^@") then -- Consider "ours" for the sake of Nix Flake
extendPaths(".", true)
else
if cwd ~= "./" then extendPaths(cwd) end
extendPaths(".")
end
local executable = require("core.pathsetup")()

-- This global is set here and *also* in the core library, since this
-- effectively passes the same table they are interchangeable (for now).
Expand All @@ -97,11 +29,7 @@ end

SILE.init()

if SILE.masterFilename then

if SILE.masterDir:len() >= 1 then
extendPaths(SILE.masterDir)
end
if SILE.input.filename and SILE.input.filename:len() > 0 then

if SU.debugging("profile") then
ProFi:start()
Expand Down
53 changes: 53 additions & 0 deletions sile.rockspec.in
@@ -0,0 +1,53 @@
-- @ROCKSPECWARNING@
rockspec_format = "3.0"
package = "@TRANSFORMED_PACKAGE_NAME@"
version = "dev-@ROCKREV@"

source = {
url = "git+https://github.com/sile-typesetter/sile.git",
branch = "master"
}

description = {
summary = "Simon’s Improved Layout Engine",
detailed = [[SILE is a typesetting system; its job is to produce beautiful printed documents.
Conceptually, SILE is similar to TeX—from which it borrows some concepts and even
syntax and algorithms—but the similarities end there. Rather than being a
derivative of the TeX family SILE is a new typesetting and layout engine written
from the ground up using modern technologies and borrowing some ideas from
graphical systems such as InDesign.]],
license = "MIT",
homepage = "https://github.com/sile-typesetter/fontproof",
issues_url = "https://github.com/sile-typesetter/fontproof/issues",
maintainer = "Caleb Maclennan <caleb@alerque.com>",
labels = { "typesetting" }
}

dependencies = {
"lua >= 5.1",
"bit32", -- only required on Lua < 5.2, versions vary between Rock and VM provided
"cassowary == 2.3.2-1",
"cldr == 0.3.0-0",
"compat53 == 0.8-1", -- only required on Lua < 5.3
"cosmo == 16.06.04-1",
"fluent == 0.2.0-0",
"linenoise == 0.9-1",
"loadkit == 1.1.0-1",
"lpeg == 1.0.2-1",
"lua-zlib == 1.2-2",
"lua_cliargs == 3.0-2",
"luaepnf == 0.3-2",
"luaexpat == 1.5.1-1",
"luafilesystem == 1.8.0-1",
"luarepl == 0.10-1",
"luasec == 1.3.1-1",
"luasocket == 3.1.0-1",
"luautf8 == 0.1.5-1",
"penlight == 1.13.1-1",
"vstruct == 2.1.1-1"
}

build = {
type = "builtin",
modules = {}
}

0 comments on commit f48a3c9

Please sign in to comment.