To be able to check for the existence of the necessary subsections in
the documentation for MISRA C:2012 Dir 4.1, ECLAIR needs to have a source
file that is built.
This file is generated from 'C-runtime-failures.rst' in docs/misra
and the configuration is updated accordingly.
Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
Changes from RFC:
- Dropped unused/useless code
- Revised the sed command
- Revised the clean target
---
docs/Makefile | 7 ++++++-
docs/misra/Makefile | 17 +++++++++++++++++
2 files changed, 23 insertions(+), 1 deletion(-)
create mode 100644 docs/misra/Makefile
diff --git a/docs/Makefile b/docs/Makefile
index 966a104490ac..ff991a0c3ca2 100644
--- a/docs/Makefile
+++ b/docs/Makefile
@@ -43,7 +43,7 @@ DOC_PDF := $(patsubst %.pandoc,pdf/%.pdf,$(PANDOCSRC-y)) \
all: build
.PHONY: build
-build: html txt pdf man-pages figs
+build: html txt pdf man-pages figs misra
.PHONY: sphinx-html
sphinx-html:
@@ -66,9 +66,14 @@ endif
.PHONY: pdf
pdf: $(DOC_PDF)
+.PHONY: misra
+misra:
+ $(MAKE) -C misra
+
.PHONY: clean
clean: clean-man-pages
$(MAKE) -C figs clean
+ $(MAKE) -C misra clean
rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~
rm -rf *.ilg *.log *.ind *.toc *.bak *.tmp core
rm -rf html txt pdf sphinx/html
diff --git a/docs/misra/Makefile b/docs/misra/Makefile
new file mode 100644
index 000000000000..8ea0505c8a20
--- /dev/null
+++ b/docs/misra/Makefile
@@ -0,0 +1,17 @@
+TARGETS := C-runtime-failures.o
+
+all: $(TARGETS)
+
+# sed is used in place of cat to prevent occurrences of '*/'
+# in the .rst from breaking the compilation
+$(TARGETS:.o=.c): %.c: %.rst
+ echo "/*\n" > $@.tmp
+ sed -e 's|\*/|*//*|g' $< >> $@.tmp
+ echo "\n*/" >> $@.tmp
+ mv $@.tmp $@
+
+%.o: %.c
+ $(CC) -c $< -o $@
+
+clean:
+ rm -f C-runtime-failures.c *.o *.tmp
--
2.34.1
On Fri, Sep 01, 2023 at 11:06:39AM +0200, Nicola Vetrini wrote:
> diff --git a/docs/misra/Makefile b/docs/misra/Makefile
> new file mode 100644
> index 000000000000..8ea0505c8a20
> --- /dev/null
> +++ b/docs/misra/Makefile
> @@ -0,0 +1,17 @@
> +TARGETS := C-runtime-failures.o
> +
> +all: $(TARGETS)
> +
> +# sed is used in place of cat to prevent occurrences of '*/'
> +# in the .rst from breaking the compilation
> +$(TARGETS:.o=.c): %.c: %.rst
> + echo "/*\n" > $@.tmp
This doesn't really works as you expect. Depending on the shell used or
the echo binary used, the "\n" would write a <new-line> or justs "\n".
Bash just write "\n" for example, while dash does write a <new-line>.
But, you can use `printf` instead:
printf "/*\n\n" > $@.tmp
> + sed -e 's|\*/|*//*|g' $< >> $@.tmp
> + echo "\n*/" >> $@.tmp
Same here.
Thanks,
--
Anthony PERARD
On 08/09/2023 13:04, Anthony PERARD wrote: > On Fri, Sep 01, 2023 at 11:06:39AM +0200, Nicola Vetrini wrote: >> diff --git a/docs/misra/Makefile b/docs/misra/Makefile >> new file mode 100644 >> index 000000000000..8ea0505c8a20 >> --- /dev/null >> +++ b/docs/misra/Makefile >> @@ -0,0 +1,17 @@ >> +TARGETS := C-runtime-failures.o >> + >> +all: $(TARGETS) >> + >> +# sed is used in place of cat to prevent occurrences of '*/' >> +# in the .rst from breaking the compilation >> +$(TARGETS:.o=.c): %.c: %.rst >> + echo "/*\n" > $@.tmp > > This doesn't really works as you expect. Depending on the shell used or > the echo binary used, the "\n" would write a <new-line> or justs "\n". > Bash just write "\n" for example, while dash does write a <new-line>. > But, you can use `printf` instead: > printf "/*\n\n" > $@.tmp > >> + sed -e 's|\*/|*//*|g' $< >> $@.tmp >> + echo "\n*/" >> $@.tmp > > Same here. > > Thanks, I'll fix it in the next version. -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
On Fri, 1 Sep 2023, Nicola Vetrini wrote: > To be able to check for the existence of the necessary subsections in > the documentation for MISRA C:2012 Dir 4.1, ECLAIR needs to have a source > file that is built. > > This file is generated from 'C-runtime-failures.rst' in docs/misra > and the configuration is updated accordingly. > > Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com> > --- > Changes from RFC: > - Dropped unused/useless code > - Revised the sed command > - Revised the clean target > --- > docs/Makefile | 7 ++++++- > docs/misra/Makefile | 17 +++++++++++++++++ > 2 files changed, 23 insertions(+), 1 deletion(-) > create mode 100644 docs/misra/Makefile > > diff --git a/docs/Makefile b/docs/Makefile > index 966a104490ac..ff991a0c3ca2 100644 > --- a/docs/Makefile > +++ b/docs/Makefile > @@ -43,7 +43,7 @@ DOC_PDF := $(patsubst %.pandoc,pdf/%.pdf,$(PANDOCSRC-y)) \ > all: build > > .PHONY: build > -build: html txt pdf man-pages figs > +build: html txt pdf man-pages figs misra > > .PHONY: sphinx-html > sphinx-html: > @@ -66,9 +66,14 @@ endif > .PHONY: pdf > pdf: $(DOC_PDF) > > +.PHONY: misra > +misra: > + $(MAKE) -C misra > + > .PHONY: clean > clean: clean-man-pages > $(MAKE) -C figs clean > + $(MAKE) -C misra clean > rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ > rm -rf *.ilg *.log *.ind *.toc *.bak *.tmp core > rm -rf html txt pdf sphinx/html > diff --git a/docs/misra/Makefile b/docs/misra/Makefile > new file mode 100644 > index 000000000000..8ea0505c8a20 > --- /dev/null > +++ b/docs/misra/Makefile > @@ -0,0 +1,17 @@ > +TARGETS := C-runtime-failures.o > + > +all: $(TARGETS) > + > +# sed is used in place of cat to prevent occurrences of '*/' > +# in the .rst from breaking the compilation Please expand this comment with what you are doing in this makefile and specifically what kind of .c file you are generating and why. Everything else looks good. > +$(TARGETS:.o=.c): %.c: %.rst > + echo "/*\n" > $@.tmp > + sed -e 's|\*/|*//*|g' $< >> $@.tmp > + echo "\n*/" >> $@.tmp > + mv $@.tmp $@ > + > +%.o: %.c > + $(CC) -c $< -o $@ > + > +clean: > + rm -f C-runtime-failures.c *.o *.tmp > -- > 2.34.1 >
On 08/09/2023 02:23, Stefano Stabellini wrote: > On Fri, 1 Sep 2023, Nicola Vetrini wrote: >> To be able to check for the existence of the necessary subsections in >> the documentation for MISRA C:2012 Dir 4.1, ECLAIR needs to have a >> source >> file that is built. >> >> This file is generated from 'C-runtime-failures.rst' in docs/misra >> and the configuration is updated accordingly. >> >> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com> >> --- >> Changes from RFC: >> - Dropped unused/useless code >> - Revised the sed command >> - Revised the clean target >> --- >> docs/Makefile | 7 ++++++- >> docs/misra/Makefile | 17 +++++++++++++++++ >> 2 files changed, 23 insertions(+), 1 deletion(-) >> create mode 100644 docs/misra/Makefile >> >> diff --git a/docs/Makefile b/docs/Makefile >> index 966a104490ac..ff991a0c3ca2 100644 >> --- a/docs/Makefile >> +++ b/docs/Makefile >> @@ -43,7 +43,7 @@ DOC_PDF := $(patsubst >> %.pandoc,pdf/%.pdf,$(PANDOCSRC-y)) \ >> all: build >> >> .PHONY: build >> -build: html txt pdf man-pages figs >> +build: html txt pdf man-pages figs misra >> >> .PHONY: sphinx-html >> sphinx-html: >> @@ -66,9 +66,14 @@ endif >> .PHONY: pdf >> pdf: $(DOC_PDF) >> >> +.PHONY: misra >> +misra: >> + $(MAKE) -C misra >> + >> .PHONY: clean >> clean: clean-man-pages >> $(MAKE) -C figs clean >> + $(MAKE) -C misra clean >> rm -rf .word_count *.aux *.dvi *.bbl *.blg *.glo *.idx *~ >> rm -rf *.ilg *.log *.ind *.toc *.bak *.tmp core >> rm -rf html txt pdf sphinx/html >> diff --git a/docs/misra/Makefile b/docs/misra/Makefile >> new file mode 100644 >> index 000000000000..8ea0505c8a20 >> --- /dev/null >> +++ b/docs/misra/Makefile >> @@ -0,0 +1,17 @@ >> +TARGETS := C-runtime-failures.o >> + >> +all: $(TARGETS) >> + >> +# sed is used in place of cat to prevent occurrences of '*/' >> +# in the .rst from breaking the compilation > > Please expand this comment with what you are doing in this makefile and > specifically what kind of .c file you are generating and why. > > Everything else looks good. > Ok -- Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
© 2016 - 2026 Red Hat, Inc.