Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: doc_src: build method detection util #1255

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,12 @@ tasks.register('webManual', Sync) {
}
}

providers.exec {
ignoreExitValue = true
commandLine ["doc_src/detect_build_method"]
}
def docMethod = exe.result.get() == 0 ? exe.standardOutput.asText.get().trim() : ''

ext.manualIndexXmls = fileTree(dir: 'doc_src', include: '**/OmegaTUsersManual_xinclude full.xml')
manualIndexXmls.each { xml ->
def lang = xml.parentFile.name
Expand All @@ -539,10 +545,7 @@ manualIndexXmls.each { xml ->
inputs.files fileTree(dir: "doc_src/${lang}", includes: ['**/*.xml', 'images/*.png'],
excludes: ['xhtml5/*', 'index.xml'])
outputs.files layout.buildDirectory.file("docs/pdfs/OmegaT_documentation_${lang}.PDF")
onlyIf {
conditions([exePresent('docker') || exePresent('nerdctl'), 'Docker or nerdctl is not installed'],
[!project.hasProperty('forceSkipDocumentBuild'), 'Specified forceSkipDocumentBuild property'])
}
onlyIf {project.hasProperty('publish') || !project.hasProperty('forceSkipDocumentBuild')}
workingDir = 'doc_src'
commandLine './docgen', "-Dlanguage=${lang}", "-Dtarget=../build/docs/pdfs", 'pdf'
doLast {
Expand Down
60 changes: 60 additions & 0 deletions doc_src/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,66 @@

<include file="../../doc_src_paths.xml"/>

<!-- Check DocBook XSL Stylesheets -->
<property name="libxml2.version" value="2.12.4" />
<target name="check-docbook-stylesheets">
<condition property="docbook.stylesheets.available">
<and>
<available file="${dbk}/docbook.xsl" />
<available file="${dbk}/fo/docbook.xsl" />
<greater
arg1="1.79.2"
arg2="1.79.2" />
</and>
</condition>
<fail message="DocBook XSL Stylesheets not found or incorrect version. Please install v1.79.2 or above."
unless="docbook.stylesheets.available" />
</target>

<!-- Check DocBook XML -->
<target name="check-docbook-xml">
<condition property="docbook.xml.available">
<available file="../../docbook-utf8.xsl" />
</condition>
<fail message="DocBook XML 4.5 not found at ${docbook.xml.dir}. Please ensure it is installed."
unless="docbook.xml.available" />
</target>

<!-- Check libxml2 -->
<target name="check-libxml2">
<exec executable="xml2-config" outputproperty="libxml2.detected.version">
<arg value="--version" />
</exec>
<condition property="libxml2.version.correct">
<greater arg1="${libxml2.detected.version}" arg2="${libxml2.version}" />
</condition>
<fail message="libxml2 version ${libxml2.version} or higher is required. Detected: ${libxml2.detected.version}"
unless="libxml2.version.correct" />
</target>

<!-- Check Saxon -->
<target name="check-saxon">
<condition property="saxon.available">
<available file="${saxon}" />
</condition>
<fail message="Saxon 6-5-5 not found in ${saxon}. Please ensure it is installed."
unless="saxon.available" />
</target>

<!-- Check XMLmind Web Help Compiler -->
<target name="check-whc">
<condition property="whc.available">
<available file="${whc}" />
</condition>
<fail message="XMLmind Web Help Compiler 3.5_1 not found at ${whc}. Please ensure it is installed."
unless="whc.available" />
</target>

<!-- Composite check for all dependencies -->
<target name="check-dependencies" depends="check-docbook-stylesheets, check-docbook-xml, check-libxml2, check-saxon, check-whc">
<echo message="All dependencies are satisfied." />
</target>

<target name="include">
<exec executable="xmllint"
dir="." >
Expand Down
21 changes: 21 additions & 0 deletions doc_src/detect_build_method
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/bash

## RESULT
METHOD="container"

## Detect container runtime and cli
CMD="$(type -p docker)" && $CMD info >/dev/null 2>&1 || CMD="$(type -p nerdctl)"
if [ "$CMD" == "" ]; then
METHOD="ant"
else
$CMD info > /dev/null 2>&1 || METHOD="ant"
fi

## Detect ant, and dependencies
if [ "$METHOD" == "ant" ]; then
CMD="$(type -p ant)"
if [ "$CMD" != "" ]; then
$CMD check-dependencies >> /dev/null 2>&1 || METHOD=""
fi
fi
echo $METHOD
Loading