From 3fb891a12079a79a330fefdc1cbd9960e78c6ea4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Thu, 5 Dec 2024 23:47:50 +0300 Subject: [PATCH 01/11] fix(build): Remove obsolete workaround for macOS dependency paths --- configure.ac | 1 - 1 file changed, 1 deletion(-) diff --git a/configure.ac b/configure.ac index ac639e639..e5d74ea99 100644 --- a/configure.ac +++ b/configure.ac @@ -247,7 +247,6 @@ AC_SUBST([ICU_LIBS]) case $host_os in darwin*) - LUAROCKSARGS="EXPAT_DIR=/usr/local/opt/expat OPENSSL_DIR=/usr/local/opt/openssl ZLIB_DIR=/usr/local/opt/zlib" SHARED_LIB_EXT="so" ;; cygwin*|mingw*) From 2c5ea3e8ab62c81808c6a73bc83f39f4ced3cbd7 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 6 Dec 2024 01:02:49 +0300 Subject: [PATCH 02/11] fix(rusile): Adjust module loader to Darwin's shared module extension --- Makefile.am | 6 ++++-- configure.ac | 2 +- core/pathsetup.lua.in | 3 +++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Makefile.am b/Makefile.am index c43a302d8..e94bd7aa9 100644 --- a/Makefile.am +++ b/Makefile.am @@ -178,9 +178,11 @@ if FONT_VARIATIONS CARGO_FEATURE_ARGS += --features variations endif -rusile.so: $(rusile_so_SOURCES) $(bin_PROGRAMS) +@builddir@/target/@RUST_TARGET_SUBDIR@/librusile.$(SHARED_LIB_EXT): $(rusile_so_SOURCES) $(bin_PROGRAMS) $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile - $(INSTALL) @builddir@/target/@RUST_TARGET_SUBDIR@/lib$@ $@ + +rusile.so: @builddir@/target/@RUST_TARGET_SUBDIR@/librusile.$(SHARED_LIB_EXT) + $(INSTALL) $< $@ DEPDIR := .deps LOCALFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf diff --git a/configure.ac b/configure.ac index e5d74ea99..bcd429650 100644 --- a/configure.ac +++ b/configure.ac @@ -247,7 +247,7 @@ AC_SUBST([ICU_LIBS]) case $host_os in darwin*) - SHARED_LIB_EXT="so" + SHARED_LIB_EXT="dylib" ;; cygwin*|mingw*) SHARED_LIB_EXT="dll" diff --git a/core/pathsetup.lua.in b/core/pathsetup.lua.in index d7556f58d..3ad11b287 100644 --- a/core/pathsetup.lua.in +++ b/core/pathsetup.lua.in @@ -43,6 +43,9 @@ end -- Prepend paths specifically for C modules. local function prependCPath (path) package.cpath = prepend_and_dedup(path .. "/?.@SHARED_LIB_EXT@", package.cpath) + if "@SHARED_LIB_EXT@" ~= "so" then + package.cpath = prepend_and_dedup(path .. "/?.so", package.cpath) + end end -- Take a given path and iterate over permutations of paths that LuaRocks might have installed a rock to that are From c2194991de892deab86c070ae746ae7ee34bf051 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 6 Dec 2024 12:03:44 +0300 Subject: [PATCH 03/11] refactor(core): Move backend selector from top level to to inputs table The desired backend when using SILE as a library should now be set via SILE.input.backend instead of SILE.backend. This makes the namespace more consistend with other input parameters vs. the resulting loaded modules. This is technically a breaking change but will not be released in a major version because the compatibility shim is expected to cover this for the whole next major release cycle, so the breakage will only come in v0.17.0. --- core/cli.lua | 2 +- core/sile.lua | 18 +++++++++++------- inputters/lua_spec.lua | 2 +- inputters/sil_spec.lua | 2 +- inputters/xml_spec.lua | 2 +- packages/counters/counters_spec.lua | 2 +- spec/complex_frame_spec.lua | 2 +- spec/hyphenator_spec.lua | 2 +- spec/opentype_spec.lua | 2 +- spec/shaper_spec.lua | 2 +- src/lib.rs | 2 +- 11 files changed, 21 insertions(+), 17 deletions(-) diff --git a/core/cli.lua b/core/cli.lua index f5a2135d3..600d3bf0a 100644 --- a/core/cli.lua +++ b/core/cli.lua @@ -73,7 +73,7 @@ cli.parseArguments = function () SILE.input.filenames = opts.INPUTS end if opts.backend then - SILE.backend = opts.backend + SILE.input.backend = opts.backend end if opts.class then SILE.input.class = opts.class diff --git a/core/sile.lua b/core/sile.lua index 1192baf6a..4881b16f4 100644 --- a/core/sile.lua +++ b/core/sile.lua @@ -205,22 +205,26 @@ end -- -- Does not move on to processing input document(s). function SILE.init () - if not SILE.backend then - SILE.backend = "libtexpdf" + if SILE.backend then + SU.deprecated("SILE.backend", "SILE.input.backend", "0.15.7", "0.17.0") + SILE.input.backend = SILE.backend end - if SILE.backend == "libtexpdf" then + if not SILE.input.backend then + SILE.input.backend = "libtexpdf" + end + if SILE.input.backend == "libtexpdf" then SILE.shaper = SILE.shapers.harfbuzz() SILE.outputter = SILE.outputters.libtexpdf() - elseif SILE.backend == "cairo" then + elseif SILE.input.backend == "cairo" then SILE.shaper = SILE.shapers.pango() SILE.outputter = SILE.outputters.cairo() - elseif SILE.backend == "debug" then + elseif SILE.input.backend == "debug" then SILE.shaper = SILE.shapers.harfbuzz() SILE.outputter = SILE.outputters.debug() - elseif SILE.backend == "text" then + elseif SILE.input.backend == "text" then SILE.shaper = SILE.shapers.harfbuzz() SILE.outputter = SILE.outputters.text() - elseif SILE.backend == "dummy" then + elseif SILE.input.backend == "dummy" then SILE.shaper = SILE.shapers.harfbuzz() SILE.outputter = SILE.outputters.dummy() end diff --git a/inputters/lua_spec.lua b/inputters/lua_spec.lua index 2b9f2892d..588e512ff 100644 --- a/inputters/lua_spec.lua +++ b/inputters/lua_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "dummy" +SILE.input.backend = "dummy" SILE.init() SILE.utilities.error = error diff --git a/inputters/sil_spec.lua b/inputters/sil_spec.lua index 78fdf4785..69290a0f9 100644 --- a/inputters/sil_spec.lua +++ b/inputters/sil_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "dummy" +SILE.input.backend = "dummy" SILE.init() SILE.utilities.error = error diff --git a/inputters/xml_spec.lua b/inputters/xml_spec.lua index 3b2077e41..d983251a2 100644 --- a/inputters/xml_spec.lua +++ b/inputters/xml_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "dummy" +SILE.input.backend = "dummy" SILE.init() SILE.utilities.error = error diff --git a/packages/counters/counters_spec.lua b/packages/counters/counters_spec.lua index 74e53d65a..14d760829 100644 --- a/packages/counters/counters_spec.lua +++ b/packages/counters/counters_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "dummy" +SILE.input.backend = "dummy" SILE.init() SILE.utilities.error = error diff --git a/spec/complex_frame_spec.lua b/spec/complex_frame_spec.lua index b20db4af2..7bc2c00ac 100644 --- a/spec/complex_frame_spec.lua +++ b/spec/complex_frame_spec.lua @@ -1,6 +1,6 @@ SILE = require("core.sile") -SILE.backend = "dummy" +SILE.input.backend = "dummy" SILE.init() local base = require("classes.base") diff --git a/spec/hyphenator_spec.lua b/spec/hyphenator_spec.lua index 5daa07831..4363dc2d0 100644 --- a/spec/hyphenator_spec.lua +++ b/spec/hyphenator_spec.lua @@ -1,6 +1,6 @@ SILE = require("core.sile") -- Using French below requires the shaper to be initialized -SILE.backend = "debug" +SILE.input.backend = "debug" SILE.init() describe("Hyphenation module", function () diff --git a/spec/opentype_spec.lua b/spec/opentype_spec.lua index 82c4342ed..0cdeb29d8 100644 --- a/spec/opentype_spec.lua +++ b/spec/opentype_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "debug" +SILE.input.backend = "debug" SILE.forceFontManager = "fontconfig" SILE.init() diff --git a/spec/shaper_spec.lua b/spec/shaper_spec.lua index 3a548a2db..72f600f9e 100644 --- a/spec/shaper_spec.lua +++ b/spec/shaper_spec.lua @@ -1,5 +1,5 @@ SILE = require("core.sile") -SILE.backend = "debug" +SILE.input.backend = "debug" SILE.init() describe("SILE.shapers.base", function () diff --git a/src/lib.rs b/src/lib.rs index 00cf621be..e2606ddb8 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -133,7 +133,7 @@ pub fn run( sile_input.set("evaluateAfters", expressions)?; } if let Some(backend) = backend { - sile.set("backend", backend)?; + sile_input.set("backend", backend)?; } if let Some(fontmanager) = fontmanager { sile.set("fontmanager", fontmanager)?; From d2fb48a063753fc7621d785236e154bf22812865 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 6 Dec 2024 12:07:24 +0300 Subject: [PATCH 04/11] fix(cli): Correctly pass through font manager preference from Rust CLI Previously only working properly from the Lua CLI. --- core/cli.lua | 2 +- core/fontmanager.lua | 4 ++-- spec/opentype_spec.lua | 2 +- src/lib.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/cli.lua b/core/cli.lua index 600d3bf0a..d9dbced06 100644 --- a/core/cli.lua +++ b/core/cli.lua @@ -90,7 +90,7 @@ cli.parseArguments = function () table.insert(SILE.input.evaluateAfters, statement) end if opts.fontmanager then - SILE.forceFontManager = opts.fontmanager + SILE.input.fontmanager = opts.fontmanager end if opts.makedeps then SILE.makeDeps = require("core.makedeps") diff --git a/core/fontmanager.lua b/core/fontmanager.lua index 44792dc97..a5a1caa4d 100644 --- a/core/fontmanager.lua +++ b/core/fontmanager.lua @@ -6,8 +6,8 @@ end) fontManager.face = function (self, ...) local manager - if SILE.forceFontManager then - manager = self[SILE.forceFontManager] + if SILE.input.fontmanager then + manager = self[SILE.input.fontmanager] else manager = self.macfonts and self.macfonts or self.fontconfig end diff --git a/spec/opentype_spec.lua b/spec/opentype_spec.lua index 0cdeb29d8..fcf183d5e 100644 --- a/spec/opentype_spec.lua +++ b/spec/opentype_spec.lua @@ -1,6 +1,6 @@ SILE = require("core.sile") SILE.input.backend = "debug" -SILE.forceFontManager = "fontconfig" +SILE.input.fontmanager = "fontconfig" SILE.init() -- These tests depend on loading specific fonts from our test fixtures. Running diff --git a/src/lib.rs b/src/lib.rs index e2606ddb8..6bf4b8195 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -136,7 +136,7 @@ pub fn run( sile_input.set("backend", backend)?; } if let Some(fontmanager) = fontmanager { - sile.set("fontmanager", fontmanager)?; + sile_input.set("fontmanager", fontmanager)?; } if let Some(class) = class { sile_input.set("class", class)?; From 4b6aa5ed00747ea22932547770aca62c8add28a4 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 6 Dec 2024 13:45:13 +0300 Subject: [PATCH 05/11] feat(fonts): Configure macOS to fallback from macfonts to fontconfig --- core/fontmanager.lua | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/core/fontmanager.lua b/core/fontmanager.lua index a5a1caa4d..b541e6dd4 100644 --- a/core/fontmanager.lua +++ b/core/fontmanager.lua @@ -1,20 +1,36 @@ local fontManager = {} + fontManager.fontconfig = require("justenoughfontconfig") -pcall(function () - fontManager.macfonts = require("macfonts") -end) + +local has_macfonts, macfonts = pcall(require, "macfonts") +if has_macfonts and macfonts then + fontManager.macfonts = macfonts +end + +local function create_macfonts_fallback (self) + return function (...) + SU.debug("fonts", "Checking via macfonts") + local status, result = pcall(self.macfonts._face, ...) + if status and result and result.filename then + SU.debug("fonts", "Found, returning result") + return result + else + SU.debug("fonts", "Not found, trying fontconfig instead") + return self.fontconfig._face(...) + end + end +end fontManager.face = function (self, ...) - local manager + local face if SILE.input.fontmanager then - manager = self[SILE.input.fontmanager] + face = self[SILE.input.fontmanager]._face + elseif has_macfonts then + face = create_macfonts_fallback(self) else - manager = self.macfonts and self.macfonts or self.fontconfig - end - if not manager then - SU.error("Failed to load any working font manager") + face = self.fontconfig._face end - return manager._face(...) + return face(...) end return fontManager From 851978d1237bb477f6be9764dc0fd882691cf8f3 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Fri, 6 Dec 2024 14:07:42 +0300 Subject: [PATCH 06/11] test(fonts): Add test for font manager fallback --- spec/fontmanager_spec.lua | 54 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 spec/fontmanager_spec.lua diff --git a/spec/fontmanager_spec.lua b/spec/fontmanager_spec.lua new file mode 100644 index 000000000..e6b822afb --- /dev/null +++ b/spec/fontmanager_spec.lua @@ -0,0 +1,54 @@ +SILE = require("core.sile") +SILE.input.backend = "debug" +SILE.init() + +-- These tests depend on loading specific fonts from our test fixtures. Running +-- plain `busted` is sometimes useful (e.g. for IDEs) but will not support this +-- test because fontconfig hasn't been preloaded with the font paths it would +-- need. If that's the case, just skip even defining these tests and call it +-- good. To test a complete set of tests use `make busted`. +local fcf = os.getenv("FONTCONFIG_FILE") +if not fcf then + return +end + +describe("The fontconfig manager", function () + SILE.input.fontmanager = "fontconfig" + + it("should load a font", function () + local family = "Libertinus Serif" + local face = SILE.shaper.getFace({ family = family }) + assert.is.equal(family, face.family) + end) + + it("should fallback when it can't find", function () + local family = "Yesteryear Imagination" + local face + assert.has_no.errors(function () + face = SILE.shaper.getFace({ family = family }) + end) + assert.is_not.equal(family, face.family) + end) +end) + +describe("The macfonts manager", function () + + if not SILE.fontManager.macfonts then + return + end + + it("should load a font", function () + local family = "Libertinus Serif" + local face = SILE.shaper.getFace({ family = family }) + assert.is.equal(family, face.family) + end) + + it("should fallback to fontconfig when it fails", function () + local family = "Yesteryear Imagination" + local face + assert.has_no.errors(function () + face = SILE.shaper.getFace({ family = family }) + end) + assert.is_not.equal(family, face.family) + end) +end) From 625ea694f3f209704ae3b75096de894e2e33d4bf Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 7 Dec 2024 02:21:52 +0300 Subject: [PATCH 07/11] fix(build): Set module build flags needed for darwin shared libraries --- Makefile.am | 2 +- build-aux/module.rs | 3 +++ rusile/Cargo.toml | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 build-aux/module.rs diff --git a/Makefile.am b/Makefile.am index e94bd7aa9..87f0a367f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,7 @@ endif $(MANUAL): $(FIGURES) BUILT_SOURCES_LUA = core/features.lua core/pathsetup.lua core/version.lua -RUSILE_SOURCES = rusile/Cargo.toml rusile/src/lib.rs +RUSILE_SOURCES = rusile/Cargo.toml rusile/src/lib.rs build-aux/module.rs bin_PROGRAMS = sile bin_SCRIPTS = sile-lua diff --git a/build-aux/module.rs b/build-aux/module.rs new file mode 100644 index 000000000..e10b0cdcd --- /dev/null +++ b/build-aux/module.rs @@ -0,0 +1,3 @@ +fn main() { + println!("cargo:rustc-link-arg=-Wl,-undefined,dynamic_lookup"); +} diff --git a/rusile/Cargo.toml b/rusile/Cargo.toml index dbe411618..3f108ec59 100644 --- a/rusile/Cargo.toml +++ b/rusile/Cargo.toml @@ -9,6 +9,7 @@ authors.workspace = true homepage.workspace = true repository.workspace = true license.workspace = true +build = "../build-aux/module.rs" [lib] crate-type = ["rlib", "cdylib", "staticlib"] From af78813d2cc07c333ce3272f768bb036c36faccc Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 7 Dec 2024 02:46:43 +0300 Subject: [PATCH 08/11] refactor(build): Extract Rust module build rules to macro --- Makefile.am | 13 ++----------- build-aux/que_rust_boilerplate.m4 | 11 +++++++++++ build-aux/que_rust_module.am | 8 ++++++++ configure.ac | 30 +++++++++++++++++------------- 4 files changed, 38 insertions(+), 24 deletions(-) create mode 100644 build-aux/que_rust_module.am diff --git a/Makefile.am b/Makefile.am index 87f0a367f..19ba5b72f 100644 --- a/Makefile.am +++ b/Makefile.am @@ -56,7 +56,6 @@ endif $(MANUAL): $(FIGURES) BUILT_SOURCES_LUA = core/features.lua core/pathsetup.lua core/version.lua -RUSILE_SOURCES = rusile/Cargo.toml rusile/src/lib.rs build-aux/module.rs bin_PROGRAMS = sile bin_SCRIPTS = sile-lua @@ -67,8 +66,6 @@ EXTRA_sile_SOURCES = if !EMBEDDED_RESOURCES nobase_dist_pkgdata_DATA = $(SILEDATA) $(LUALIBRARIES) nobase_nodist_pkgdata_DATA = $(BUILT_SOURCES_LUA) $(LUAMODULES) -pkglib_LIBRARIES = rusile.so -rusile_so_SOURCES = $(RUSILE_SOURCES) endif !EMBEDDED_RESOURCES dist_doc_DATA = README.md CHANGELOG.md dist_pdf_DATA = $(_MANUAL) @@ -137,7 +134,7 @@ $(CARGO_BIN): justenough/.libs/justenoughlibtexpdf.a $(CARGO_BIN): justenough/.libs/svg.a $(CARGO_BIN): libtexpdf/.libs/libtexpdf.a if !EMBEDDED_RESOURCES -$(CARGO_BIN): rusile.so +$(CARGO_BIN): rusile.$(SHARED_LIB_EXT) endif !EMBEDDED_RESOURCES src/embed-includes.rs: Makefile-distfiles @@ -164,7 +161,7 @@ else MLUAVER = lua$(LUA_SHORT_VERSION) endif CARGO_FEATURE_ARGS = --features $(MLUAVER) -RUSILE_FEATURE_ARG = --features $(MLUAVER) +rusile_FEATURE_ARGS = --features $(MLUAVER) if !SYSTEM_LUA_SOURCES CARGO_FEATURE_ARGS += --features vendored @@ -178,12 +175,6 @@ if FONT_VARIATIONS CARGO_FEATURE_ARGS += --features variations endif -@builddir@/target/@RUST_TARGET_SUBDIR@/librusile.$(SHARED_LIB_EXT): $(rusile_so_SOURCES) $(bin_PROGRAMS) - $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(RUSILE_FEATURE_ARG) $(CARGO_RELEASE_ARGS) -p rusile - -rusile.so: @builddir@/target/@RUST_TARGET_SUBDIR@/librusile.$(SHARED_LIB_EXT) - $(INSTALL) $< $@ - DEPDIR := .deps LOCALFONTS := FONTCONFIG_FILE=$(PWD)/fontconfig.conf LOCALPATHS := SILE_PATH="$(PWD);libtexpdf/.libs;justenough/.libs" diff --git a/build-aux/que_rust_boilerplate.m4 b/build-aux/que_rust_boilerplate.m4 index bc3d5ffaf..050afbf4e 100644 --- a/build-aux/que_rust_boilerplate.m4 +++ b/build-aux/que_rust_boilerplate.m4 @@ -44,3 +44,14 @@ $($SED -E "s/@PACKAGE_VAR@/$PACKAGE_VAR/g;s/@PACKAGE_NAME@/$PACKAGE_NAME/g" buil ])dnl ]) + +AC_DEFUN([QUE_RUST_MODULE], [ + + AC_REQUIRE([AX_AM_MACROS]) + AX_ADD_AM_MACRO([dnl +EXTRA_DIST += build-aux/que_rust_module.am + +$($SED -E "s/@MODULE@/$1/g;s/@SHARED_LIB_EXT@/$SHARED_LIB_EXT/g" build-aux/que_rust_module.am) +])dnl + +]) diff --git a/build-aux/que_rust_module.am b/build-aux/que_rust_module.am new file mode 100644 index 000000000..708b6a12b --- /dev/null +++ b/build-aux/que_rust_module.am @@ -0,0 +1,8 @@ +pkglib_LIBRARIES = @MODULE@.@SHARED_LIB_EXT@ +@MODULE@_@SHARED_LIB_EXT@_SOURCES = @MODULE@/Cargo.toml @MODULE@/src/lib.rs build-aux/module.rs + +@builddir@/target/@RUST_TARGET_SUBDIR@/lib@MODULE@.@SHARED_LIB_EXT@: $(@MODULE@_@SHARED_LIB_EXT@_SOURCES) + $(CARGO_ENV) $(CARGO) build $(CARGO_VERBOSE) --target $(CARGO_TARGET_TRIPLE) $(@MODULE@_FEATURE_ARGS) $(CARGO_RELEASE_ARGS) -p @MODULE@ + +@MODULE@.@SHARED_LIB_EXT@: @builddir@/target/@RUST_TARGET_SUBDIR@/lib@MODULE@.@SHARED_LIB_EXT@ + $(INSTALL) $< $@ diff --git a/configure.ac b/configure.ac index bcd429650..03701b5c4 100644 --- a/configure.ac +++ b/configure.ac @@ -11,6 +11,23 @@ QUE_TRANSFORM_PACKAGE_NAME QUE_DEVELOPER_MODE QUE_DIST_CHECKSUMS +AC_CANONICAL_HOST + +# Load Rust module bits, early since it stuffs rules in aminclude.am +case $host_os in + darwin*) + SHARED_LIB_EXT="dylib" + ;; + cygwin*|mingw*) + SHARED_LIB_EXT="dll" + ;; + *) + SHARED_LIB_EXT="so" + ;; +esac +AC_SUBST([SHARED_LIB_EXT]) +QUE_RUST_MODULE([rusile]) + # Extend the QUE checksums feature with support for the PDF manual SILE_DIST_CHECKSUMS @@ -244,19 +261,6 @@ AC_SUBST([HARFBUZZ_SUBSET_LIBS]) AC_SUBST([ICU_TRUE]) AC_SUBST([ICU_CFLAGS]) AC_SUBST([ICU_LIBS]) - -case $host_os in - darwin*) - SHARED_LIB_EXT="dylib" - ;; - cygwin*|mingw*) - SHARED_LIB_EXT="dll" - ;; - *) - SHARED_LIB_EXT="so" - ;; -esac -AC_SUBST([SHARED_LIB_EXT]) AC_SUBST([LUAROCKSARGS]) # Avoid need for `--datarootdir=$(cd ..; pwd)` hack to run locally for From e039df171d40fd6d9c08926f53d9894c27b35504 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Mon, 30 Sep 2024 17:35:41 +0300 Subject: [PATCH 09/11] ci(actions): Setup test build on macOS runner --- .github/workflows/build.yml | 62 +++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 04a1a9f79..18c941fef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -131,6 +131,68 @@ jobs: run: | make docker-test-dist + build-macos: + name: Build macOS + runs-on: macos-latest + env: + CFLAGS: "-I/opt/homebrew/include/luajit-2.1 -I/opt/homebrew/include" + OBJCFLAGS: "-I/opt/homebrew/include/luajit-2.1 -I/opt/homebrew/include" + LDFLAGS: "-L/opt/homebrew/lib" + DOCKER: false + LDOC: false + NIX: false + SHA256SUM: false + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + - name: Cache test fonts + uses: actions/cache@v4 + with: + path: | + .fonts + .sources + key: fonts-${{ hashFiles('Makefile-fonts') }} + - name: Cache lua_modules + uses: actions/cache@v4 + with: + path: | + lua_modules + key: luarocks-${{ hashFiles('Makefile-luarocks', 'sile.rockspec.in') }} + - name: Install system dependencies + run: | + brew install \ + autoconf \ + automake \ + expat \ + ghostscript \ + graphviz \ + libtool \ + luajit \ + luarocks \ + poppler \ + rust \ + unzip \ + zlib + brew link icu4c@76 --force + brew link zlib --force + brew link expat --force + brew install --cask font-gentium-plus + - name: Configure + run: | + ./bootstrap.sh + ./configure \ + --enable-developer-mode \ + --without-developer-tools \ + --with-system-lua-sources \ + --with-manual + echo "VERSION=$(./build-aux/git-version-gen .tarball-version)" >> $GITHUB_ENV + echo "MAKEFLAGS=-j$(sysctl -n hw.ncpu) -Otarget" >> $GITHUB_ENV + - name: Make + run: | + make + build-nix: runs-on: ubuntu-22.04 name: Build Nix From 3c3cae2f94bf46cda0d1f1d8cd92c27ee74c8f71 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sat, 7 Dec 2024 18:28:09 +0300 Subject: [PATCH 10/11] chore(build): Use target os not host for platform specific options --- configure.ac | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/configure.ac b/configure.ac index 03701b5c4..bd55b7a09 100644 --- a/configure.ac +++ b/configure.ac @@ -2,6 +2,7 @@ AC_PREREQ([2.69]) AC_INIT([sile], [m4_esyscmd(build-aux/git-version-gen .tarball-version)], [caleb@alerque.com]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_MACRO_DIR([build-aux]) +AC_CANONICAL_TARGET AM_INIT_AUTOMAKE([foreign tar-pax dist-zstd dist-zip no-dist-gzip color-tests subdir-objects]) AM_SILENT_RULES([yes]) @@ -11,23 +12,6 @@ QUE_TRANSFORM_PACKAGE_NAME QUE_DEVELOPER_MODE QUE_DIST_CHECKSUMS -AC_CANONICAL_HOST - -# Load Rust module bits, early since it stuffs rules in aminclude.am -case $host_os in - darwin*) - SHARED_LIB_EXT="dylib" - ;; - cygwin*|mingw*) - SHARED_LIB_EXT="dll" - ;; - *) - SHARED_LIB_EXT="so" - ;; -esac -AC_SUBST([SHARED_LIB_EXT]) -QUE_RUST_MODULE([rusile]) - # Extend the QUE checksums feature with support for the PDF manual SILE_DIST_CHECKSUMS @@ -54,11 +38,24 @@ RANLIB=: LT_PREREQ([2.2]) LT_INIT([dlopen]) -AC_CANONICAL_HOST - QUE_RUST_BOILERPLATE QUE_DOCKER_BOILERPLATE +# Load Rust module bits, early since it stuffs rules in aminclude.am +case $target_os in + darwin*) + SHARED_LIB_EXT="dylib" + ;; + cygwin*|mingw*) + SHARED_LIB_EXT="dll" + ;; + *) + SHARED_LIB_EXT="so" + ;; +esac +AC_SUBST([SHARED_LIB_EXT]) +QUE_RUST_MODULE([rusile]) + AM_CONDITIONAL([SHARED], [test "x$enable_shared" = "xyes"]) AM_CONDITIONAL([STATIC], [test "x$enable_static" = "xyes"]) @@ -128,7 +125,7 @@ AM_COND_IF([MANUAL], [ AC_MSG_CHECKING([for OS X]) have_appkit=no -case $host_os in +case $target_os in darwin*) AC_MSG_RESULT([yes]) AC_MSG_CHECKING([for AppKit works]) From db87128202ba71aad6181df98168a9da0277b113 Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Sun, 8 Dec 2024 01:43:41 +0300 Subject: [PATCH 11/11] ci(actions): Avoid parallel build bugs in Homebrew's make --- .github/workflows/build.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 18c941fef..d4f5c7b4e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -188,7 +188,8 @@ jobs: --with-system-lua-sources \ --with-manual echo "VERSION=$(./build-aux/git-version-gen .tarball-version)" >> $GITHUB_ENV - echo "MAKEFLAGS=-j$(sysctl -n hw.ncpu) -Otarget" >> $GITHUB_ENV + # Note don't use -Otarget for macOS, Homebrew's old make is too buggy + echo "MAKEFLAGS=-j$(sysctl -n hw.ncpu)" >> $GITHUB_ENV - name: Make run: | make