This is an automated email from the ASF dual-hosted git repository. leginee pushed a commit to branch backport/pdfimport-pdfbox in repository https://gitbox.apache.org/repos/asf/openoffice.git
commit 22af67367164802c857cf3204696dddbf8222048 Author: Peter <[email protected]> AuthorDate: Wed Sep 9 00:47:30 2026 +0200 build: make the PDFBox helper actually build under dmake Four fixes, each found by running the build rather than reading it. set_soenv.in Still expanded @SYSTEM_POPPLER@, @POPPLER_CFLAGS@ and @POPPLER_LIBS@. With the AC_SUBSTs gone those placeholders survive verbatim into set_soenv, where perl reads "@SYSTEM_POPPLER" as an array and dies: "Global symbol requires explicit package name". Removing an AC_SUBST means removing its consumer. makefile.mk Includes ant.mk, not antsettings.mk. ant.mk pulls in settings.mk and target.mk itself and is what defines the ANTBUILD target; antsettings.mk only sets variables and belongs to the BUILD_ACTION/tg_ext.mk route that unpacks a source tarball first, which apache-commons needs and this does not. build.xml Places the four jars, instead of dmake doing it. $(OUTDIR) and $(TARFILE_LOCATION) are absolute and begin "C:", and dmake reads that colon as its rule separator, so neither can appear as a target or a prerequisite: it fails with "Multiply defined recipe for target C". $(BIN) is relative and survives, so it is passed through -D and the copy happens in ant, which has no such trouble. The sources are also named by checksum on disk, as "<md5>-<name>", the convention TARFILE_MD5 follows in solenv/inc/tg_ext.mk, so the four MD5s are spelled out here. Verified: the module builds, and the resulting jar runs against test/testinput.pdf producing byte-identical output to the Bazel-built helper. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01CH5PJJyJfirMStqJEZTxBD --- .../sdext/source/pdfimport/pdfboxwrapper/build.xml | 67 +++++++++++++++++++--- .../source/pdfimport/pdfboxwrapper/makefile.mk | 55 +++++------------- main/set_soenv.in | 3 - 3 files changed, 72 insertions(+), 53 deletions(-) diff --git a/main/sdext/source/pdfimport/pdfboxwrapper/build.xml b/main/sdext/source/pdfimport/pdfboxwrapper/build.xml index 2d0e9c472c..60e7c508eb 100644 --- a/main/sdext/source/pdfimport/pdfboxwrapper/build.xml +++ b/main/sdext/source/pdfimport/pdfboxwrapper/build.xml @@ -22,21 +22,34 @@ <!-- The PDF Import extension's parsing backend. - This is a plain program, not a UNO component: it is spawned as its own - process and speaks the protocol in ../PROTOCOL.md over stdout, so it links - no UNO and needs none of the office jars on its classpath. Keeping it out - of process is what lets an Apache-licensed office use any engine, and what - confines a fault in it to one document. --> + A plain program, not a UNO component: it is spawned as its own process and + speaks the protocol in ../PROTOCOL.md over stdout, so it links no UNO and + needs none of the office jars on its classpath. Keeping it out of process + is what lets an Apache-licensed office use any engine, and what confines a + fault in it to one document. + + The four PDFBox jars are placed from here rather than from makefile.mk + because they live under absolute paths: $(OUTDIR) and $(TARFILE_LOCATION) + both begin "C:", and dmake reads the colon in a target or prerequisite as + its rule separator. Ant has no such trouble. --> <project name="pdfimport-pdfbox" default="main" basedir="."> <property file="../../../../ant.properties"/> <import file="${SRC_ROOT}/solenv/ant/aoo-ant.xml"/> - <target name="init-project"> - <!-- Started as `java -jar`, so the four PDFBox jars have to be - reachable from this jar's own Class-Path. They are packed beside - it in the extension, so plain filenames resolve. --> + <!-- external_deps.lst stores every download under its checksum, as + "<md5>-<name>", the same convention TARFILE_MD5 follows in + solenv/inc/tg_ext.mk. --> + <property name="pdfbox.md5" value="92ed0441337f2ed1f43eeaa901bd7814"/> + <property name="pdfbox-io.md5" value="f45a2386cf4178b5955dda2807139745"/> + <property name="fontbox.md5" value="379e6faf6ea614ad3318eda879e4f423"/> + <property name="commons-logging.md5" value="954e27d33e55e587a4694d5952a0c5c6"/> + + <target name="init-project" depends="place-externals"> + <!-- Started as `java -jar`, so the four have to be reachable from this + jar's own Class-Path. They are packed beside it in the extension, + so plain filenames resolve. --> <property name="jar.classpath" value="${external.pdfbox.jarclasspath} ${external.pdfbox-io.jarclasspath} ${external.fontbox.jarclasspath} ${external.commons-logging.jarclasspath}"/> <property name="jar.manifest" location="manifest.mf"/> @@ -49,4 +62,40 @@ </path> </target> + <!-- Put the downloads where externals.xml says they are, so the compile + classpath above resolves. Nothing else owns these: unlike + apache-commons, which fetches source and builds it, they are official + ASF release artifacts with nothing to build. --> + <target name="place-externals"> + <macrodef name="place-external"> + <attribute name="name"/> + <attribute name="file"/> + <sequential> + <copy file="${TARFILE_LOCATION}/${@{name}.md5}-@{file}" + tofile="${OUTDIR}/bin/@{file}" + preservelastmodified="true"/> + </sequential> + </macrodef> + + <place-external name="pdfbox" file="pdfbox-3.0.8.jar"/> + <place-external name="pdfbox-io" file="pdfbox-io-3.0.8.jar"/> + <place-external name="fontbox" file="fontbox-3.0.8.jar"/> + <place-external name="commons-logging" file="commons-logging-1.4.0.jar"/> + </target> + + <!-- The extension packaging in ../makefile.mk copies every CONVERTER_FILE + out of the module's own bin directory, so all five jars have to land + there as well. --> + <target name="deliver-to-module-bin" depends="jar"> + <copy todir="${pdfi.bin.dir}" preservelastmodified="true" flatten="true"> + <fileset file="${jar.dir}/${ant.project.name}.jar"/> + <fileset file="${OUTDIR}/bin/pdfbox-3.0.8.jar"/> + <fileset file="${OUTDIR}/bin/pdfbox-io-3.0.8.jar"/> + <fileset file="${OUTDIR}/bin/fontbox-3.0.8.jar"/> + <fileset file="${OUTDIR}/bin/commons-logging-1.4.0.jar"/> + </copy> + </target> + + <target name="main" depends="deliver-to-module-bin"/> + </project> diff --git a/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk b/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk index d6d281969f..ce2cff1f8e 100644 --- a/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk +++ b/main/sdext/source/pdfimport/pdfboxwrapper/makefile.mk @@ -26,57 +26,30 @@ TARGET=pdfimport-pdfbox # --- Settings ----------------------------------------------------- -.INCLUDE : settings.mk - .IF "$(ENABLE_PDFIMPORT)" == "NO" || "$(SOLAR_JAVA)" == "" -all: +@all: @echo "PDF Import extension disabled." .ELSE -ANT_BUILDFILE=build.xml -.INCLUDE : antsettings.mk +# ant.mk, not antsettings.mk: it pulls in settings.mk and target.mk itself and +# is what defines the ANTBUILD target. antsettings.mk only sets variables, and +# is for the BUILD_ACTION/tg_ext.mk route that unpacks a source tarball first -- +# apache-commons does that; there is nothing to unpack here. +.INCLUDE : ant.mk -# external_deps.lst downloads the four jars into $(TARFILE_LOCATION). They are -# needed in two places and neither is optional: solenv/ant/externals.xml -# resolves external.<name>.path to $(OUTDIR)/bin, which is what puts them on -# ant's compile classpath, and the extension packs them beside the helper jar -# so that `java -jar` can follow the Class-Path in its manifest. +# build.xml does the file placement, not dmake. $(OUTDIR) and +# $(TARFILE_LOCATION) are absolute and begin "C:", and dmake reads that colon as +# its rule separator, so neither can appear as a target or a prerequisite -- it +# fails with "Multiply defined recipe for target C". Ant is unaffected. # -# Unlike apache-commons, which fetches source and builds it, these are official -# ASF release artifacts, so there is nothing to build -- only to place. -PDFBOX_JARNAMES= \ - pdfbox-3.0.8.jar \ - pdfbox-io-3.0.8.jar \ - fontbox-3.0.8.jar \ - commons-logging-1.4.0.jar - -SOLVER_JARS=$(foreach,i,$(PDFBOX_JARNAMES) $(OUTDIR)$/bin$/$(i)) -DELIVERED_JARS=$(foreach,i,$(PDFBOX_JARNAMES) $(BIN)$/$(i)) +# $(BIN) is relative, so it survives the trip through -D as a plain value and +# resolves against the build file's basedir, which is this directory. +ANT_FLAGS+=-Dpdfi.bin.dir=$(BIN) # --- Targets ------------------------------------------------------ -.INCLUDE : target.mk - -# The solver copies must exist before ant runs, or the compile classpath points -# at nothing; the $(BIN) copies are what ../makefile.mk packs into the .oxt. -ANTBUILD : $(SOLVER_JARS) - -ALLTAR : $(DELIVERED_JARS) $(BIN)$/$(TARGET).jar - -$(SOLVER_JARS) : $(TARFILE_LOCATION)$/$$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ - -$(DELIVERED_JARS) : $(TARFILE_LOCATION)$/$$(@:f) - @@-$(MKDIRHIER) $(@:d) - $(COPY) $< $@ - -# aoo-ant.xml writes the jar to $(WORKDIR)/Ant; bring it where the extension -# packaging expects to find it. -$(BIN)$/$(TARGET).jar : ANTBUILD - @@-$(MKDIRHIER) $(@:d) - $(COPY) $(WORKDIR)$/Ant$/$(TARGET).jar $@ +ALLTAR : ANTBUILD .ENDIF # ENABLE_PDFIMPORT diff --git a/main/set_soenv.in b/main/set_soenv.in index 24ad7aa98a..e82ffae48b 100644 --- a/main/set_soenv.in +++ b/main/set_soenv.in @@ -2099,9 +2099,6 @@ ToFile( "SYSTEM_GENCMN", "@SYSTEM_GENCMN@", "e" ); ToFile( "SYSTEM_JPEG", "@SYSTEM_JPEG@", "e" ); ToFile( "FREETYPE_CFLAGS", "@FREETYPE_CFLAGS@", "e" ); ToFile( "FREETYPE_LIBS", "@FREETYPE_LIBS@", "e" ); -ToFile( "SYSTEM_POPPLER", "@SYSTEM_POPPLER@", "e" ); -ToFile( "POPPLER_CFLAGS", "@POPPLER_CFLAGS@", "e" ); -ToFile( "POPPLER_LIBS", "@POPPLER_LIBS@", "e" ); ToFile( "GSTREAMER_CFLAGS", "@GSTREAMER_CFLAGS@", "e" ); ToFile( "GSTREAMER_LIBS", "@GSTREAMER_LIBS@", "e" ); ToFile( "SYSTEM_CAIRO", "@SYSTEM_CAIRO@", "e" );
