rebase to 1.24.0 (rhbz#2270341)

- support more formats (office xml, text, gzipped)
- `mutool bake` command
- redaction options for line art and images
- Art, Bleed, Media, and Trim boxes for PDF page sizes
- various fixes and improvements

In addition, all patches are upstreamed!
This commit is contained in:
Michael J Gruber 2024-03-19 21:25:23 +01:00
parent 7fd9be4f47
commit 3997f669ec
16 changed files with 6 additions and 1355 deletions

1
.gitignore vendored
View File

@ -42,3 +42,4 @@
/mupdf-1.23.8-source.tar.gz /mupdf-1.23.8-source.tar.gz
/mupdf-1.23.9-source.tar.gz /mupdf-1.23.9-source.tar.gz
/mupdf-1.23.10-source.tar.gz /mupdf-1.23.10-source.tar.gz
/mupdf-1.24.0-source.tar.gz

View File

@ -1,28 +0,0 @@
From e25787685ab0283bcda7ec275e35d694e4e239cf Mon Sep 17 00:00:00 2001
Message-ID: <e25787685ab0283bcda7ec275e35d694e4e239cf.1710842983.git.mjg@fedoraproject.org>
From: Tom Stellard <tstellar@redhat.com>
Date: Mon, 18 Mar 2024 23:13:46 +0000
Subject: [PATCH] Fix build with llvm18
MJG: deal with both llvm17 and llvm18 cursor kinds
---
scripts/wrap/parse.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/scripts/wrap/parse.py b/scripts/wrap/parse.py
index c6df24dae..a96f4964a 100644
--- a/scripts/wrap/parse.py
+++ b/scripts/wrap/parse.py
@@ -70,7 +70,8 @@ def get_children(cursor):
for cursor in cursor.get_children():
#verbose = state.state_.show_details( cursor.spelling)
#verbose = 1
- if cursor.kind == clang.cindex.CursorKind.UNEXPOSED_DECL:
+ if ((cursor.kind == clang.cindex.CursorKind.UNEXPOSED_DECL)
+ or (cursor.kind == clang.cindex.CursorKind.LINKAGE_SPEC)):
# Things tagged with `extern "C" appear to be within this
# cursor.
for cursor2 in cursor.get_children():
--
2.44.0.413.g3b59069256

View File

@ -1,152 +0,0 @@
From 1932a672db047da3204a445880007fcc522fa7d7 Mon Sep 17 00:00:00 2001
Message-ID: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Wed, 13 Sep 2023 14:11:47 +0100
Subject: [PATCH 01/11] Makerules scripts/wrap/__main__.py: fix for Pyodide
shared library builds.
We need to use environment's $CC (as set in Pyodide venv), not emcc.
Also, Pyodide builds are now indicated by $OS='pyodide'; previously we used
$OS='wasm' && $PYODIDE_ROOT!=''.
(cherry picked from commit 5b111feae295e52fd25bd7bcaabb5c5a3ea8687e)
---
Makerules | 28 ++++++++++++++++++++--------
scripts/wrap/__main__.py | 26 ++++++++++++++++----------
2 files changed, 36 insertions(+), 18 deletions(-)
diff --git a/Makerules b/Makerules
index f25a8ce0b..916e8581a 100644
--- a/Makerules
+++ b/Makerules
@@ -80,6 +80,14 @@ ifeq ($(shared),yes)
else ifeq ($(OS),wasm-mt)
LIB_LDFLAGS = -shared -sSIDE_MODULE
EXE_LDFLAGS = -sMAIN_MODULE
+ else ifeq ($(OS),pyodide)
+ LIB_LDFLAGS = -shared -sSIDE_MODULE
+ EXE_LDFLAGS = -sMAIN_MODULE
+
+ # Pyodide's ld does not support -b so we cannot use it to create object
+ # files containing font data, so leave HAVE_OBJCOPY unset. And we need
+ # extra memory when linking.
+ LDFLAGS += -sTOTAL_MEMORY=48MB
else
LIB_LDFLAGS = -shared
endif
@@ -181,14 +189,7 @@ else ifeq ($(OS),MACOS)
endif
else ifeq ($(OS),Linux)
- ifeq ($(PYODIDE_ROOT),)
- HAVE_OBJCOPY := yes
- else
- # Pyodide's ld does not support -b so we cannot use it to create object
- # files containing font data, so leave HAVE_OBJCOPY unset. And we need
- # extra memory when linking.
- LDFLAGS += -sTOTAL_MEMORY=48MB
- endif
+ HAVE_OBJCOPY := yes
ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes)
SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
@@ -297,6 +298,17 @@ ifeq "$(OS)" "wasm-mt"
CFLAGS += -pthread
endif
+ifeq "$(OS)" "pyodide"
+ build_prefix += $(OS)/
+ # We use the provided $CC and $CXX.
+ AR = emar
+ HAVE_GLUT=no
+ HAVE_X11=no
+ HAVE_OBJCOPY=no
+ HAVE_LIBCRYPTO=no
+ CFLAGS += -pthread
+endif
+
ifeq "$(OS)" "mingw32-cross"
build_prefix += $(OS)/
SO := dll
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index a543a689c..9ae753a72 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -1207,12 +1207,12 @@ def _get_m_command( build_dirs, j=None):
build_prefix = ''
in_prefix = True
for i, flag in enumerate( flags):
- if flag in ('x32', 'x64') or flag.startswith('py'):
+ if flag in ('x32', 'x64') or re.match('py[0-9]', flag):
# setup.py puts cpu and python version
# elements into the build directory name
# when creating wheels; we need to ignore
# them.
- pass
+ jlib.log('Ignoring {flag=}')
else:
if 0: pass # lgtm [py/unreachable-statement]
elif flag == 'debug':
@@ -1438,8 +1438,8 @@ def build_0(
def link_l_flags(sos):
ld_origin = None
- if os.environ.get('OS') in ('wasm', 'wasm-mt'):
- # Don't add '-Wl,-rpath*' etc if building for wasm.
+ if os.environ.get('OS') == 'pyodide':
+ # Don't add '-Wl,-rpath*' etc if building for Pyodide.
ld_origin = False
return jlib.link_l_flags( sos, ld_origin)
@@ -1472,8 +1472,13 @@ def build( build_dirs, swig_command, args, vs_upgrade):
header_git = False
j = 0
refcheck_if = '#ifndef NDEBUG'
- wasm = os.environ.get('OS') in ('wasm', 'wasm-mt')
- if wasm:
+ pyodide = (os.environ.get('OS') == 'pyodide')
+ if pyodide:
+ # Looks like Pyodide sets CXX to (for example) /tmp/tmp8h1meqsj/c++.
+ # But for some reason using `compiler = os.environ['CXX']` fails when we
+ # build libmupdfcpp.so, with:
+ # emsdk/upstream/bin/llvm-nm: error: a.out: No such file or directory
+ # But using `em++` directly seems to work.
compiler = 'em++'
elif state.state_.macos:
compiler = 'c++ -std=c++14'
@@ -1626,7 +1631,7 @@ def build( build_dirs, swig_command, args, vs_upgrade):
f'''
{compiler}
-o {os.path.relpath(libmupdfcpp)}
- {"-sSIDE_MODULE" if wasm else ""}
+ {"-sSIDE_MODULE" if pyodide else ""}
{build_dirs.cpp_flags}
-fPIC -shared
-I {include1}
@@ -1884,10 +1889,11 @@ def build( build_dirs, swig_command, args, vs_upgrade):
# todo: maybe instead use sysconfig.get_config_vars() ?
#
- if os.environ.get('PYODIDE_ROOT'):
+ if os.environ.get('OS') == 'pyodide':
+ assert os.environ.get('PYODIDE_ROOT') is not None
_include_dir = os.environ[ 'PYO3_CROSS_INCLUDE_DIR']
_lib_dir = os.environ[ 'PYO3_CROSS_LIB_DIR']
- jlib.log( 'PYODIDE_ROOT set. {_include_dir=} {_lib_dir=}')
+ jlib.log( 'OS is Pyodide. {_include_dir=} {_lib_dir=}')
flags_compile = f'-I {_include_dir}'
flags_link = f'-L {_lib_dir}'
@@ -2007,7 +2013,7 @@ def build( build_dirs, swig_command, args, vs_upgrade):
f'''
{compiler}
-o {os.path.relpath(out_so)}
- {"-sMAIN_MODULE" if wasm else ""}
+ {"-sMAIN_MODULE" if pyodide else ""}
{cpp_path}
{build_dirs.cpp_flags}
-fPIC
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,59 +0,0 @@
From 06ea458607d54015c39ae42cf6417361e5c4c9f9 Mon Sep 17 00:00:00 2001
Message-ID: <06ea458607d54015c39ae42cf6417361e5c4c9f9.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Tue, 5 Sep 2023 08:43:51 +0100
Subject: [PATCH 02/11] Makefile: add version numbers and installation targets
for shared libraries.
* Installation targets install-shared-* build+install C/C++/Python/C# bindings.
* On non-MacOS we append .FZ_VERSION_MINOR.FZ_VERSION_PATCH to shared
libraries.
* On Linux we create links such as libmupdf.so -> libmupdf.so.23.1 (not
required on OpenBSD).
For install-shared-* targets we require that USE_SYSTEM_LIBS=yes, otherwise we
fail with a diagnostic.
We install Python mupdf.py and _mupdf.so into location from Python's
sysconfig.get_path('platlib').
In existing calls of ./scripts/mupdfwrap.py:
* Add `--venv` so that we automatically get libclang and swig.
* Use `-d $(OUT)` so we use the right build directory, e.g. if $(build_prefix)
is set.
$(OUT) is only set correctly (i.e. contains `shared-`) if Make was run with
`shared=yes`. So if $(shared) is not 'yes', rules for shared library targets
that use $(OUT) rerun make with shared=yes.
(cherry picked from commit f32df6f6ebc7ff20224de3350914bb89a5417c54)
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index f8a8dfaa9..55fda4854 100644
--- a/Makefile
+++ b/Makefile
@@ -621,14 +621,14 @@ install-shared-c: install-shared-check shared install-headers
install -d $(DESTDIR)$(libdir)
install -m 644 $(OUT)/libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
- ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
+ ln -s libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
endif
install-shared-c++: install-shared-c c++
install -m 644 platform/c++/include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
install -m 644 $(OUT)/libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
- ln -sf libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdfcpp.$(SO)
+ ln -s libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdfcpp.$(SO)
endif
install-shared-python: install-shared-c++ python
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,284 +0,0 @@
From 10de118bdef0325c9b7bc25e03045ecd91be97ec Mon Sep 17 00:00:00 2001
Message-ID: <10de118bdef0325c9b7bc25e03045ecd91be97ec.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Wed, 13 Sep 2023 22:51:36 +0100
Subject: [PATCH 03/11] scripts/: Create shared libraries with version numbers.
(We don't include version numbers on MacOS.)
scripts/wrap/__main__.py:
Create .so's with version numbers.
Allow specification of make command. We use $MUPDF_MAKE if specified
instead of 'make'. Also added `--make <make-command>` option.
macos_patch(): fix to cope with so_name.
Create softlinks such as libmupdfcpp.so -> libmupdfcpp.so.23.0. (Not on
OpenBSD, which does not require them.)
scripts/jlib.py:link_l_flags():
Also accept .so's with version suffix.
(cherry picked from commit ca530e79f55fd9759d044bd73c1f6a1427b60ca7)
---
scripts/jlib.py | 6 ++-
scripts/wrap/__main__.py | 97 ++++++++++++++++++++++++++++++----------
2 files changed, 77 insertions(+), 26 deletions(-)
diff --git a/scripts/jlib.py b/scripts/jlib.py
index a6ded32f7..3df501b3e 100644
--- a/scripts/jlib.py
+++ b/scripts/jlib.py
@@ -2243,9 +2243,11 @@ def link_l_flags( sos, ld_origin=None):
dir_ = os.path.dirname( so)
name = os.path.basename( so)
assert name.startswith( 'lib'), f'name={name}'
- if name.endswith( '.so'):
+ m = re.search( '(.so[.0-9]*)$', name)
+ if m:
+ l = len(m.group(1))
dirs.add( dir_)
- names.append( f'-l {name[3:-3]}')
+ names.append( f'-l {name[3:-l]}')
elif darwin and name.endswith( '.dylib'):
dirs.add( dir_)
names.append( f'-l {name[3:-6]}')
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index 9ae753a72..fdb61c7a4 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -789,6 +789,11 @@ Usage:
Also see '--sync-docs' option for copying these generated
documentation files elsewhere.
+ --make <make-command>
+ Override make command, e.g. `--make gmake`.
+ If not specified, we use $MUPDF_MAKE. If this is not set, we use
+ `make` (or `gmake` on OpenBSD).
+
--ref
Copy generated C++ files to mupdfwrap_ref/ directory for use by --diff.
@@ -1178,7 +1183,30 @@ def _test_get_m_command():
jlib.log( '_get_m_command() ok')
-def _get_m_command( build_dirs, j=None):
+def get_so_version( build_dirs):
+ '''
+ Returns `.<minor>.<patch>` from include/mupdf/fitz/version.h.
+
+ Returns '' on macos.
+ '''
+ if state.state_.macos:
+ return ''
+ d = dict()
+ def get_v( name):
+ path = f'{build_dirs.dir_mupdf}/include/mupdf/fitz/version.h'
+ with open( path) as f:
+ for line in f:
+ m = re.match(f'^#define {name} (.+)\n$', line)
+ if m:
+ return m.group(1)
+ assert 0, f'Cannot find #define of {name=} in {path=}.'
+ major = get_v('FZ_VERSION_MAJOR')
+ minor = get_v('FZ_VERSION_MINOR')
+ patch = get_v('FZ_VERSION_PATCH')
+ return f'.{minor}.{patch}'
+
+
+def _get_m_command( build_dirs, j=None, make=None):
'''
Generates a `make` command for building with `build_dirs.dir_mupdf`.
@@ -1186,13 +1214,18 @@ def _get_m_command( build_dirs, j=None):
'''
assert not state.state_.windows, 'Cannot do "-b m" on Windows; C library is integrated into C++ library built by "-b 01"'
#jlib.log( '{build_dirs.dir_mupdf=}')
- make = 'make'
- if state.state_.openbsd:
- # Need to run gmake, not make. Also for some
- # reason gmake on OpenBSD sets CC to clang, but
- # CXX to g++, so need to force CXX=clang++ too.
- #
- make = 'CXX=clang++ gmake'
+ if not make:
+ make = os.environ.get('MUPDF_MAKE')
+ jlib.log('Overriding from $MUPDF_MAKE={make}.')
+ if not make:
+ if state.state_.openbsd:
+ # Need to run gmake, not make. Also for some
+ # reason gmake on OpenBSD sets CC to clang, but
+ # CXX to g++, so need to force CXX=clang++ too.
+ #
+ make = 'CXX=clang++ gmake'
+ if not make:
+ make = 'make'
if j is not None:
if j == 0:
@@ -1314,6 +1347,7 @@ def macos_patch( library, *sublibraries):
jlib.log( f'macos_patch(): library={library} sublibraries={sublibraries}')
if not state.state_.macos:
return
+ # Find what shared libraries are used by `library`.
jlib.system( f'otool -L {library}', out='log')
command = 'install_name_tool'
names = []
@@ -1322,7 +1356,13 @@ def macos_patch( library, *sublibraries):
name = name.split('\n')
assert len(name) == 2 and name[0] == f'{sublibrary}:', f'{name=}'
name = name[1]
- command += f' -change {name} @rpath/{os.path.basename(name)}'
+ # strip trailing so_name.
+ leaf = os.path.basename(name)
+ m = re.match('^(.+[.]((so)|(dylib)))[0-9.]*$', leaf)
+ assert m
+ jlib.log(f'Changing {leaf=} to {m.group(1)}')
+ leaf = m.group(1)
+ command += f' -change {name} @rpath/{leaf}'
command += f' {library}'
jlib.system( command, out='log')
jlib.system( f'otool -L {library}', out='log')
@@ -1444,7 +1484,7 @@ def link_l_flags(sos):
return jlib.link_l_flags( sos, ld_origin)
-def build( build_dirs, swig_command, args, vs_upgrade):
+def build( build_dirs, swig_command, args, vs_upgrade, make_command):
'''
Handles -b ...
'''
@@ -1549,6 +1589,7 @@ def build( build_dirs, swig_command, args, vs_upgrade):
dir_so_flags = os.path.basename( build_dirs.dir_so).split( '-')
windows_build_type = build_dirs.windows_build_type()
+ so_version = get_so_version( build_dirs)
for action in actions:
with jlib.LogPrefixScope( f'{action}: '):
@@ -1563,9 +1604,12 @@ def build( build_dirs, swig_command, args, vs_upgrade):
jlib.log( 'Ignoring `-b m` on Windows as not required.')
else:
jlib.log( 'Building libmupdf.so ...')
- command, actual_build_dir, suffix = _get_m_command( build_dirs, j)
+ command, actual_build_dir, suffix = _get_m_command( build_dirs, j, make_command)
jlib.system( command, prefix=jlib.log_text(), out='log', verbose=1)
+ suffix2 = '.dylib' if state.state_.macos else '.so'
+ assert os.path.isfile(f'{actual_build_dir}/libmupdf{suffix2}{so_version}')
+
if actual_build_dir != build_dirs.dir_so:
# This happens when we are being run by
# setup.py - it it might specify '-d
@@ -1575,7 +1619,6 @@ def build( build_dirs, swig_command, args, vs_upgrade):
# build/shared-release/libmupdf.so, so we need
# to copy into build/shared-release-x64-py3.8/.
#
- suffix2 = '.dylib' if state.state_.macos else '.so'
jlib.fs_copy( f'{actual_build_dir}/libmupdf{suffix2}', f'{build_dirs.dir_so}/libmupdf{suffix2}', verbose=1)
elif action == '0':
@@ -1625,8 +1668,8 @@ def build( build_dirs, swig_command, args, vs_upgrade):
for i in cpp_files:
cpp_files_text += ' ' + os.path.relpath(i)
if 'shared' in dir_so_flags:
- libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so'
- libmupdf = f'{build_dirs.dir_so}/libmupdf.so'
+ libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}'
+ libmupdf = f'{build_dirs.dir_so}/libmupdf.so{so_version}'
command = ( textwrap.dedent(
f'''
{compiler}
@@ -1646,7 +1689,9 @@ def build( build_dirs, swig_command, args, vs_upgrade):
command,
force_rebuild,
)
- macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib')
+ macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib{so_version}')
+ if so_version:
+ jlib.system(f'ln -sf libmupdfcpp.so{so_version} {build_dirs.dir_so}/libmupdfcpp.so')
elif 'fpic' in dir_so_flags:
# We build a .so containing the C and C++ API. This
@@ -1920,9 +1965,9 @@ def build( build_dirs, swig_command, args, vs_upgrade):
dir_so_flags = os.path.basename( build_dirs.dir_so).split( '-')
if 'shared' in dir_so_flags:
- libmupdf = f'{build_dirs.dir_so}/libmupdf.so'
+ libmupdf = f'{build_dirs.dir_so}/libmupdf.so{so_version}'
libmupdfthird = f''
- libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so'
+ libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}'
elif 'fpic' in dir_so_flags:
libmupdf = f'{build_dirs.dir_so}/libmupdf.a'
libmupdfthird = f'{build_dirs.dir_so}/libmupdf-third.a'
@@ -1935,7 +1980,7 @@ def build( build_dirs, swig_command, args, vs_upgrade):
out_so = f'{build_dirs.dir_so}/_mupdf.so'
elif build_csharp:
cpp_path = f'{build_dirs.dir_mupdf}/platform/csharp/mupdfcpp_swig.cpp'
- out_so = f'{build_dirs.dir_so}/mupdfcsharp.so'
+ out_so = f'{build_dirs.dir_so}/mupdfcsharp.so' # todo: append {so_version} ?
if state.state_.openbsd:
# clang needs around 2G on OpenBSD.
@@ -2006,9 +2051,9 @@ def build( build_dirs, swig_command, args, vs_upgrade):
# module) using the same underlying C library.
#
sos = []
- sos.append( f'{build_dirs.dir_so}/libmupdfcpp.so')
+ sos.append( f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}')
if os.path.basename( build_dirs.dir_so).startswith( 'shared-'):
- sos.append( f'{build_dirs.dir_so}/libmupdf.so')
+ sos.append( f'{build_dirs.dir_so}/libmupdf.so{so_version}')
command = ( textwrap.dedent(
f'''
{compiler}
@@ -2043,8 +2088,8 @@ def build( build_dirs, swig_command, args, vs_upgrade):
force_rebuild,
)
macos_patch( out_so,
- f'{build_dirs.dir_so}/libmupdf.dylib',
- f'{build_dirs.dir_so}/libmupdfcpp.so',
+ f'{build_dirs.dir_so}/libmupdf.dylib{so_version}',
+ f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}',
)
else:
raise Exception( 'unrecognised --build action %r' % action)
@@ -2288,9 +2333,10 @@ def main2():
#
build_dirs = state.BuildDirs()
- # Set default swig.
+ # Set default swig and make.
#
swig_command = 'swig'
+ make_command = None
# Whether to use `devenv.com /upgrade`.
#
@@ -2313,7 +2359,7 @@ def main2():
print( __doc__)
elif arg == '--build' or arg == '-b':
- build( build_dirs, swig_command, args, vs_upgrade)
+ build( build_dirs, swig_command, args, vs_upgrade, make_command)
elif arg == '--check-headers':
keep_going = False
@@ -2394,6 +2440,9 @@ def main2():
languages = args.next()
make_docs( build_dirs, languages)
+ elif arg == '--make':
+ make_command = args.next()
+
elif arg == '--ref':
assert 'mupdfwrap_ref' in build_dirs.ref_dir
jlib.system(
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,67 +0,0 @@
From 95a8976c7d0d55a88caec62f5f5d37ac69806f03 Mon Sep 17 00:00:00 2001
Message-ID: <95a8976c7d0d55a88caec62f5f5d37ac69806f03.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Thu, 14 Sep 2023 18:57:42 +0100
Subject: [PATCH 04/11] Makerules: fixes for shared shared library installs on
OpenBSD.
We need to use the same pkg-config calls as Linux.
(cherry picked from commit fbf12be21348aa2ea8977a61d1dac1fcf04c36ed)
---
Makerules | 23 +++++++++++++++++++----
1 file changed, 19 insertions(+), 4 deletions(-)
diff --git a/Makerules b/Makerules
index 916e8581a..49c04f009 100644
--- a/Makerules
+++ b/Makerules
@@ -162,6 +162,13 @@ ifneq "$(CLUSTER)" ""
CFLAGS += -DCLUSTER
endif
+ifeq ($(OS),Linux)
+ LINUX_OR_OPENBSD := yes
+endif
+ifeq ($(OS),OpenBSD)
+ LINUX_OR_OPENBSD := yes
+endif
+
ifeq ($(OS),MINGW)
WINDRES := windres
HAVE_WIN32 := yes
@@ -188,8 +195,11 @@ else ifeq ($(OS),MACOS)
endif
endif
-else ifeq ($(OS),Linux)
- HAVE_OBJCOPY := yes
+else ifeq ($(LINUX_OR_OPENBSD),yes)
+
+ ifeq ($(OS),Linux)
+ HAVE_OBJCOPY := yes
+ endif
ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes)
SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
@@ -240,8 +250,13 @@ else ifeq ($(OS),Linux)
HAVE_GLUT := yes
ifeq ($(HAVE_GLUT),yes)
- SYS_GLUT_CFLAGS :=
- SYS_GLUT_LIBS := -lglut -lGL
+ ifeq ($(OS),OpenBSD)
+ SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut gl)
+ SYS_GLUT_LIBS := $(shell pkg-config --libs glut gl)
+ else
+ SYS_GLUT_CFLAGS :=
+ SYS_GLUT_LIBS := -lglut -lGL
+ endif
endif
HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,243 +0,0 @@
From 7afd21cc1aadee98cb05665900130477effb88b1 Mon Sep 17 00:00:00 2001
Message-ID: <7afd21cc1aadee98cb05665900130477effb88b1.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Thu, 19 Oct 2023 12:38:50 +0100
Subject: [PATCH 05/11] scripts/wrap/__main__.py: fix Pyodide builds of shared
libraries.
We now use '$CXX', not 'em++', with separate compilation and linking to avoid
error:
emsdk/upstream/bin/llvm-nm: error: a.out: No such file or directory
(cherry picked from commit 161f9757f16bd5b6a685e7cd2d3a10d478be8863)
---
scripts/wrap/__main__.py | 192 +++++++++++++++++++++++++++++----------
1 file changed, 146 insertions(+), 46 deletions(-)
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index fdb61c7a4..3000685a1 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -1514,12 +1514,11 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
refcheck_if = '#ifndef NDEBUG'
pyodide = (os.environ.get('OS') == 'pyodide')
if pyodide:
- # Looks like Pyodide sets CXX to (for example) /tmp/tmp8h1meqsj/c++.
- # But for some reason using `compiler = os.environ['CXX']` fails when we
- # build libmupdfcpp.so, with:
- # emsdk/upstream/bin/llvm-nm: error: a.out: No such file or directory
- # But using `em++` directly seems to work.
- compiler = 'em++'
+ # Looks like Pyodide sets CXX to (for example) /tmp/tmp8h1meqsj/c++. We
+ # don't evaluate it here, because that would force a rebuild each time
+ # because of the command changing.
+ assert os.environ.get('CXX', None), 'Pyodide build but $CXX not defined.'
+ compiler = '$CXX'
elif state.state_.macos:
compiler = 'c++ -std=c++14'
# Add extra flags for MacOS cross-compilation, where ARCHFLAGS can be
@@ -1667,14 +1666,58 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
cpp_files_text = ''
for i in cpp_files:
cpp_files_text += ' ' + os.path.relpath(i)
- if 'shared' in dir_so_flags:
- libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}'
- libmupdf = f'{build_dirs.dir_so}/libmupdf.so{so_version}'
+ libmupdfcpp = f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}'
+ libmupdf = f'{build_dirs.dir_so}/libmupdf.so{so_version}'
+ if pyodide:
+ # Compile/link separately. Otherwise
+ # emsdk/upstream/bin/llvm-nm: error: a.out: No such
+ # file or directory
+ o_files = list()
+ for cpp_file in cpp_files:
+ o_file = f'{os.path.relpath(cpp_file)}.o'
+ o_files.append(o_file)
+ command = textwrap.dedent(
+ f'''
+ {compiler}
+ -c
+ -o {o_file}
+ {build_dirs.cpp_flags}
+ -fPIC
+ -I {include1}
+ -I {include2}
+ {cpp_file}
+ ''').strip().replace( '\n', ' \\\n')
+ jlib.build(
+ [include1, include2, cpp_file],
+ o_file,
+ command,
+ force_rebuild,
+ )
+ command = ( textwrap.dedent(
+ f'''
+ {compiler}
+ -o {os.path.relpath(libmupdfcpp)}
+ -sSIDE_MODULE
+ {build_dirs.cpp_flags}
+ -fPIC -shared
+ -I {include1}
+ -I {include2}
+ {" ".join(o_files)}
+ {link_l_flags(libmupdf)}
+ ''').strip().replace( '\n', ' \\\n')
+ )
+ jlib.build(
+ [include1, include2] + o_files,
+ libmupdfcpp,
+ command,
+ force_rebuild,
+ )
+
+ elif 'shared' in dir_so_flags:
command = ( textwrap.dedent(
f'''
{compiler}
-o {os.path.relpath(libmupdfcpp)}
- {"-sSIDE_MODULE" if pyodide else ""}
{build_dirs.cpp_flags}
-fPIC -shared
-I {include1}
@@ -2054,43 +2097,100 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
sos.append( f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}')
if os.path.basename( build_dirs.dir_so).startswith( 'shared-'):
sos.append( f'{build_dirs.dir_so}/libmupdf.so{so_version}')
- command = ( textwrap.dedent(
- f'''
- {compiler}
- -o {os.path.relpath(out_so)}
- {"-sMAIN_MODULE" if pyodide else ""}
- {cpp_path}
- {build_dirs.cpp_flags}
- -fPIC
- -shared
- -I {include1}
- -I {include2}
- {flags_compile}
- -Wno-deprecated-declarations
- -Wno-free-nonheap-object
- -DSWIG_PYTHON_SILENT_MEMLEAK
- {flags_link}
- {link_l_flags( sos)}
- ''').strip().replace( '\n', ' \\\n')
- )
- infiles = [
- cpp_path,
- include1,
- include2,
- libmupdf,
- ]
- infiles += sos
+ if pyodide:
+ # Need to use separate compilation/linking.
+ o_file = f'{os.path.relpath(cpp_path)}.o'
+ command = ( textwrap.dedent(
+ f'''
+ {compiler}
+ -c
+ -o {o_file}
+ {cpp_path}
+ {build_dirs.cpp_flags}
+ -fPIC
+ -I {include1}
+ -I {include2}
+ {flags_compile}
+ -Wno-deprecated-declarations
+ -Wno-free-nonheap-object
+ -DSWIG_PYTHON_SILENT_MEMLEAK
+ ''').strip().replace( '\n', ' \\\n')
+ )
+ infiles = [
+ cpp_path,
+ include1,
+ include2,
+ ]
+ jlib.build(
+ infiles,
+ o_file,
+ command,
+ force_rebuild,
+ )
- jlib.build(
- infiles,
- out_so,
- command,
- force_rebuild,
- )
- macos_patch( out_so,
- f'{build_dirs.dir_so}/libmupdf.dylib{so_version}',
- f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}',
- )
+ command = ( textwrap.dedent(
+ f'''
+ {compiler}
+ -o {os.path.relpath(out_so)}
+ -sSIDE_MODULE
+ {o_file}
+ {build_dirs.cpp_flags}
+ -shared
+ {flags_link}
+ {link_l_flags( sos)}
+ ''').strip().replace( '\n', ' \\\n')
+ )
+ infiles = [
+ o_file,
+ libmupdf,
+ ]
+ infiles += sos
+
+ jlib.build(
+ infiles,
+ out_so,
+ command,
+ force_rebuild,
+ )
+ else:
+ # Not Pyodide.
+ command = ( textwrap.dedent(
+ f'''
+ {compiler}
+ -o {os.path.relpath(out_so)}
+ {"-sMAIN_MODULE" if 0 and pyodide else ""}
+ {cpp_path}
+ {build_dirs.cpp_flags}
+ -fPIC
+ -shared
+ -I {include1}
+ -I {include2}
+ {flags_compile}
+ -Wno-deprecated-declarations
+ -Wno-free-nonheap-object
+ -DSWIG_PYTHON_SILENT_MEMLEAK
+ {flags_link}
+ {link_l_flags( sos)}
+ ''').strip().replace( '\n', ' \\\n')
+ )
+ infiles = [
+ cpp_path,
+ include1,
+ include2,
+ libmupdf,
+ ]
+ infiles += sos
+
+ jlib.build(
+ infiles,
+ out_so,
+ command,
+ force_rebuild,
+ )
+ macos_patch( out_so,
+ f'{build_dirs.dir_so}/libmupdf.dylib{so_version}',
+ f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}',
+ )
else:
raise Exception( 'unrecognised --build action %r' % action)
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,176 +0,0 @@
From cb26b6c33f761f592e21f22301368319395d6ad2 Mon Sep 17 00:00:00 2001
Message-ID: <cb26b6c33f761f592e21f22301368319395d6ad2.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Sun, 5 Nov 2023 18:03:50 +0000
Subject: [PATCH 06/11] scripts/wrap/__main__.py: Allow customisation of
language bindings builds.
If $CXX is set in environment, we use its value instead of default `c++`.
Also, on MacOS, avoid unnecessary rebuilds - only run post-processing otool
command if we ran the link command.
Allow customisation of mupdf make command: new options in `-b` sub-command
allow overriding of make target (e.g. `-b --m-target libs`) and setting of
Makefile variables (e.g. `-b --m-vars 'HAVE_LIBCRYPTO=no'`).
Fix `--venv` arg, recent pipcl.py requires setuptools.
(cherry picked from commit 8cdf891d85c8c302f56d295c8acc37c2e3e6b6b5)
---
scripts/wrap/__main__.py | 49 ++++++++++++++++++++++++++++++----------
1 file changed, 37 insertions(+), 12 deletions(-)
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index 3000685a1..d7e86c755 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -402,7 +402,10 @@ Tools required to build:
pip install libclang
- SWIG for Python bindings:
+ setuptools:
+ Used internally.
+
+ SWIG for Python/C# bindings:
We work with swig-3 and swig-4. If swig-4 is used, we propogate
doxygen-style comments for structures and functions into the generated
@@ -637,6 +640,13 @@ Usage:
Set -j arg used when action 'm' calls make (not
Windows). If <N> is 0 we use the number of CPUs
(from Python's multiprocessing.cpu_count()).
+ --m-target
+ Set target for action 'm'. Default is blank, so make will
+ build the default `all` target.
+ --m-vars
+ Text to insert near start of the action 'm' make command,
+ typically to set MuPDF build flags, for example:
+ --m-vars 'HAVE_LIBCRYPTO=no'
--regress
Checks for regressions in generated C++ code and SWIG .i
file (actions 0 and 2 below). If a generated file already
@@ -1206,7 +1216,7 @@ def get_so_version( build_dirs):
return f'.{minor}.{patch}'
-def _get_m_command( build_dirs, j=None, make=None):
+def _get_m_command( build_dirs, j=None, make=None, m_target=None, m_vars=None):
'''
Generates a `make` command for building with `build_dirs.dir_mupdf`.
@@ -1236,6 +1246,8 @@ def _get_m_command( build_dirs, j=None, make=None):
actual_build_dir = f'{build_dirs.dir_mupdf}/build/'
make_env = ''
make_args = ' HAVE_GLUT=no HAVE_PTHREAD=yes verbose=yes'
+ if m_vars:
+ make_args += f' {m_vars}'
suffix = None
build_prefix = ''
in_prefix = True
@@ -1286,6 +1298,8 @@ def _get_m_command( build_dirs, j=None, make=None):
assert suffix, f'Leaf must contain "shared-" or "fpic-": build_dirs.dir_so={build_dirs.dir_so}'
if build_prefix:
make_args += f' build_prefix={build_prefix}'
+ if m_target:
+ make_args += f' {m_target}'
command = f'cd {build_dirs.dir_mupdf} &&'
if make_env:
command += make_env
@@ -1510,6 +1524,8 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
clang_info_verbose = False
force_rebuild = False
header_git = False
+ m_target = None
+ m_vars = None
j = 0
refcheck_if = '#ifndef NDEBUG'
pyodide = (os.environ.get('OS') == 'pyodide')
@@ -1519,6 +1535,9 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
# because of the command changing.
assert os.environ.get('CXX', None), 'Pyodide build but $CXX not defined.'
compiler = '$CXX'
+ elif 'CXX' in os.environ:
+ compiler = os.environ['CXX']
+ jlib.log(f'Setting compiler to {os.environ["CXX"]=}.')
elif state.state_.macos:
compiler = 'c++ -std=c++14'
# Add extra flags for MacOS cross-compilation, where ARCHFLAGS can be
@@ -1577,6 +1596,10 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
elif actions == '--refcheck-if':
refcheck_if = args.next()
jlib.log( 'Have set {refcheck_if=}')
+ elif actions == '--m-target':
+ m_target = args.next()
+ elif actions == '--m-vars':
+ m_vars = args.next()
elif actions.startswith( '-'):
raise Exception( f'Unrecognised --build flag: {actions}')
else:
@@ -1603,7 +1626,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
jlib.log( 'Ignoring `-b m` on Windows as not required.')
else:
jlib.log( 'Building libmupdf.so ...')
- command, actual_build_dir, suffix = _get_m_command( build_dirs, j, make_command)
+ command, actual_build_dir, suffix = _get_m_command( build_dirs, j, make_command, m_target, m_vars)
jlib.system( command, prefix=jlib.log_text(), out='log', verbose=1)
suffix2 = '.dylib' if state.state_.macos else '.so'
@@ -1726,13 +1749,14 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
{link_l_flags(libmupdf)}
''').strip().replace( '\n', ' \\\n')
)
- jlib.build(
+ command_was_run = jlib.build(
[include1, include2] + cpp_files,
libmupdfcpp,
command,
force_rebuild,
)
- macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib{so_version}')
+ if command_was_run:
+ macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib{so_version}')
if so_version:
jlib.system(f'ln -sf libmupdfcpp.so{so_version} {build_dirs.dir_so}/libmupdfcpp.so')
@@ -2181,16 +2205,17 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
]
infiles += sos
- jlib.build(
+ command_was_run = jlib.build(
infiles,
out_so,
command,
force_rebuild,
)
- macos_patch( out_so,
- f'{build_dirs.dir_so}/libmupdf.dylib{so_version}',
- f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}',
- )
+ if command_was_run:
+ macos_patch( out_so,
+ f'{build_dirs.dir_so}/libmupdf.dylib{so_version}',
+ f'{build_dirs.dir_so}/libmupdfcpp.so{so_version}',
+ )
else:
raise Exception( 'unrecognised --build action %r' % action)
@@ -2994,9 +3019,9 @@ def main2():
command += f' && python -m pip install --upgrade pip'
if state.state_.openbsd:
jlib.log( 'Not installing libclang on openbsd; we assume py3-llvm is installed.')
- command += f' && python -m pip install --upgrade swig'
+ command += f' && python -m pip install --upgrade swig setuptools'
else:
- command += f' && python -m pip install{force_reinstall} --upgrade libclang swig'
+ command += f' && python -m pip install{force_reinstall} --upgrade libclang swig setuptools'
command += f' && python {shlex.quote(sys.argv[0])}'
while 1:
try:
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,32 +0,0 @@
From 6ebfa017ebe069ddb139252e49a151ab687c4f42 Mon Sep 17 00:00:00 2001
Message-ID: <6ebfa017ebe069ddb139252e49a151ab687c4f42.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Fri, 17 Nov 2023 17:05:06 +0000
Subject: [PATCH 07/11] scripts/wrap/cpp.py: avoid compiler error in debug
diagnostics on Android.
In debug diagnostics, don't attempt to write a `va_list` arg to a stream.
(cherry picked from commit d888952ba9c38a0a2b0c9dec79e25c29a53e1e82)
---
scripts/wrap/cpp.py | 2 ++
1 file changed, 2 insertions(+)
diff --git a/scripts/wrap/cpp.py b/scripts/wrap/cpp.py
index 329db25a4..0a1b16ac8 100644
--- a/scripts/wrap/cpp.py
+++ b/scripts/wrap/cpp.py
@@ -333,6 +333,8 @@ def make_fncall( tu, cursor, return_type, fncall, out, refcheck_if):
# appears to kill std::cerr on Linux.
out.write( f' if ({arg.name}) std::cerr << " {arg.name}=\'" << {arg.name} << "\'";\n')
out.write( f' else std::cerr << " {arg.name}:null";\n')
+ elif parse.is_( arg.cursor.type, 'va_list'):
+ out.write( f' std::cerr << " {arg.name}:va_list";\n')
elif (0
or parse.is_( arg.cursor.type, 'signed char')
or parse.is_( arg.cursor.type, 'unsigned char')
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,40 +0,0 @@
From 590dd46a909773f0b3f2754ec15487745afbdd91 Mon Sep 17 00:00:00 2001
Message-ID: <590dd46a909773f0b3f2754ec15487745afbdd91.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Wed, 3 Jan 2024 16:42:17 +0000
Subject: [PATCH 08/11] Makefile: fix build failures with library soft-links.
We need to use `ln -f` when creating shared library soft-links, otherwise we
fail if they already exist.
(cherry picked from commit 032af8acbfdfcfaf7d7fa63df7f22dacf6b4f630)
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 55fda4854..f8a8dfaa9 100644
--- a/Makefile
+++ b/Makefile
@@ -621,14 +621,14 @@ install-shared-c: install-shared-check shared install-headers
install -d $(DESTDIR)$(libdir)
install -m 644 $(OUT)/libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
- ln -s libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
+ ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
endif
install-shared-c++: install-shared-c c++
install -m 644 platform/c++/include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
install -m 644 $(OUT)/libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
- ln -s libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdfcpp.$(SO)
+ ln -sf libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdfcpp.$(SO)
endif
install-shared-python: install-shared-c++ python
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,78 +0,0 @@
From e0730c0a0b9332c66400ce60b6782cd391b67b05 Mon Sep 17 00:00:00 2001
Message-ID: <e0730c0a0b9332c66400ce60b6782cd391b67b05.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Tue, 9 Jan 2024 18:47:47 +0000
Subject: [PATCH 09/11] Makefile scripts/wrap/__main__.py: Set SONAME when
linking shared libs on Linux.
We add link arg `-Wl,-soname,libmupdf[cpp].so,MAJOR.MINOR`.
Also only create libmupdf[cpp].so softlinks if we are on Linux.
(cherry picked from commit 82db7fcd5bdf59652d03a56b06bf2e853140282b)
---
Makefile | 9 +++++++--
scripts/wrap/__main__.py | 6 +++++-
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/Makefile b/Makefile
index f8a8dfaa9..369127981 100644
--- a/Makefile
+++ b/Makefile
@@ -42,6 +42,9 @@ VERSION_PATCH = $(shell grep "define FZ_VERSION_PATCH" include/mupdf/fitz/versio
ifeq ($(LINUX_OR_OPENBSD),yes)
SO_VERSION = .$(VERSION_MINOR).$(VERSION_PATCH)
+ ifeq ($(OS),Linux)
+ SO_VERSION_LINUX := yes
+ endif
endif
# --- Commands ---
@@ -93,9 +96,11 @@ $(OUT)/%.exe: %.c
$(LINK_CMD)
$(OUT)/%.$(SO)$(SO_VERSION):
- $(LINK_CMD) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
-ifneq ($(SO_VERSION),)
+ifeq ($(SO_VERSION_LINUX),yes)
+ $(LINK_CMD) -Wl,-soname,$(notdir $@) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
ln -sf $(notdir $@) $(patsubst %$(SO_VERSION), %, $@)
+else
+ $(LINK_CMD) $(LIB_LDFLAGS) $(THIRD_LIBS) $(LIBCRYPTO_LIBS)
endif
$(OUT)/%.def: $(OUT)/%.$(SO)$(SO_VERSION)
diff --git a/scripts/wrap/__main__.py b/scripts/wrap/__main__.py
index d7e86c755..80dd2bf1e 100644
--- a/scripts/wrap/__main__.py
+++ b/scripts/wrap/__main__.py
@@ -1737,10 +1737,14 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
)
elif 'shared' in dir_so_flags:
+ link_soname_arg = ''
+ if state.state_.linux:
+ link_soname_arg = f'-Wl,-soname,{os.path.basename(libmupdfcpp)}'
command = ( textwrap.dedent(
f'''
{compiler}
-o {os.path.relpath(libmupdfcpp)}
+ {link_soname_arg}
{build_dirs.cpp_flags}
-fPIC -shared
-I {include1}
@@ -1757,7 +1761,7 @@ def build( build_dirs, swig_command, args, vs_upgrade, make_command):
)
if command_was_run:
macos_patch( libmupdfcpp, f'{build_dirs.dir_so}/libmupdf.dylib{so_version}')
- if so_version:
+ if so_version and state.state_.linux:
jlib.system(f'ln -sf libmupdfcpp.so{so_version} {build_dirs.dir_so}/libmupdfcpp.so')
elif 'fpic' in dir_so_flags:
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,37 +0,0 @@
From 09fd82aaa02f6182bf8ca97998969a19af308660 Mon Sep 17 00:00:00 2001
Message-ID: <09fd82aaa02f6182bf8ca97998969a19af308660.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Robin Watts <Robin.Watts@artifex.com>
Date: Wed, 31 Jan 2024 17:00:16 +0000
Subject: [PATCH 10/11] Bug 707503: Make cast from int64_t to time_t explicit.
(cherry picked from commit be277ad92b55a74dac4495c25d2ca29f60b3fa1d)
---
platform/gl/gl-main.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index b2eb0a48e..d5b02f340 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -2556,7 +2556,7 @@ static char *short_signature_error_desc(pdf_signature_error err)
}
}
-const char *format_date(int64_t secs)
+const char *format_date(int64_t secs64)
{
static char buf[100];
#ifdef _POSIX_SOURCE
@@ -2564,6 +2564,7 @@ const char *format_date(int64_t secs)
#else
struct tm *tm;
#endif
+ time_t secs = (time_t)secs64;
if (secs <= 0)
return NULL;
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,86 +0,0 @@
From ea99887b31f600b2a13e208361f66da0adf87743 Mon Sep 17 00:00:00 2001
Message-ID: <ea99887b31f600b2a13e208361f66da0adf87743.1708115863.git.mjg@fedoraproject.org>
In-Reply-To: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
References: <1932a672db047da3204a445880007fcc522fa7d7.1708115863.git.mjg@fedoraproject.org>
From: Julian Smith <julian.smith@artifex.com>
Date: Sat, 27 Jan 2024 20:18:27 +0000
Subject: [PATCH 11/11] Makefile: allow control of file modes and venv's.
For `install*` targets, `SO_INSTALL_MODE` will override `install` commands'
default `-m 644` setting for .so files.
For C++, Python and C# builds, `VENV_FLAG` will override the default `--venv`
passed to ./scripts/mupdfwrap.py; so if set to an empty string, the build will
not be done in a venv.
Defaults for `SO_INSTALL_MODE` and `VENV_FLAG` are set using `?=` so they can
be overridden either in the environment or as `make` parameters. For example
`INSTALL_MODE=755 make ...` or `make INSTALL_MODE=755 ...`.
(cherry picked from commit 010404d06200115fbf146434234fdd99b5df6f66)
---
Makefile | 19 ++++++++++++-------
1 file changed, 12 insertions(+), 7 deletions(-)
diff --git a/Makefile b/Makefile
index 369127981..1d901a389 100644
--- a/Makefile
+++ b/Makefile
@@ -449,6 +449,7 @@ incdir ?= $(prefix)/include
mandir ?= $(prefix)/share/man
docdir ?= $(prefix)/share/doc/mupdf
pydir ?= $(shell python3 -c "import sysconfig; print(sysconfig.get_path('platlib'))")
+SO_INSTALL_MODE ?= 644
third: $(THIRD_LIB)
extra-libs: $(THIRD_GLUT_LIB)
@@ -604,13 +605,17 @@ $(error OUT=$(OUT) does not contain shared)
endif
# C++, Python and C# shared libraries.
+#
+# To disable automatic use of a venv, use `make VENV_FLAG= ...` or `VENV_FLAG=
+# make ...`.
+#
+VENV_FLAG ?= --venv
c++-%: shared-%
- ./scripts/mupdfwrap.py --venv -d $(OUT) -b 01
+ ./scripts/mupdfwrap.py $(VENV_FLAG) -d $(OUT) -b 01
python-%: c++-%
- ./scripts/mupdfwrap.py --venv -d $(OUT) -b 23
+ ./scripts/mupdfwrap.py $(VENV_FLAG) -d $(OUT) -b 23
csharp-%: c++-%
- ./scripts/mupdfwrap.py --venv -d $(OUT) -b --csharp 23
-
+ ./scripts/mupdfwrap.py $(VENV_FLAG) -d $(OUT) -b --csharp 23
# Installs of C, C++, Python and C# shared libraries
#
@@ -624,21 +629,21 @@ endif
install-shared-c: install-shared-check shared install-headers
install -d $(DESTDIR)$(libdir)
- install -m 644 $(OUT)/libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
+ install -m $(SO_INSTALL_MODE) $(OUT)/libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
endif
install-shared-c++: install-shared-c c++
install -m 644 platform/c++/include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
- install -m 644 $(OUT)/libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
+ install -m $(SO_INSTALL_MODE) $(OUT)/libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/
ifneq ($(OS),OpenBSD)
ln -sf libmupdfcpp.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdfcpp.$(SO)
endif
install-shared-python: install-shared-c++ python
install -d $(DESTDIR)$(pydir)/mupdf
- install -m 644 $(OUT)/_mupdf.$(SO) $(DESTDIR)$(pydir)/mupdf
+ install -m $(SO_INSTALL_MODE) $(OUT)/_mupdf.$(SO) $(DESTDIR)$(pydir)/mupdf
install -m 644 $(OUT)/mupdf.py $(DESTDIR)$(pydir)/mupdf/__init__.py
else
--
2.44.0.rc1.222.g52f20dec8d

View File

@ -1,53 +0,0 @@
From dc339ceab37d962e91527068321790768262a42c Mon Sep 17 00:00:00 2001
From: Mamoru TASAKA <mtasaka@fedoraproject.org>
Date: Thu, 28 Sep 2023 23:35:51 +0900
Subject: [PATCH] Bug 707210: fitz: fix assertion on mutool on s390x
template_span_with_mask_3_general attemps to accelerate
template_span_with_mask_N_general
by accessing byte sequence dp and sp 4 bytes each,
reinterpreting them as uint32_t sequence then calculating the result
sequence 4 bytes each. The value of each 4 byte interpreted as
uint32_t differs according to endianness, so fixing
assertion expression as such.
Fixes https://bugs.ghostscript.com/show_bug.cgi?id=707210 :
`mutool draw -F png` assertion on s390x.
---
source/fitz/draw-paint.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/source/fitz/draw-paint.c b/source/fitz/draw-paint.c
index c8e67c8832..84e6490a32 100644
--- a/source/fitz/draw-paint.c
+++ b/source/fitz/draw-paint.c
@@ -1203,6 +1203,7 @@ template_span_with_mask_1_general(byte * FZ_RESTRICT dp, const byte * FZ_RESTRIC
static fz_forceinline void
template_span_with_mask_3_general(byte * FZ_RESTRICT dp, const byte * FZ_RESTRICT sp, int a, const byte * FZ_RESTRICT mp, int w)
{
+ int bigendian_p = isbigendian();
do
{
int ma = *mp++;
@@ -1240,9 +1241,18 @@ template_span_with_mask_3_general(byte * FZ_RESTRICT dp, const byte * FZ_RESTRIC
d0 = (((d0<<8) + (s0-d0)*ma)>>8) & mask;
d1 = ((d1<<8) + (s1-d1)*ma) & ~mask;
d0 |= d1;
- assert((d0>>24) >= (d0 & 0xff));
- assert((d0>>24) >= ((d0>>8) & 0xff));
- assert((d0>>24) >= ((d0>>16) & 0xff));
+ if (bigendian_p)
+ {
+ assert((d0 & 0xff) >= (d0>>24));
+ assert((d0 & 0xff) >= ((d0>>16) & 0xff));
+ assert((d0 & 0xff) >= ((d0>>8) & 0xff));
+ }
+ else
+ {
+ assert((d0>>24) >= (d0 & 0xff));
+ assert((d0>>24) >= ((d0>>8) & 0xff));
+ assert((d0>>24) >= ((d0>>16) & 0xff));
+ }
*(uint32_t *)dp = d0;
sp += 4;
dp += 4;

View File

@ -1,10 +1,10 @@
Name: mupdf Name: mupdf
%global libname libmupdf %global libname libmupdf
Version: 1.23.10 Version: 1.24.0
%global pypiname mupdf %global pypiname mupdf
# upstream prerelease versions tags need to be translated to Fedorian # upstream prerelease versions tags need to be translated to Fedorian
%global upversion %{version} %global upversion %{version}
%global soname 23.10 %global soname 24.0
Release: %autorelease Release: %autorelease
Summary: A lightweight PDF viewer and toolkit Summary: A lightweight PDF viewer and toolkit
License: AGPL-3.0-or-later License: AGPL-3.0-or-later
@ -12,21 +12,6 @@ URL: http://mupdf.com/
Source0: http://mupdf.com/downloads/archive/%{name}-%{upversion}-source.tar.gz Source0: http://mupdf.com/downloads/archive/%{name}-%{upversion}-source.tar.gz
Source1: %{name}.desktop Source1: %{name}.desktop
Source2: %{name}-gl.desktop Source2: %{name}-gl.desktop
# https://github.com/ArtifexSoftware/mupdf/pull/42
Patch: dc339ceab37d962e91527068321790768262a42c.patch
# Upstream patches backported from master branch (build system fixes for shared builds)
Patch: 0001-Makerules-scripts-wrap-__main__.py-fix-for-Pyodide-s.patch
Patch: 0002-Makefile-add-version-numbers-and-installation-target.patch
Patch: 0003-scripts-Create-shared-libraries-with-version-numbers.patch
Patch: 0004-Makerules-fixes-for-shared-shared-library-installs-o.patch
Patch: 0005-scripts-wrap-__main__.py-fix-Pyodide-builds-of-share.patch
Patch: 0006-scripts-wrap-__main__.py-Allow-customisation-of-lang.patch
Patch: 0007-scripts-wrap-cpp.py-avoid-compiler-error-in-debug-di.patch
Patch: 0008-Makefile-fix-build-failures-with-library-soft-links.patch
Patch: 0009-Makefile-scripts-wrap-__main__.py-Set-SONAME-when-li.patch
Patch: 0010-Bug-707503-Make-cast-from-int64_t-to-time_t-explicit.patch
Patch: 0011-Makefile-allow-control-of-file-modes-and-venv-s.patch
Patch: 0001-Fix-build-with-llvm18.patch
BuildRequires: gcc gcc-c++ make binutils desktop-file-utils coreutils pkgconfig BuildRequires: gcc gcc-c++ make binutils desktop-file-utils coreutils pkgconfig
BuildRequires: openjpeg2-devel desktop-file-utils BuildRequires: openjpeg2-devel desktop-file-utils
BuildRequires: libjpeg-devel freetype-devel libXext-devel curl-devel BuildRequires: libjpeg-devel freetype-devel libXext-devel curl-devel
@ -39,12 +24,12 @@ BuildRequires: swig python3-clang python3-devel
# We need to build against the Artifex fork of lcms2 so that we are thread safe # We need to build against the Artifex fork of lcms2 so that we are thread safe
# (see bug #1553915). Artifex make sure to rebase against upstream, who refuse # (see bug #1553915). Artifex make sure to rebase against upstream, who refuse
# to integrate Artifex's changes. # to integrate Artifex's changes.
Provides: bundled(lcms2-devel) = 2.14~rc1^59-g88b6a72 Provides: bundled(lcms2-devel) = 2.14~rc1^60.gab4547b
# muPDF needs the muJS sources for the build even if we build against the system # muPDF needs the muJS sources for the build even if we build against the system
# version so bundling them is the safer choice. # version so bundling them is the safer choice.
Provides: bundled(mujs-devel) = 1.3.3 Provides: bundled(mujs-devel) = 1.3.3
# muPDF builds only against in-tree extract which is versioned along with ghostpdl. # muPDF builds only against in-tree extract which is versioned along with ghostpdl.
Provides: bundled(extract) = 10.01.2 Provides: bundled(extract) = 10.01.2^1.ged5acb1
%description %description
MuPDF is a lightweight PDF viewer and toolkit written in portable C. MuPDF is a lightweight PDF viewer and toolkit written in portable C.

View File

@ -1 +1 @@
SHA512 (mupdf-1.23.10-source.tar.gz) = 38b1dcd8480eb11b19861cf15302d6a8d5ca6c42f774fd2ad5f4b5ec231a819c0c59372c5895d0973af5b4f2e71f14e97201a5db56c7796e0af95c44d3994f2d SHA512 (mupdf-1.24.0-source.tar.gz) = cb3b70341a924b524ddd20d5af00249a48bf79d9e05031648f95dd4121e1f125eb85ca70168b34db9fcf5251db705df599e327afde14549ee8627efe1d866811