Skip to content

Commit 4b61483

Browse files
committed
Change transitive imports management
This patch applies and adapts the effects of UCO-Profile-Example PR 4. A follow-on patch will regenerate Make-managed files. References: * ucoProject/UCO-Profile-Example#4 Signed-off-by: Alex Nelson <alexander.nelson@nist.gov>
1 parent 5dd0b75 commit 4b61483

15 files changed

Lines changed: 253 additions & 237 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@
44
.venv-pre-commit
55
_*.*
66
__pycache__
7+
generated-*
78
venv

Makefile

Lines changed: 54 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,27 @@ PYTHON3 ?= python3
2020

2121
all: \
2222
.venv-pre-commit/var/.pre-commit-built.log \
23-
all-ontology \
24-
all-shapes
23+
all-shapes \
24+
all-tests
2525

2626
.PHONY: \
2727
all-dependencies \
2828
all-ontology \
2929
all-shapes \
30+
all-tests \
3031
check-dependencies \
3132
check-mypy \
3233
check-ontology \
3334
check-shapes \
3435
check-supply-chain \
3536
check-supply-chain-cdo-profile \
3637
check-supply-chain-pre-commit \
37-
check-supply-chain-submodules
38+
check-supply-chain-submodules \
39+
check-tests \
40+
clean-dependencies \
41+
clean-ontology \
42+
clean-shapes \
43+
clean-tests
3844

3945
# This Make target should be left in place, even if it does nothing. It
4046
# has been found beneficial with profiles that have a submodule-based
@@ -53,7 +59,7 @@ all: \
5359
# profile builds on a UCO profile.
5460
$(MAKE) \
5561
--directory dependencies/UCO-Profile-Example \
56-
.git_submodule_init_imports.done.log
62+
.git_submodule_init.done.log
5763
$(MAKE) \
5864
--directory dependencies/CASE \
5965
.git_submodule_init.done.log \
@@ -103,33 +109,28 @@ all-dependencies: \
103109
.git_submodule_init.done.log \
104110
.venv.done.log
105111
$(MAKE) \
112+
PYTHON3=$(PYTHON3) \
106113
--directory dependencies
107114

108115
all-ontology: \
109116
all-dependencies
110117
$(MAKE) \
111118
--directory ontology
112119

113-
# NOTE: For profiles that don't include shapes, the $(top_srcdir)/shapes
114-
# directory might be missing. Checking for its existence first relieves
115-
# each profile of needing to modify the top Makefile when removing
116-
# shapes.
117120
all-shapes: \
118-
all-dependencies
119-
test ! -d shapes \
120-
|| $(MAKE) \
121-
--directory shapes
121+
all-ontology
122+
$(MAKE) \
123+
--directory shapes
124+
125+
all-tests: \
126+
all-ontology
127+
$(MAKE) \
128+
--directory tests
122129

123130
check: \
124131
.venv-pre-commit/var/.pre-commit-built.log \
125132
check-mypy \
126-
check-dependencies \
127-
check-ontology \
128-
check-shapes
129-
$(MAKE) \
130-
PYTHON3=$(PYTHON3) \
131-
--directory tests \
132-
check
133+
check-tests
133134

134135
check-dependencies: \
135136
all-dependencies
@@ -147,21 +148,18 @@ check-mypy: \
147148
.
148149

149150
check-ontology: \
150-
all-ontology
151+
all-ontology \
152+
check-dependencies
151153
$(MAKE) \
152154
--directory ontology \
153155
check
154156

155-
# NOTE: For profiles that don't include shapes, the $(top_srcdir)/shapes
156-
# directory might be missing. Checking for its existence first relieves
157-
# each profile of needing to modify the top Makefile when removing
158-
# shapes.
159157
check-shapes: \
160-
all-shapes
161-
test ! -d shapes \
162-
|| $(MAKE) \
163-
--directory shapes \
164-
check
158+
all-shapes \
159+
check-ontology
160+
$(MAKE) \
161+
--directory shapes \
162+
check
165163

166164
# This target's dependencies potentially modify the working directory's
167165
# Git state, so it is intentionally not a dependency of check.
@@ -228,19 +226,37 @@ check-supply-chain-submodules: \
228226
--ignore-submodules=dirty \
229227
dependencies
230228

231-
clean:
232-
@$(MAKE) \
229+
check-tests: \
230+
all-tests \
231+
check-shapes
232+
$(MAKE) \
233233
--directory tests \
234+
check
235+
236+
clean: \
237+
clean-tests \
238+
clean-shapes \
239+
clean-ontology \
240+
clean-dependencies
241+
@rm -f \
242+
.*.done.log
243+
244+
clean-dependencies:
245+
@$(MAKE) \
246+
--directory dependencies \
234247
clean
235-
@test ! -d shapes \
236-
|| $(MAKE) \
237-
--directory shapes \
238-
clean
248+
249+
clean-ontology:
239250
@$(MAKE) \
240251
--directory ontology \
241252
clean
253+
254+
clean-shapes:
242255
@$(MAKE) \
243-
--directory dependencies \
256+
--directory shapes \
257+
clean
258+
259+
clean-tests:
260+
@$(MAKE) \
261+
--directory tests \
244262
clean
245-
@rm -f \
246-
.*.done.log

dependencies/Makefile

Lines changed: 13 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -16,71 +16,26 @@
1616

1717
SHELL := /bin/bash
1818

19-
top_srcdir := $(shell cd .. ; pwd)
19+
PYTHON3 ?= python3
2020

2121
case_srcdir := CASE
2222

23-
uco_srcdir := $(case_srcdir)/dependencies/UCO
24-
25-
RDF_TOOLKIT_JAR := $(uco_srcdir)/lib/rdf-toolkit.jar
26-
2723
all: \
28-
catalog-v001.xml
24+
$(case_srcdir)/tests/case_monolithic.ttl
2925

30-
$(RDF_TOOLKIT_JAR):
31-
@echo "DEBUG:dependencies/Makefile:top_srcdir=$(top_srcdir)" >&2
32-
@echo "ERROR:dependencies/Makefile:rdf-toolkit.jar not found. Did you run `make` from the top source directory?" >&2
33-
@test -r $@
26+
$(case_srcdir)/.venv.done.log:
27+
$(MAKE) \
28+
PYTHON3=$(PYTHON3) \
29+
--directory $(case_srcdir) \
30+
.venv.done.log
3431

35-
catalog-v001.xml: \
36-
$(case_srcdir)/ontology/master/catalog-v001.xml \
37-
$(top_srcdir)/.venv.done.log \
38-
$(top_srcdir)/etc/domain_directories.tsv \
39-
$(top_srcdir)/etc/dependency_files.tsv \
40-
$(uco_srcdir)/src/create-catalog-v001.xml.py \
41-
imports-transitive.ttl
42-
rm -f _$@
43-
source $(top_srcdir)/venv/bin/activate \
44-
&& python3 $(uco_srcdir)/src/create-catalog-v001.xml.py \
45-
--catalog-xml $(case_srcdir)/ontology/master/catalog-v001.xml \
46-
_$@ \
47-
$(top_srcdir)/etc/domain_directories.tsv \
48-
$(top_srcdir)/etc/dependency_files.tsv \
49-
"$(top_srcdir)" \
50-
imports-transitive.ttl
51-
mv _$@ $@
32+
$(case_srcdir)/tests/case_monolithic.ttl: \
33+
$(case_srcdir)/.venv.done.log
34+
$(MAKE) \
35+
--directory $(case_srcdir)/tests \
36+
case_monolithic.ttl
5237

5338
check: \
54-
catalog-v001.xml
39+
all
5540

56-
# TODO: This recipe deletes files generated by Make. The line deleting
57-
# example.ttl should be adapted.
5841
clean:
59-
@rm -f \
60-
catalog-v001.xml \
61-
imports-transitive.ttl
62-
63-
# This recipe intentionally does not incorporate CDO ontologies (UCO,
64-
# CASE, etc.), to avoid redundant imports between multiple profiles.
65-
# TODO: Adapt this recipe to depend instead on the normalized file, as
66-
# well as any profile submodules' imports-transitive files.
67-
# Note that the piping command, analagous to the concatenate ('cat')
68-
# command but for RDF graph files, will combine all recipe dependencies
69-
# into one file, using the $^ ("all dependencies") Make variable.
70-
imports-transitive.ttl: \
71-
UCO-Profile-Example/dependencies/example.ttl \
72-
UCO-Profile-Example/dependencies/imports-transitive.ttl \
73-
UCO-Profile-Example/ontology/uco-example.ttl
74-
source $(top_srcdir)/venv/bin/activate \
75-
&& rdfpipe \
76-
--output-format turtle \
77-
$^ \
78-
> __$@
79-
java -jar $(RDF_TOOLKIT_JAR) \
80-
--inline-blank-nodes \
81-
--source __$@ \
82-
--source-format turtle \
83-
--target _$@ \
84-
--target-format turtle
85-
rm __$@
86-
mv _$@ $@

dependencies/catalog-v001.xml

Lines changed: 0 additions & 26 deletions
This file was deleted.

dependencies/imports-transitive.ttl

Lines changed: 0 additions & 32 deletions
This file was deleted.

etc/dependency_files.tsv

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
http://example.org/ontology/example/0.0.1 ${top_srcdir}/dependencies/UCO-Profile-Example/dependencies/example.ttl
1+
http://example.org/ontology/example/0.0.1 ${top_srcdir}/dependencies/UCO-Profile-Example/dependencies/CDO-Shapes-Example/dependencies/formatted-example.ttl
22
http://example.org/ontology/uco-example ${top_srcdir}/dependencies/UCO-Profile-Example/ontology/uco-example.ttl
33
http://example.org/shapes/sh-case-example ${top_srcdir}/shapes/sh-case-example.ttl
4+
http://example.org/shapes/sh-example ${top_srcdir}/dependencies/UCO-Profile-Example/dependencies/CDO-Shapes-Example/shapes/sh-example.ttl
45
http://example.org/shapes/sh-uco-example ${top_srcdir}/dependencies/UCO-Profile-Example/shapes/sh-uco-example.ttl

ontology/.empty.ttl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
@prefix owl: <http://www.w3.org/2002/07/owl#> .
2+
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
3+
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
4+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
5+

0 commit comments

Comments
 (0)