-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
231 lines (189 loc) · 10.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
#
# Copyright 2021-2022 PDF Association, Inc. https://www.pdfa.org
#
# This material is based upon work supported by the Defense Advanced
# Research Projects Agency (DARPA) under Contract No. HR001119C0079.
# Any opinions, findings and conclusions or recommendations expressed
# in this material are those of the author(s) and do not necessarily
# reflect the views of the Defense Advanced Research Projects Agency
# (DARPA). Approved for public release.
#
# SPDX-License-Identifier: Apache-2.0
# Contributors: Peter Wyatt, PDF Association
#
# A simple makefile to automate some repetitive tasks.
# May require copying dylibs, etc to well known locations on some platforms
#
# First, manually build one of TestGrammar PoC apps (PDFix is fastest):
# $ make TestGrammar-pdfix OR
# $ make TestGrammar-pdfium OR
# $ make TestGrammar-qpdf
#
# Then:
# $ make clean
# $ make tsv
# $ make validate
# $ make 3d
# $ make xml
# $ make pandas <-- Optional, this file is not GitHub!
#
XMLLINT ::= xmllint
XMLLINT_FLAGS ::= --noout
# Clean up all outputs that can be re-created
.PHONY: clean
clean:
rm -rf ./3dvisualize/*.json ./xml/*.xml ./scripts/*.tsv
rm -rf ./tsv/1.?/*.tsv ./tsv/2.0/*.tsv
rm -rf ./gcxml/dist/gcxml.jar
rm -rf /TestGrammar/doc
# Make the monolithic TSV file by combining all TSVs - suitable for Jupyter
.PHONY: pandas
pandas:
python3 ./scripts/arlington-to-pandas.py --tsvdir ./tsv/latest --save ./scripts/pandas.tsv
# Make the 3D/VR visualization JSON files (all versions)
# Ensure to do a "make tsv" beforehand to refresh the PDF version specific file sets!
.PHONY: 3d
3d:
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/latest --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/2.0 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.7 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.6 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.5 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.4 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.3 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.2 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.1 --outdir ./3dvisualize/
python3 ./3dvisualize/TSVto3D.py --tsvdir ./tsv/1.0 --outdir ./3dvisualize/
# Build the TestGrammar C++ PoC app using PDFix (because build times are much faster)
.PHONY: TestGrammar-pdfix
TestGrammar-pdfix:
rm -rf ./TestGrammar/bin/linux/TestGrammar ./TestGrammar/bin/linux/TestGrammar_d
rm -rf ./TestGrammar/cmake-linux
cmake -B ./TestGrammar/cmake-linux/debug -DPDFSDK_PDFIX=ON -DCMAKE_BUILD_TYPE=Debug ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/debug --config Debug
cmake -B ./TestGrammar/cmake-linux/release -DPDFSDK_PDFIX=ON -DCMAKE_BUILD_TYPE=Release ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/release --config Release
rm -rf ./TestGrammar/cmake-linux
# Build the TestGrammar C++ PoC app using PDFIUM (SLOW!)
.PHONY: TestGrammar-pdfium
TestGrammar-pdfium:
rm -rf ./TestGrammar/bin/linux/TestGrammar ./TestGrammar/bin/linux/TestGrammar_d
rm -rf ./TestGrammar/cmake-linux
cmake -B ./TestGrammar/cmake-linux/debug -DPDFSDK_PDFIUM=ON -DCMAKE_BUILD_TYPE=Debug ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/debug --config Debug
cmake -B ./TestGrammar/cmake-linux/release -DPDFSDK_PDFIUM=ON -DCMAKE_BUILD_TYPE=Release ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/release --config Release
rm -rf ./TestGrammar/cmake-linux
# Build the TestGrammar C++ PoC app using QPDF (not functional yet!)
.PHONY: TestGrammar-qpdf
TestGrammar-qpdf:
rm -rf ./TestGrammar/bin/linux/TestGrammar ./TestGrammar/bin/linux/TestGrammar_d
rm -rf ./TestGrammar/cmake-linux
cmake -B ./TestGrammar/cmake-linux/debug -DPDFSDK_QPDF=ON -DCMAKE_BUILD_TYPE=Debug ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/debug --config Debug
cmake -B ./TestGrammar/cmake-linux/release -DPDFSDK_QPDF=ON -DCMAKE_BUILD_TYPE=Release ./TestGrammar
cmake --build ./TestGrammar/cmake-linux/release --config Release
rm -rf ./TestGrammar/cmake-linux
# Validate each of the existing TSV file sets using both the Python script and C++ PoC.
# Does NOT create the TSVs!
# Ensure to do a "make tsv" beforehand to refresh the PDF version specific file sets!
validate:
# Clean-up where gcxml is missing some capabilities...
rm -f ./tsv/1.3/ActionNOP.tsv ./tsv/1.3/ActionSetState.tsv
rm -f ./tsv/1.4/ActionNOP.tsv ./tsv/1.4/ActionSetState.tsv
rm -f ./tsv/1.5/ActionNOP.tsv ./tsv/1.5/ActionSetState.tsv
rm -f ./tsv/1.6/ActionNOP.tsv ./tsv/1.6/ActionSetState.tsv
rm -f ./tsv/1.7/ActionNOP.tsv ./tsv/1.7/ActionSetState.tsv
rm -f ./tsv/2.0/ActionNOP.tsv ./tsv/2.0/ActionSetState.tsv
mv ./tsv/1.4/XObjectImage.tsv ./tsv/1.4/XObjectImage-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsPresent\(\@SMaskInData>0\)\)\]//g' ./tsv/1.4/XObjectImage-BEFORE.tsv > ./tsv/1.4/XObjectImage.tsv
rm ./tsv/1.4/XObjectImage-BEFORE.tsv
mv ./tsv/1.3/AnnotStamp.tsv ./tsv/1.3/AnnotStamp-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsRequired\(fn\:IsPresent\(IT\) && \(\@IT!=Stamp\)\)\)\]//g' ./tsv/1.3/AnnotStamp-BEFORE.tsv > ./tsv/1.3/AnnotStamp.tsv
rm ./tsv/1.3/AnnotStamp-BEFORE.tsv
mv ./tsv/1.4/AnnotStamp.tsv ./tsv/1.4/AnnotStamp-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsRequired\(fn\:IsPresent\(IT\) && \(\@IT!=Stamp\)\)\)\]//g' ./tsv/1.4/AnnotStamp-BEFORE.tsv > ./tsv/1.4/AnnotStamp.tsv
rm ./tsv/1.4/AnnotStamp-BEFORE.tsv
mv ./tsv/1.5/AnnotStamp.tsv ./tsv/1.5/AnnotStamp-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsRequired\(fn\:IsPresent\(IT\) && \(\@IT!=Stamp\)\)\)\]//g' ./tsv/1.5/AnnotStamp-BEFORE.tsv > ./tsv/1.5/AnnotStamp.tsv
rm ./tsv/1.5/AnnotStamp-BEFORE.tsv
mv ./tsv/1.6/AnnotStamp.tsv ./tsv/1.6/AnnotStamp-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsRequired\(fn\:IsPresent\(IT\) && \(\@IT!=Stamp\)\)\)\]//g' ./tsv/1.6/AnnotStamp-BEFORE.tsv > ./tsv/1.6/AnnotStamp.tsv
rm ./tsv/1.6/AnnotStamp-BEFORE.tsv
mv ./tsv/1.7/AnnotStamp.tsv ./tsv/1.7/AnnotStamp-BEFORE.tsv
sed -E 's/\[fn\:Not\(fn\:IsRequired\(fn\:IsPresent\(IT\) && \(\@IT!=Stamp\)\)\)\]//g' ./tsv/1.7/AnnotStamp-BEFORE.tsv > ./tsv/1.7/AnnotStamp.tsv
rm ./tsv/1.7/AnnotStamp-BEFORE.tsv
mv ./tsv/1.3/DeviceNDict.tsv ./tsv/1.3/DeviceNDict-BEFORE.tsv
sed -E 's/fn:IsRequired\(fn:SinceVersion\(1.6,\(@Subtype==NChannel\)\) && fn:HasSpotColorants\(parent::1\)\)/FALSE/g' ./tsv/1.3/DeviceNDict-BEFORE.tsv > ./tsv/1.3/DeviceNDict.tsv
rm ./tsv/1.3/DeviceNDict-BEFORE.tsv
mv ./tsv/1.4/DeviceNDict.tsv ./tsv/1.4/DeviceNDict-BEFORE.tsv
sed -E 's/fn:IsRequired\(fn:SinceVersion\(1.6,\(@Subtype==NChannel\)\) && fn:HasSpotColorants\(parent::1\)\)/FALSE/g' ./tsv/1.4/DeviceNDict-BEFORE.tsv > ./tsv/1.4/DeviceNDict.tsv
rm ./tsv/1.4/DeviceNDict-BEFORE.tsv
mv ./tsv/1.5/DeviceNDict.tsv ./tsv/1.5/DeviceNDict-BEFORE.tsv
sed -E 's/fn:IsRequired\(fn:SinceVersion\(1.6,\(@Subtype==NChannel\)\) && fn:HasSpotColorants\(parent::1\)\)/FALSE/g' ./tsv/1.5/DeviceNDict-BEFORE.tsv > ./tsv/1.5/DeviceNDict.tsv
rm ./tsv/1.5/DeviceNDict-BEFORE.tsv
mv ./tsv/1.1/Transition.tsv ./tsv/1.1/Transition-BEFORE.tsv
sed -E 's/ && fn:SinceVersion\(1.5,\(@SS!=1.0\)\)//g' ./tsv/1.1/Transition-BEFORE.tsv > ./tsv/1.1/Transition.tsv
rm ./tsv/1.1/Transition-BEFORE.tsv
mv ./tsv/1.2/Transition.tsv ./tsv/1.2/Transition-BEFORE.tsv
sed -E 's/ && fn:SinceVersion\(1.5,\(@SS!=1.0\)\)//g' ./tsv/1.2/Transition-BEFORE.tsv > ./tsv/1.2/Transition.tsv
rm ./tsv/1.2/Transition-BEFORE.tsv
mv ./tsv/1.3/Transition.tsv ./tsv/1.3/Transition-BEFORE.tsv
sed -E 's/ && fn:SinceVersion\(1.5,\(@SS!=1.0\)\)//g' ./tsv/1.3/Transition-BEFORE.tsv > ./tsv/1.3/Transition.tsv
rm ./tsv/1.3/Transition-BEFORE.tsv
mv ./tsv/1.4/Transition.tsv ./tsv/1.4/Transition-BEFORE.tsv
sed -E 's/ && fn:SinceVersion\(1.5,\(@SS!=1.0\)\)//g' ./tsv/1.4/Transition-BEFORE.tsv > ./tsv/1.4/Transition.tsv
rm ./tsv/1.4/Transition-BEFORE.tsv
mv ./tsv/1.3/AnnotStamp.tsv ./tsv/1.3/AnnotStamp-BEFORE.tsv
sed -E 's/ && \(@IT!=Stamp\)//g' ./tsv/1.3/AnnotStamp-BEFORE.tsv > ./tsv/1.3/AnnotStamp.tsv
rm ./tsv/1.3/AnnotStamp-BEFORE.tsv
mv ./tsv/1.4/AnnotStamp.tsv ./tsv/1.4/AnnotStamp-BEFORE.tsv
sed -E 's/ && \(@IT!=Stamp\)//g' ./tsv/1.4/AnnotStamp-BEFORE.tsv > ./tsv/1.4/AnnotStamp.tsv
rm ./tsv/1.4/AnnotStamp-BEFORE.tsv
mv ./tsv/1.5/AnnotStamp.tsv ./tsv/1.5/AnnotStamp-BEFORE.tsv
sed -E 's/ && \(@IT!=Stamp\)//g' ./tsv/1.5/AnnotStamp-BEFORE.tsv > ./tsv/1.5/AnnotStamp.tsv
rm ./tsv/1.5/AnnotStamp-BEFORE.tsv
mv ./tsv/1.6/AnnotStamp.tsv ./tsv/1.6/AnnotStamp-BEFORE.tsv
sed -E 's/ && \(@IT!=Stamp\)//g' ./tsv/1.6/AnnotStamp-BEFORE.tsv > ./tsv/1.6/AnnotStamp.tsv
rm ./tsv/1.6/AnnotStamp-BEFORE.tsv
mv ./tsv/1.7/AnnotStamp.tsv ./tsv/1.7/AnnotStamp-BEFORE.tsv
sed -E 's/ && \(@IT!=Stamp\)//g' ./tsv/1.7/AnnotStamp-BEFORE.tsv > ./tsv/1.7/AnnotStamp.tsv
rm ./tsv/1.7/AnnotStamp-BEFORE.tsv
mv ./tsv/1.4/XObjectImage.tsv ./tsv/1.4/XObjectImage-BEFORE.tsv
sed -E 's/\[fn:SinceVersion\(1.5,fn:Not\(fn:IsPresent\(@SMaskInData>0\)\)\)\]//g' ./tsv/1.4/XObjectImage-BEFORE.tsv > ./tsv/1.4/XObjectImage.tsv
rm ./tsv/1.4/XObjectImage-BEFORE.tsv
TestGrammar --tsvdir ./tsv/1.0/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.0/ --validate
TestGrammar --tsvdir ./tsv/1.1/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.1/ --validate
TestGrammar --tsvdir ./tsv/1.2/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.2/ --validate
TestGrammar --tsvdir ./tsv/1.3/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.3/ --validate
TestGrammar --tsvdir ./tsv/1.4/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.4/ --validate
TestGrammar --tsvdir ./tsv/1.5/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.5/ --validate
TestGrammar --tsvdir ./tsv/1.6/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.6/ --validate
TestGrammar --tsvdir ./tsv/1.7/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/1.7/ --validate
TestGrammar --tsvdir ./tsv/2.0/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/2.0/ --validate
TestGrammar --tsvdir ./tsv/latest/ --validate
python3 ./scripts/arlington.py --tsvdir ./tsv/latest/ --validate
# Create all TSV file sets for each PDF version based on tsv/latest using Java PoC app. SLOW!
.PHONY: tsv
tsv: ./gcxml/dist/Gcxml.jar
java -jar ./gcxml/dist/Gcxml.jar -tsv
# Make the Java PoC app, run it and then validate the generated XML
xml: ./xml/pdf_grammar1.0.xml ./xml/pdf_grammar1.1.xml ./xml/pdf_grammar1.2.xml ./xml/pdf_grammar1.3.xml \
./xml/pdf_grammar1.4.xml ./xml/pdf_grammar1.5.xml ./xml/pdf_grammar1.6.xml ./xml/pdf_grammar1.7.xml ./xml/pdf_grammar2.0.xml
${XMLLINT} ${XMLLINT_FLAGS} --schema ./xml/schema/arlington-pdf.xsd $?
# Create and validate XML files for each PDF version based on tsv/latest using the Java PoC app. SLOW!
xml/%.xml: ./gcxml/dist/Gcxml.jar
echo "Creating XML: $(strip $(subst xml/pdf_grammar,,$(subst .xml,,$@)))"
java -jar ./gcxml/dist/Gcxml.jar -xml $(strip $(subst xml/pdf_grammar,,$(subst .xml,,$@)))
# Build the Java proof-of-concept application using "ant"
./gcxml/dist/Gcxml.jar:
( cd gcxml ; ant ; cd .. )