diff mbox series

[v2,7/7] docparse: Split into metadata and docparse

Message ID 20211101145342.7166-8-chrubis@suse.cz
State Changes Requested
Headers show
Series docparse improvements | expand

Commit Message

Cyril Hrubis Nov. 1, 2021, 2:53 p.m. UTC
That way the metadata are build and installed unconditionally as they
are going to be integral part of the test execution framework.

The metadata file is also renamed to ltp.json and installed into
$DESTDIR/metadata/ltp.json.

The docparse build is triggered from the metadata Makefile since it has
to be done once the ltp.json is fully generated.

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 Makefile                                      |  5 +---
 docparse/.gitignore                           |  2 --
 docparse/Makefile                             | 12 ++-------
 metadata/.gitignore                           |  2 ++
 metadata/Makefile                             | 26 +++++++++++++++++++
 {docparse => metadata}/data_storage.h         |  0
 docparse/docparse.c => metadata/metaparse.c   |  0
 {docparse => metadata}/parse.sh               |  0
 {docparse => metadata}/tests/Makefile         |  0
 {docparse => metadata}/tests/array_size01.c   |  0
 .../tests/array_size01.c.json                 |  0
 {docparse => metadata}/tests/array_size02.c   |  0
 .../tests/array_size02.c.json                 |  0
 {docparse => metadata}/tests/array_size03.c   |  0
 .../tests/array_size03.c.json                 |  0
 {docparse => metadata}/tests/array_size04.c   |  0
 .../tests/array_size04.c.json                 |  0
 {docparse => metadata}/tests/empty_struct.c   |  0
 .../tests/empty_struct.c.json                 |  0
 {docparse => metadata}/tests/expand_flags.c   |  0
 .../tests/expand_flags.c.json                 |  0
 {docparse => metadata}/tests/include.c        |  0
 {docparse => metadata}/tests/include.c.json   |  0
 {docparse => metadata}/tests/include.h        |  0
 {docparse => metadata}/tests/macro.c          |  0
 {docparse => metadata}/tests/macro.c.json     |  0
 .../tests/multiline_macro.c                   |  0
 .../tests/multiline_macro.c.json              |  0
 {docparse => metadata}/tests/tags.c           |  0
 {docparse => metadata}/tests/tags.c.json      |  0
 {docparse => metadata}/tests/test.sh          |  2 +-
 31 files changed, 32 insertions(+), 17 deletions(-)
 create mode 100644 metadata/.gitignore
 create mode 100644 metadata/Makefile
 rename {docparse => metadata}/data_storage.h (100%)
 rename docparse/docparse.c => metadata/metaparse.c (100%)
 rename {docparse => metadata}/parse.sh (100%)
 rename {docparse => metadata}/tests/Makefile (100%)
 rename {docparse => metadata}/tests/array_size01.c (100%)
 rename {docparse => metadata}/tests/array_size01.c.json (100%)
 rename {docparse => metadata}/tests/array_size02.c (100%)
 rename {docparse => metadata}/tests/array_size02.c.json (100%)
 rename {docparse => metadata}/tests/array_size03.c (100%)
 rename {docparse => metadata}/tests/array_size03.c.json (100%)
 rename {docparse => metadata}/tests/array_size04.c (100%)
 rename {docparse => metadata}/tests/array_size04.c.json (100%)
 rename {docparse => metadata}/tests/empty_struct.c (100%)
 rename {docparse => metadata}/tests/empty_struct.c.json (100%)
 rename {docparse => metadata}/tests/expand_flags.c (100%)
 rename {docparse => metadata}/tests/expand_flags.c.json (100%)
 rename {docparse => metadata}/tests/include.c (100%)
 rename {docparse => metadata}/tests/include.c.json (100%)
 rename {docparse => metadata}/tests/include.h (100%)
 rename {docparse => metadata}/tests/macro.c (100%)
 rename {docparse => metadata}/tests/macro.c.json (100%)
 rename {docparse => metadata}/tests/multiline_macro.c (100%)
 rename {docparse => metadata}/tests/multiline_macro.c.json (100%)
 rename {docparse => metadata}/tests/tags.c (100%)
 rename {docparse => metadata}/tests/tags.c.json (100%)
 rename {docparse => metadata}/tests/test.sh (88%)

Comments

Cyril Hrubis Nov. 1, 2021, 3:14 p.m. UTC | #1
Hi!
> That way the metadata are build and installed unconditionally as they
> are going to be integral part of the test execution framework.
> 
> The metadata file is also renamed to ltp.json and installed into
> $DESTDIR/metadata/ltp.json.
> 
> The docparse build is triggered from the metadata Makefile since it has
> to be done once the ltp.json is fully generated.

I have forgotten to update the parse.sh script, this patch is broken
without:

diff --git a/metadata/parse.sh b/metadata/parse.sh
index 52d9a5cbf..b43d024c6 100755
--- a/metadata/parse.sh
+++ b/metadata/parse.sh
@@ -30,7 +30,7 @@ echo ' "tests": {'
 first=1

 for test in `find testcases/ -name '*.c'`; do
-       a=$($top_builddir/docparse/docparse -Iinclude -Itestcases/kernel/syscalls/utils/ "$test")
+       a=$($top_builddir/metadata/metaparse -Iinclude -Itestcases/kernel/syscalls/utils/ "$test")
        if [ -n "$a" ]; then
                if [ -z "$first" ]; then

Sorry for that.
Petr Vorel Nov. 2, 2021, 3:22 p.m. UTC | #2
Hi Cyril,

> That way the metadata are build and installed unconditionally as they
> are going to be integral part of the test execution framework.

> The metadata file is also renamed to ltp.json and installed into
> $DESTDIR/metadata/ltp.json.

> The docparse build is triggered from the metadata Makefile since it has
> to be done once the ltp.json is fully generated.
While I agree with this, there is a dependency loop. Or am I missing something?

ltp.git/metadata $ make
HOSTCC metadata/metaparse
ltp.git/metadata/parse.sh > ltp.json
ltp.git/metadata/parse.sh: line 33: ltp.git/metadata/../docparse/docparse: No such file or directory
# => OK let's go to docparse and make first

ltp.git/metadata $ cd ../docparse/
ltp.git/docparse $ make
docparse/testinfo.pl ../metadata/ltp.json
'"' expected, at character offset 294 (before "(end of string)") at docparse/testinfo.pl line 461.
# => OK, let's cleanup docparse first

ltp.git/docparse $ cd ../metadata
ltp.git/metadata $ rm -rf *; git reset --hard
ltp.git/metadata $ cd ../docparse/
ltp.git/docparse $ make
make: *** No rule to make target '../metadata/ltp.json', needed by 'txt'.  Stop.
# => huh, dependency loop?

And indeed CI confirms that:
https://github.com/pevik/ltp/actions/runs/1412787433

Kind regards,
Petr
Cyril Hrubis Nov. 2, 2021, 3:28 p.m. UTC | #3
Hi!
> ltp.git/metadata $ make
> HOSTCC metadata/metaparse
> ltp.git/metadata/parse.sh > ltp.json
> ltp.git/metadata/parse.sh: line 33: ltp.git/metadata/../docparse/docparse: No such file or directory
> # => OK let's go to docparse and make first

The docparse build should be triggered from the metadata directory,
since the ltp.json has to be generated first.

But I have forgotten to update the parse.sh script. Have you seen the
reply to this patch?
Petr Vorel Nov. 2, 2021, 3:39 p.m. UTC | #4
> Hi!
> > ltp.git/metadata $ make
> > HOSTCC metadata/metaparse
> > ltp.git/metadata/parse.sh > ltp.json
> > ltp.git/metadata/parse.sh: line 33: ltp.git/metadata/../docparse/docparse: No such file or directory
> > # => OK let's go to docparse and make first

> The docparse build should be triggered from the metadata directory,
> since the ltp.json has to be generated first.

> But I have forgotten to update the parse.sh script. Have you seen the
> reply to this patch?

I see, thx!

Kind regards,
Petr
Cyril Hrubis Nov. 2, 2021, 4:04 p.m. UTC | #5
Hi!
> > > ltp.git/metadata $ make
> > > HOSTCC metadata/metaparse
> > > ltp.git/metadata/parse.sh > ltp.json
> > > ltp.git/metadata/parse.sh: line 33: ltp.git/metadata/../docparse/docparse: No such file or directory
> > > # => OK let's go to docparse and make first
> 
> > The docparse build should be triggered from the metadata directory,
> > since the ltp.json has to be generated first.
> 
> > But I have forgotten to update the parse.sh script. Have you seen the
> > reply to this patch?
> 
> I see, thx!

Also looking at the Makefile it may not work with out-of-tree build, so
we may need this as well:

diff --git a/metadata/Makefile b/metadata/Makefile
index 76a3aed94..9b88d8302 100644
--- a/metadata/Makefile
+++ b/metadata/Makefile
@@ -17,10 +17,10 @@ ltp.json: metaparse

 docparse: ltp.json
 ifeq ($(WITH_METADATA),yes)
-       $(MAKE) -C ../docparse/
+       $(MAKE) -C $(top_srcdir)/docparse/
 endif

 test:
-       $(MAKE) -C tests/ test
+       $(MAKE) -C $(abs_srcdir)/tests/ test

 include $(top_srcdir)/include/mk/generic_leaf_target.mk
Cyril Hrubis Nov. 3, 2021, 11:39 a.m. UTC | #6
Hi!
> Also looking at the Makefile it may not work with out-of-tree build, so
> we may need this as well:
> 
> diff --git a/metadata/Makefile b/metadata/Makefile
> index 76a3aed94..9b88d8302 100644
> --- a/metadata/Makefile
> +++ b/metadata/Makefile
> @@ -17,10 +17,10 @@ ltp.json: metaparse
> 
>  docparse: ltp.json
>  ifeq ($(WITH_METADATA),yes)
> -       $(MAKE) -C ../docparse/
> +       $(MAKE) -C $(top_srcdir)/docparse/
>  endif
> 
>  test:
> -       $(MAKE) -C tests/ test
> +       $(MAKE) -C $(abs_srcdir)/tests/ test
> 
>  include $(top_srcdir)/include/mk/generic_leaf_target.mk

And it's more complex than this, I guess that I will fix the out-of-tree
build send send another version of the patchset.
diff mbox series

Patch

diff --git a/Makefile b/Makefile
index 4e37362f9..63010d531 100644
--- a/Makefile
+++ b/Makefile
@@ -62,10 +62,7 @@  $(1):: | $$(abs_top_builddir)/$$(basename $$(subst -,.,$(1)))
 endif
 endef
 
-COMMON_TARGETS		+= testcases tools
-ifeq ($(WITH_METADATA),yes)
-COMMON_TARGETS		+= docparse
-endif
+COMMON_TARGETS		+= testcases tools metadata
 
 # Don't want to nuke the original files if we're installing in-build-tree.
 ifneq ($(BUILD_TREE_STATE),$(BUILD_TREE_SRCDIR_INSTALL))
diff --git a/docparse/.gitignore b/docparse/.gitignore
index 7a87b4234..d786a4762 100644
--- a/docparse/.gitignore
+++ b/docparse/.gitignore
@@ -1,7 +1,5 @@ 
 /*.txt
 /docbook-xsl.css
-/docparse
-/metadata.json
 /metadata.html
 /metadata.pdf
 /metadata.chunked/
diff --git a/docparse/Makefile b/docparse/Makefile
index e2defad38..ab30efc80 100644
--- a/docparse/Makefile
+++ b/docparse/Makefile
@@ -29,7 +29,6 @@  METADATA_GENERATOR_PARAMS += -v
 endif
 
 CLEAN_TARGETS		:= *.css *.js *.txt
-MAKE_TARGETS		:= metadata.json
 
 ifeq ($(WITH_METADATA_HTML),yes)
 MAKE_TARGETS		+= metadata.html
@@ -42,8 +41,6 @@  ifeq ($(WITH_METADATA_PDF),yes)
 MAKE_TARGETS		+= metadata.pdf
 endif
 
-HOST_MAKE_TARGETS	:= docparse
-
 INSTALL_DIR = metadata
 INSTALL_TARGETS = *.css *.js
 
@@ -51,13 +48,8 @@  ifndef METADATA_GENERATOR
 METADATA_GENERATOR := asciidoctor
 endif
 
-.PHONY: metadata.json
-
-metadata.json: docparse
-	$(abs_srcdir)/parse.sh > metadata.json
-
-txt: metadata.json
-	$(abs_srcdir)/testinfo.pl metadata.json
+txt: ../metadata/ltp.json
+	$(abs_srcdir)/testinfo.pl ../metadata/ltp.json
 
 ifeq ($(WITH_METADATA_HTML),yes)
 metadata.html: txt
diff --git a/metadata/.gitignore b/metadata/.gitignore
new file mode 100644
index 000000000..07d2fd6ff
--- /dev/null
+++ b/metadata/.gitignore
@@ -0,0 +1,2 @@ 
+metaparse
+ltp.json
diff --git a/metadata/Makefile b/metadata/Makefile
new file mode 100644
index 000000000..76a3aed94
--- /dev/null
+++ b/metadata/Makefile
@@ -0,0 +1,26 @@ 
+# SPDX-License-Identifier: GPL-2.0-or-later
+# Copyright (c) 2020 Cyril Hrubis <chrubis@suse.cz>
+
+top_srcdir		?= ..
+
+include $(top_srcdir)/include/mk/env_pre.mk
+include $(top_srcdir)/include/mk/functions.mk
+
+MAKE_TARGETS		:= ltp.json docparse
+HOST_MAKE_TARGETS	:= metaparse
+INSTALL_DIR		= metadata
+
+.PHONY: ltp.json
+
+ltp.json: metaparse
+	$(abs_srcdir)/parse.sh > ltp.json
+
+docparse: ltp.json
+ifeq ($(WITH_METADATA),yes)
+	$(MAKE) -C ../docparse/
+endif
+
+test:
+	$(MAKE) -C tests/ test
+
+include $(top_srcdir)/include/mk/generic_leaf_target.mk
diff --git a/docparse/data_storage.h b/metadata/data_storage.h
similarity index 100%
rename from docparse/data_storage.h
rename to metadata/data_storage.h
diff --git a/docparse/docparse.c b/metadata/metaparse.c
similarity index 100%
rename from docparse/docparse.c
rename to metadata/metaparse.c
diff --git a/docparse/parse.sh b/metadata/parse.sh
similarity index 100%
rename from docparse/parse.sh
rename to metadata/parse.sh
diff --git a/docparse/tests/Makefile b/metadata/tests/Makefile
similarity index 100%
rename from docparse/tests/Makefile
rename to metadata/tests/Makefile
diff --git a/docparse/tests/array_size01.c b/metadata/tests/array_size01.c
similarity index 100%
rename from docparse/tests/array_size01.c
rename to metadata/tests/array_size01.c
diff --git a/docparse/tests/array_size01.c.json b/metadata/tests/array_size01.c.json
similarity index 100%
rename from docparse/tests/array_size01.c.json
rename to metadata/tests/array_size01.c.json
diff --git a/docparse/tests/array_size02.c b/metadata/tests/array_size02.c
similarity index 100%
rename from docparse/tests/array_size02.c
rename to metadata/tests/array_size02.c
diff --git a/docparse/tests/array_size02.c.json b/metadata/tests/array_size02.c.json
similarity index 100%
rename from docparse/tests/array_size02.c.json
rename to metadata/tests/array_size02.c.json
diff --git a/docparse/tests/array_size03.c b/metadata/tests/array_size03.c
similarity index 100%
rename from docparse/tests/array_size03.c
rename to metadata/tests/array_size03.c
diff --git a/docparse/tests/array_size03.c.json b/metadata/tests/array_size03.c.json
similarity index 100%
rename from docparse/tests/array_size03.c.json
rename to metadata/tests/array_size03.c.json
diff --git a/docparse/tests/array_size04.c b/metadata/tests/array_size04.c
similarity index 100%
rename from docparse/tests/array_size04.c
rename to metadata/tests/array_size04.c
diff --git a/docparse/tests/array_size04.c.json b/metadata/tests/array_size04.c.json
similarity index 100%
rename from docparse/tests/array_size04.c.json
rename to metadata/tests/array_size04.c.json
diff --git a/docparse/tests/empty_struct.c b/metadata/tests/empty_struct.c
similarity index 100%
rename from docparse/tests/empty_struct.c
rename to metadata/tests/empty_struct.c
diff --git a/docparse/tests/empty_struct.c.json b/metadata/tests/empty_struct.c.json
similarity index 100%
rename from docparse/tests/empty_struct.c.json
rename to metadata/tests/empty_struct.c.json
diff --git a/docparse/tests/expand_flags.c b/metadata/tests/expand_flags.c
similarity index 100%
rename from docparse/tests/expand_flags.c
rename to metadata/tests/expand_flags.c
diff --git a/docparse/tests/expand_flags.c.json b/metadata/tests/expand_flags.c.json
similarity index 100%
rename from docparse/tests/expand_flags.c.json
rename to metadata/tests/expand_flags.c.json
diff --git a/docparse/tests/include.c b/metadata/tests/include.c
similarity index 100%
rename from docparse/tests/include.c
rename to metadata/tests/include.c
diff --git a/docparse/tests/include.c.json b/metadata/tests/include.c.json
similarity index 100%
rename from docparse/tests/include.c.json
rename to metadata/tests/include.c.json
diff --git a/docparse/tests/include.h b/metadata/tests/include.h
similarity index 100%
rename from docparse/tests/include.h
rename to metadata/tests/include.h
diff --git a/docparse/tests/macro.c b/metadata/tests/macro.c
similarity index 100%
rename from docparse/tests/macro.c
rename to metadata/tests/macro.c
diff --git a/docparse/tests/macro.c.json b/metadata/tests/macro.c.json
similarity index 100%
rename from docparse/tests/macro.c.json
rename to metadata/tests/macro.c.json
diff --git a/docparse/tests/multiline_macro.c b/metadata/tests/multiline_macro.c
similarity index 100%
rename from docparse/tests/multiline_macro.c
rename to metadata/tests/multiline_macro.c
diff --git a/docparse/tests/multiline_macro.c.json b/metadata/tests/multiline_macro.c.json
similarity index 100%
rename from docparse/tests/multiline_macro.c.json
rename to metadata/tests/multiline_macro.c.json
diff --git a/docparse/tests/tags.c b/metadata/tests/tags.c
similarity index 100%
rename from docparse/tests/tags.c
rename to metadata/tests/tags.c
diff --git a/docparse/tests/tags.c.json b/metadata/tests/tags.c.json
similarity index 100%
rename from docparse/tests/tags.c.json
rename to metadata/tests/tags.c.json
diff --git a/docparse/tests/test.sh b/metadata/tests/test.sh
similarity index 88%
rename from docparse/tests/test.sh
rename to metadata/tests/test.sh
index 767cc464c..c11f0e496 100755
--- a/docparse/tests/test.sh
+++ b/metadata/tests/test.sh
@@ -3,7 +3,7 @@ 
 fail=0
 
 for i in *.c; do
-	../docparse $i > tmp.json
+	../metaparse $i > tmp.json
 	if ! diff tmp.json $i.json &> /dev/null; then
 		echo "***"
 		echo "$i output differs!"