Skip to content

Commit

Permalink
Revert "Rearrange scripts for PDF generation"
Browse files Browse the repository at this point in the history
This reverts commit da2507a.

The output PDFs have a bug where the section numbers are one depth level
below where they should be.
  • Loading branch information
vhscampos committed Jul 25, 2023
1 parent 5cbb4b7 commit 5b01857
Show file tree
Hide file tree
Showing 18 changed files with 62 additions and 57 deletions.
15 changes: 8 additions & 7 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
# SPDX-FileCopyrightText: Copyright 2021, 2023 Arm Limited and/or its affiliates <[email protected]>
# SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <[email protected]>
#
# SPDX-License-Identifier: Apache-2.0
name: CI

on: [push, pull_request]

jobs:
build-pdfs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v2
- name: check the correctness of the sources and generate the PDFs
run: ./tools/build-pdfs.sh
- uses: actions/upload-artifact@v3
run: ./build_with_docker.sh
- uses: actions/upload-artifact@v2
with:
name: pdfs
path: output_pdfs
path: pdfs

build-github-pages:
runs-on: ubuntu-latest
Expand All @@ -27,7 +28,7 @@ jobs:
markdown-link-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@master
- uses: gaurav-nelson/github-action-markdown-link-check@v1
with:
config-file: '.github/workflows/markdown-link-check.json'
5 changes: 2 additions & 3 deletions tools/build-pdfs.sh → build_with_docker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
set -x
IMAGE_NAME=acle_build
# Build the image.
docker build -t $IMAGE_NAME tools/pdf/docker
docker build -t $IMAGE_NAME tools/docker
# Run the image, mounting the current folder into the /src folder of
# the docker image.
ROOTDIR=$(realpath "$(dirname "$(realpath "$0")")/..")
docker run --rm -v "$ROOTDIR":/src $IMAGE_NAME
docker run --rm --mount type=bind,source="$(pwd)",target=/src $IMAGE_NAME
File renamed without changes.
File renamed without changes.
27 changes: 27 additions & 0 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-FileCopyrightText: Copyright 2021 Arm Limited and/or its affiliates <[email protected]>
# SPDX-License-Identifier: Apache-2.0
# syntax=docker/dockerfile:1

# We use Ubuntu 20.04 (Long term Support, LTS) to avoid major updates
# in the tools used to build the specification to avoid changes in the
# appearance of the PDFs.
FROM ubuntu:20.04
ENV DEBIAN_FRONTEND="noninteractive"
# The option --no-install-recommends is used to prevent apt from
# installing the texlive-*-doc packages.
RUN apt-get update \
&& apt-get install -y --no-install-recommends \
texlive-latex-base \
texlive-fonts-recommended \
texlive-fonts-extra \
texlive-latex-extra \
lmodern \
pandoc \
inkscape \
python3 \
python3-tabulate \
librsvg2-bin \
&& rm -rf /var/lib/apt/lists/*

COPY entrypoint.sh /entrypoint.sh
ENTRYPOINT ["/entrypoint.sh"]
7 changes: 3 additions & 4 deletions tools/pdf/docker/entrypoint.sh → tools/docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ ls -al

# Generate the intrinsic specifications and the PDFs. If this step
# fails at any point, stop the docker run.
/src/tools/pdf/hyperref-check.sh || exit 1
/src/tools/pdf/generate-intrinsics-specs.sh || exit 1
/src/tools/pdf/generate-pdfs.sh || exit 1
rm -rf tmp
/src/tools/hyperref-check.sh || exit 1
/src/tools/generate-intrinsics-specs.sh || exit 1
/src/tools/generate-pdfs.sh || exit 1
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ function check_changes() {
# Function that invokes the script to generate the md out of the db
# of the specs.
function generate_specs() {
./tools/pdf/gen-intrinsics-specs.py --intrinsic-defs $1 \
./tools/gen-intrinsics-specs.py --intrinsic-defs $1 \
--classification $2 \
--template $3 --outfile $4 \
--workflow $5
}

# Generate specs
generate_specs ./tools/pdf/intrinsic_db/advsimd.csv \
./tools/pdf/intrinsic_db/advsimd_classification.csv \
generate_specs ./tools/intrinsic_db/advsimd.csv \
./tools/intrinsic_db/advsimd_classification.csv \
./neon_intrinsics/advsimd.template.md \
./tmp/advsimd.new.md \
markdown

generate_specs ./tools/pdf/intrinsic_db/mve.csv \
./tools/pdf/intrinsic_db/mve_classification.csv \
generate_specs ./tools/intrinsic_db/mve.csv \
./tools/intrinsic_db/mve_classification.csv \
./mve_intrinsics/mve.template.md \
./tmp/mve.new.md \
markdown
Expand All @@ -56,14 +56,14 @@ check_changes ./tmp/advsimd.new.md ./neon_intrinsics/advsimd.md
check_changes ./tmp/mve.new.md ./mve_intrinsics/mve.md

# Generate tmp file for pdfs
generate_specs ./tools/pdf/intrinsic_db/mve.csv \
./tools/pdf/intrinsic_db/mve_classification.csv \
generate_specs ./tools/intrinsic_db/mve.csv \
./tools/intrinsic_db/mve_classification.csv \
./mve_intrinsics/mve.template.md \
./tmp/mve.for-pdf.md \
pdf

generate_specs ./tools/pdf/intrinsic_db/advsimd.csv \
./tools/pdf/intrinsic_db/advsimd_classification.csv \
generate_specs ./tools/intrinsic_db/advsimd.csv \
./tools/intrinsic_db/advsimd_classification.csv \
./neon_intrinsics/advsimd.template.md \
./tmp/advsimd.for-pdf.md \
pdf
16 changes: 8 additions & 8 deletions tools/pdf/generate-pdfs.sh → tools/generate-pdfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,16 @@ function generate_pdfs_from_md() {
# in the specific case of the cmse.md file.
sed -u ':a;N;$!ba;s/\*\sTOC\n{*{:toc}}*//' $inputMdFile | \
sed -u "s/<!--latex_geometry_conf-->/$geometryForIntrinsics/" | \
pandoc --template=tools/pdf/acle_template.tex -o $outputPdfFile --resource-path=$(dirname $inputMdFile):.
pandoc --template=tools/acle_template.tex -o $outputPdfFile --resource-path=$(dirname $inputMdFile)
}

mkdir -p output_pdfs tmp
mkdir -p pdfs tmp

# Convert svg image to pdf for use in pdf generation via pandoc.
inkscape Arm_logo_blue_RGB.svg -o tmp/Arm-logo-blue-RGB.pdf
inkscape -z Arm_logo_blue_RGB.svg -e tmp/Arm-logo-blue-RGB.pdf

generate_pdfs_from_md ./cmse/cmse.md ./output_pdfs/cmse.pdf
generate_pdfs_from_md ./morello/morello.md ./output_pdfs/morello.pdf
generate_pdfs_from_md ./main/acle.md ./output_pdfs/acle.pdf
generate_pdfs_from_md ./tmp/mve.for-pdf.md ./output_pdfs/mve.pdf
generate_pdfs_from_md ./tmp/advsimd.for-pdf.md ./output_pdfs/advsimd.pdf
generate_pdfs_from_md ./cmse/cmse.md ./pdfs/cmse.pdf
generate_pdfs_from_md ./morello/morello.md ./pdfs/morello.pdf
generate_pdfs_from_md ./main/acle.md ./pdfs/acle.pdf
generate_pdfs_from_md ./tmp/mve.for-pdf.md ./pdfs/mve.pdf
generate_pdfs_from_md ./tmp/advsimd.for-pdf.md ./pdfs/advsimd.pdf
12 changes: 5 additions & 7 deletions tools/pdf/hyperref-check.sh → tools/hyperref-check.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#!/usr/bin/env bash
# SPDX-FileCopyrightText: Copyright 2021-2023 Arm Limited and/or its affiliates <[email protected]>
# SPDX-FileCopyrightText: Copyright 2021-2022 Arm Limited and/or its affiliates <[email protected]>
# SPDX-License-Identifier: Apache-2.0

set -ex

# Convert svg image to pdf for use in pdf generation via pandoc.
mkdir -p tmp tmp/pdfs
inkscape Arm_logo_blue_RGB.svg -o tmp/Arm-logo-blue-RGB.pdf
mkdir -p pdfs tmp
inkscape -z Arm_logo_blue_RGB.svg -e tmp/Arm-logo-blue-RGB.pdf

# Extracting all broken hyperref detected by PDFTex
for file in "./main/acle.md" "./morello/morello.md" "./mve_intrinsics/mve.md" "./neon_intrinsics/advsimd.md" \
Expand All @@ -17,9 +17,9 @@ for file in "./main/acle.md" "./morello/morello.md" "./mve_intrinsics/mve.md" ".
# - Using tee to output the error and warning messages generated by pandoc pdf conversion into a file
# - Using grep to extract all unresolved links from the file, eg "pdfTeX warning (dest): name{ssec-bf16-scalar}"
# - Using wc to count all the lines and thus all the warnings/detected broken links
pandoc --template=tools/pdf/acle_template.tex $file --verbose -o tmp/pdfs/tmp.pdf --resource-path=$(dirname $file):. 2>&1 | tee tmp/output
pandoc --template=tools/acle_template.tex $file --verbose -o pdfs/tmp.pdf --resource-path=$(dirname $file) 2>&1 | tee tmp/output
number_of_broken_refs=`cat tmp/output | grep 'pdfTeX warning (dest): name' | wc -l`
rm tmp/pdfs/tmp.pdf tmp/output
rm pdfs/tmp.pdf tmp/output

if [[ $number_of_broken_refs -gt 0 ]]; then
echo "**** ERROR! There are $number_of_broken_refs unresolved internal references in $file."
Expand All @@ -28,5 +28,3 @@ for file in "./main/acle.md" "./morello/morello.md" "./mve_intrinsics/mve.md" ".
exit 1
fi
done

rm -rf tmp
File renamed without changes.
File renamed without changes.
File renamed without changes.
19 changes: 0 additions & 19 deletions tools/pdf/docker/Dockerfile

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 5b01857

Please sign in to comment.