Skip to content

Commit

Permalink
Merge branch 'mlua-v010' into cargo-workspace-inplace
Browse files Browse the repository at this point in the history
  • Loading branch information
alerque committed Oct 2, 2024
2 parents c0c9b9f + b9716f0 commit 3e50b28
Show file tree
Hide file tree
Showing 37 changed files with 1,061 additions and 1,011 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,18 @@ jobs:
run: |
make dist
- name: Upload source dist artifact
if: ${{ matrix.configuration[0] == 'dynamic' && !contains(github.ref, 'refs/tags/v') }}
if: matrix.configuration[0] == 'dynamic' && !startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: sile-${{ env.VERSION }}
path: sile-${{ env.VERSION }}.zip
- name: Append architecture to static binary
if: ${{ matrix.configuration[0] == 'static' }}
if: matrix.configuration[0] == 'static'
run: |
cp sile sile-${{ env.CARCH }}
sha256sum sile-${{ env.CARCH }} | tee -a sile-${{ env.VERSION }}.sha256.txt
- name: Upload static binary artifact
if: ${{ matrix.configuration[0] == 'static' && !contains(github.ref, 'refs/tags/v') }}
if: matrix.configuration[0] == 'static' && !startsWith(github.ref, 'refs/tags/v')
uses: actions/upload-artifact@v4
with:
name: sile-${{ env.CARCH }}
Expand Down Expand Up @@ -124,7 +124,7 @@ jobs:
run: |
make fake-manual
make distdir
- name: Build from package
- name: Build from dist tree
run: |
make docker-test-dist
Expand All @@ -144,9 +144,9 @@ jobs:
.sources
key: fonts-${{ hashFiles('Makefile-fonts') }}
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
uses: DeterminateSystems/nix-installer-action@v14
- name: Cache Nix dependencies
uses: DeterminateSystems/magic-nix-cache-action@v7
uses: DeterminateSystems/magic-nix-cache-action@v8
- name: Setup developer environment
run: |
nix develop --command ./bootstrap.sh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ jobs:
with:
fetch-depth: 0
- name: Install Nix
uses: DeterminateSystems/nix-installer-action@v13
uses: DeterminateSystems/nix-installer-action@v14
- name: Cache Nix dependencies
uses: DeterminateSystems/magic-nix-cache-action@v7
uses: DeterminateSystems/magic-nix-cache-action@v8
# Upstream package sometimes has flags set that disable flake checking
- name: Setup test env
run: |
Expand Down
22 changes: 11 additions & 11 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ zsh = [ "completions" ]
[profile.release]
lto = true

[workspace.dependencies.mlua]
version = "0.10.0-beta.2"

[dependencies.anyhow]
version = "1.0"

Expand All @@ -116,7 +119,7 @@ optional = true
features = [ "derive", "string", "wrap_help" ]

[dependencies.mlua]
version = "0.9"
workspace = true
features = [ "macros" ]

# [dependencies.rusile]
Expand Down
76 changes: 53 additions & 23 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,19 @@

ARG ARCHTAG

FROM docker.io/library/archlinux:base-devel$ARCHTAG AS builder
FROM docker.io/library/archlinux:$ARCHTAG AS base

# Initialize keys so we can do package management
RUN pacman-key --init && pacman-key --populate

# This hack can convince Docker its cache is obsolete; e.g. when the contents
# of downloaded resources have changed since being fetched. It's helpful to have
# this as a separate layer because it saves time for local builds. Incrementing
# this when pushing dependency updates to Caleb's Arch user repository or just
# when the remote Docker Hub builds die should be enough.
ARG DOCKER_HUB_CACHE=1

ARG RUNTIME_DEPS
ARG BUILD_DEPS

# Enable system locales for everything we have localizations for so tools like
# `date` will output matching localized strings. By default Arch Docker images
Expand All @@ -14,60 +23,70 @@ ARG BUILD_DEPS
RUN sed -i -e '/^NoExtract.*locale/d' /etc/pacman.conf

# Freshen all base system packages
RUN pacman-key --init
RUN pacman --needed --noconfirm -Syq archlinux-keyring
RUN pacman --needed --noconfirm -Suq
RUN pacman --needed --noconfirm -Syuq && yes | pacman -Sccq

# Make sure *at least* glibc actually got reinstalled after enabling
# extraaction of locale files even if the version was fresh so we can use the
# extraction of locale files even if the version was fresh so we can use the
# locale support out of it later.
RUN pacman --noconfirm -Sq glibc && yes | pacman -Sccq

# Install run-time dependencies
RUN pacman --needed --noconfirm -Sq $RUNTIME_DEPS $BUILD_DEPS
RUN pacman --needed --noconfirm -Sq $RUNTIME_DEPS && yes | pacman -Sccq

# Setup LuaRocks for use with LuaJIT roughly matching SILE's internal VM
RUN luarocks config lua_version 5.1 && \
luarocks config lua_interpreter luajit && \
luarocks config variables.LUA "$(command -v luajit)" && \
luarocks config variables.LUA_INCDIR /usr/include/luajit-2.1/

# Setup separate image for build so we don’t bloat the final image
FROM base AS builder

ARG BUILD_DEPS

# Install build time dependencies
RUN pacman --needed --noconfirm -Sq $BUILD_DEPS && yes | pacman -Sccq

# Set at build time, forces Docker’s layer caching to reset at this point
ARG REVISION

COPY ./ /src
WORKDIR /src

# Rebuild locale database after having added our supported locales.
# Take note of SILE's supported locales so the final system can build localized messages
RUN ls i18n/ | sed 's/[.-].*$/_/;s/^/^/' | sort -u | grep -Ef - /usr/share/i18n/SUPPORTED > /etc/locale.gen
RUN locale-gen

# GitHub Actions builder stopped providing git history :(
# See feature request at https://github.com/actions/runner/issues/767
RUN build-aux/docker-bootstrap.sh

# Use clang and mold instead of gcc and ld for speed
ENV RUSTFLAGS="-C linker=clang -C link-arg=-fuse-ld=mold"

RUN ./bootstrap.sh
RUN ./configure --with-system-lua-sources --without-manual
RUN ./configure \
--disable-embeded-resources \
--with-system-lua-sources \
--without-system-luarocks \
--without-manual
RUN make
RUN make install DESTDIR=/pkgdir

# Work around BuiltKit / buildx bug, they can’t copy to symlinks only dirs
RUN mv /pkgdir/usr/local/{share/,}/man

FROM docker.io/library/archlinux:base$ARCHTAG AS final
FROM base AS final

# Same args as above, repeated because they went out of scope with FROM
ARG RUNTIME_DEPS
ARG VERSION
ARG REVISION
ARG VERSION

# Allow `su` with no root password so non-priv users can install dependencies
RUN sed -i -e '/.so$/s/$/ nullok/' /etc/pam.d/su

# Set system locale to something other than 'C' that resolves to a real language
ENV LANG=en_US.UTF-8

# Freshen all base system packages (and cleanup cache)
RUN pacman-key --init
RUN pacman --needed --noconfirm -Syq archlinux-keyring && yes | pacman -Sccq
RUN pacman --needed --noconfirm -Suq && yes | pacman -Sccq

# Install run-time dependencies
RUN pacman --needed --noconfirm -Sq $RUNTIME_DEPS && yes | pacman -Sccq
# Rebuild locale database so system apps have localized messages for SILE's supported locales
COPY --from=builder /etc/locale.gen /etc
RUN locale-gen

LABEL org.opencontainers.image.title="SILE"
LABEL org.opencontainers.image.description="A containerized version of the SILE typesetter"
Expand All @@ -80,8 +99,19 @@ LABEL org.opencontainers.image.revision="$REVISION"

COPY build-aux/docker-fontconfig.conf /etc/fonts/conf.d/99-docker.conf

# Inform the system Lua manifest where SILE's vendored modules are so they are
# available to 3rd party packages even outside of SILE's runtime. Most notably
# useful so that luarocks can find them as existing dependencies when
# installing 3rd party modules. We replace the user tree instead of inserting
# a new one because it doesn't make sense in Docker anyway and the default
# priority works out better having it first.
RUN luarocks config rocks_trees[1].root /usr/local/share/sile/lua_modules && \
luarocks config rocks_trees[1].name sile && \
luarocks config deps_mode all

COPY --from=builder /pkgdir /
COPY --from=builder /src/src/sile-entry.sh /usr/local/bin

RUN sile --version

WORKDIR /data
Expand Down
8 changes: 4 additions & 4 deletions Makefile-fonts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ if FONT_DOWNLOAD_TOOLS
[ -h .sources ] || mkdir -p $@

fonttooling:
$(if $(BSDTAR),,$(error Please set BSDTAR with path or `./configure --enable-developer`))
$(if $(CURL),,$(error Please set CURL with path or `./configure --enable-developer`))
$(if $(BSDTAR),,$(error Please set BSDTAR with path or `./configure --enable-developer-mode`))
$(if $(CURL),,$(error Please set CURL with path or `./configure --enable-developer-mode`))

# Don't let make delete things we had to download
.PRECIOUS: .fonts/% .sources/%
Expand Down Expand Up @@ -101,7 +101,7 @@ notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')
.sources/LateefGR-1.200.zip: | .sources
$(CURL) -fsSL https://software.sil.org/downloads/r/lateef/$(notdir $@) -o $@

.sources/Libertinus-%.tar.xz: | .sources
.sources/Libertinus-%.tar.zst: | .sources
$(CURL) -fsSL https://github.com/alerque/libertinus/releases/download/v$*/$(notdir $@) -o $@

.sources/roboto-unhinted.zip: | .sources
Expand Down Expand Up @@ -138,7 +138,7 @@ notobase = $(shell echo $(notdir $1) | sed -e 's/-.*//')
$(BSDTAR) -x -f $< -C $(dir $@) $(notdir $@) && \
touch $@

.fonts/Libertinus%: .sources/Libertinus-7.020.tar.xz | .fonts
.fonts/Libertinus%: .sources/Libertinus-7.050.tar.zst | .fonts
$(BSDTAR) -x -f $< -C $(dir $@) --strip-components 3 $(basename $(basename $(<F)))/static/OTF/$(notdir $@) && \
touch $@

Expand Down
2 changes: 1 addition & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,6 @@ gource.webm:
else !DEVELOPER_MODE

$(PHONY_DEVELOPER_TARGETS):
@: $(error "Please reconfigure using --enable-developer to use developer tooling")
@: $(error "Please reconfigure using --enable-developer-mode to use developer tooling")

endif !DEVELOPER_MODE
2 changes: 1 addition & 1 deletion core/pathsetup.lua.in
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ local function extendPaths (path, silesourcedir)
prependPath(path .. "/sile")
end
-- These paths are *only* used in developer mode for build testing
if "@DEVELOPER_FALSE@" ~= "" then -- see ./configure --(en|dis)able-developer
if "@DEVELOPER_MODE_TRUE@" == "" then -- see ./configure --(en|dis)able-developer-mode
prependCPath(path .. "/libtexpdf/.libs")
prependCPath(path .. "/justenough/.libs")
end
Expand Down
6 changes: 3 additions & 3 deletions hooks/build
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env sh
set -e

: "${ARCHTAG:=}"
: "${ARCHTAG:=latest}"
: "${DOCKERFILE:=Dockerfile}"

REVISION=$(git describe --long --tags | sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g')

RUNTIME_DEPS='fontconfig freetype2 gentium-plus-font glibc harfbuzz icu libpng luajit zlib'\
' libertinus-font luarocks noto-fonts-cjk ttf-hack'
BUILD_DEPS='cargo git jq lua51 poppler'
' otf-libertinus luarocks noto-fonts-cjk ttf-hack'
BUILD_DEPS='base-devel cargo clang git jq mold poppler'

: "${DOCKER_BUILDKIT:=1}"
export DOCKER_BUILDKIT
Expand Down
4 changes: 2 additions & 2 deletions outputters/text.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@ function outputter:setCursor (x, y, relative)
if newy - cursorY > bs then
outfile:write("\n")
else
outfile:write("")
outfile:write("\u{202b}")
end
elseif newx > cursorX then
if newx:tonumber() - cursorX:tonumber() > spc then
outfile:write(" ")
else
outfile:write("")
outfile:write("\u{202b}")
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion rusile/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ luajit = [ "mlua/luajit" ]
vendored = [ "mlua/vendored" ]

[dependencies.mlua]
version = "0.9"
workspace = true
features = [ "macros", "module" ]
11 changes: 8 additions & 3 deletions sile-lua.1.in
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,14 @@
.B [\fIoptions\fR]
.B [\fIINPUT\fR]
.SH DESCRIPTION
The SILE typesetter reads an input file(s), by default in either SIL or XML format, and processes them to generate an output file, by default in PDF format.
The output will be written to a file with the same name as the first input file with the extension changed to .pdf unless the \fB\-\-output\fR argument is used.
Additional input or output formats can be handled by loading a module with the \fB\-\-use\fR argument to add support for them first.
The SILE Typesetter reads input file(s) and typesets the content into a rendered documument format, typically PDF.
.LP
By default, input files may be in declarative SIL markup, structured XML, or programatic Lua.
The input format is automatically detected by the active modules.
By default, the output will be a file with the same name as the first input file with the extension changed to .pdf.
The output filename can be overridden with the \fB\-\-output\fR argument.
Using \fB\-\-backend\fR one can change to a different output format (or a different driver for the same format).
Additional input or output formats can be handled by loading a 3rd party module that supports them by adding \fB\-\-use\fR argument on the command line (which will load prior to attempting to read input documents).
.SH OPTIONS
.TP
.BR \-b ", " \-\-backend= \fIvalue\fR
Expand Down
2 changes: 1 addition & 1 deletion spec/opentype_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@ describe("The OpenType loader/parser", function ()

it("should convert Microsoft-platform name strings to UTF8", function ()
local version = font.names[5]["en-US"][1]
assert.is.equal("Version 7.020;RELEASE", version)
assert.is.equal("Version 7.050;RELEASE", version)
end)
end)
Loading

0 comments on commit 3e50b28

Please sign in to comment.