Skip to contentSkip to conversation

asciidoc: use absolute path for resources

PATCH Superseded Matt Weber 4 participants 6 messages Jul 27, 2016 – Jul 28, 2016

lore
Share & tools
lore

Matt Weber

author
#0 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

From: Atul Singh <[email protected]>

One of the "features" of a2x is that the '-r|--resource' flag imports resources relative to the [SOURCE_FILE], not the CWD. The current implementation tries to import resources from the destination dir $(@D), which works fine for out-of-tree builds because $(@D) is an absolute path, however in-tree builds treat $(@D) as a relative path, which breaks because a2x treats $(@D) relative to SOURCE_FILE.

Use the make command $(abspath names...) to convert the dest dir to an absolute path before passing it as a resource.

---
v1 -> v2
[Yann
- Removed extra spaces before the $$(foreach and --resource
- Updated commit message to be $(@D) vs $(D)

v2 -> v3
[Matt
- Fixed my rebase and resent patch

---
 package/doc-asciidoc.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
package/doc-asciidoc.mk +2 -1
index 6ab5ad2..4f765b8 100644
@@ -117,7 +117,8 @@ $$(O)/docs/$(1)/$(1).$(6): $$($(2)_SOURCES) \
 	$$(Q)$$(call MESSAGE,"Generating $(7) $(1)...")
 	$$(Q)mkdir -p $$(@D)
 	$$(Q)a2x $(8) -f $(4) -d book -L \
-		$$(foreach r,$$($(2)_RESOURCES),-r $$(r)) -r $$(@D) \
+		$$(foreach r,$$($(2)_RESOURCES) $$(@D), \
+			--resource="$$(abspath $$(r))") \
 		$$($(2)_$(4)_A2X_OPTS) \
 		--asciidoc-opts="$$($(2)_$(4)_ASCIIDOC_OPTS)" \
 		$$(BUILD_DIR)/docs/$(1)/$(1).txt
Signature · 1 line
1.9.1
#1 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

Quoted 10 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matt" == Matt Weber <[email protected]> writes:

From: Atul Singh <[email protected]>
One of the "features" of a2x is that the '-r|--resource' flag imports resources relative to the [SOURCE_FILE], not the CWD. The current implementation tries to import resources from the destination dir $(@D), which works fine for out-of-tree builds because $(@D) is an absolute path, however in-tree builds treat $(@D) as a relative path, which breaks because a2x treats $(@D) relative to SOURCE_FILE.

Quoted 8 lines

Use the make command $(abspath names...) to convert the dest dir to an absolute path before passing it as a resource.

Committed, thanks.

Like Yann, I also cannot reproduce any errors without it. How do you trigger it?

Signature · 1 line
Bye, Peter Korsgaard
#2 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

All,

Quoted 15 lines · Peter Korsgaard
Quoted 14 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matt" == Matt Weber <[email protected]> writes:

From: Atul Singh <[email protected]>
One of the "features" of a2x is that the '-r|--resource' flag imports resources relative to the [SOURCE_FILE], not the CWD. The current implementation tries to import resources from the destination dir $(@D), which works fine for out-of-tree builds because $(@D) is an absolute path, however in-tree builds treat $(@D) as a relative path, which breaks because a2x treats $(@D) relative to SOURCE_FILE.

Use the make command $(abspath names...) to convert the dest dir to an absolute path before passing it as a resource.

Quoted 8 lines
Quoted 3 lines

Committed, thanks.

Like Yann, I also cannot reproduce any errors without it. How do you trigger it?

(Courtesy of Brandon, CC'd)

You can see the issue by running "make V=1 manual". Normally you'll see the following

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Generating split HTML manual...

mkdir -p output/docs/manual
a2x --xsltproc-opts "--stringparam toc.section.depth 1" -f chunked -d
book -L -r /home/foobar/projects/asciidoc-upstream/buildroot-main/docs/images -r output/docs/manual --destination-dir="output/docs/manual" --asciidoc-opts="" /home/foobar/projects/asciidoc-upstream/buildroot-main/output/build/docs/manual/manual.txt

The issue is with the flag "-r output/docs/manual" which uses a relative path. However only generated files are stored there, which isn't a problem with the current Buildroot as it doesn't use any. The issue appears when you use generated files like a graphviz element because the generated graph is stored in that directory.

You can recreate the bug by applying this patch

From: Brandon Maier <[email protected]>
Date: Wed, 27 Jul 2016 17:05:43 -0500
Subject: [PATCH] Example graph to show asciidoc bug

---
 docs/manual/introduction.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
docs/manual/introduction.txt +0 -0
index 476aa81..2297efd 100644
@@ -24,3 +24,20 @@ comes with default configurations for several

boards available
off-the-shelf. Besides this, a number of third-party projects are based on, or develop their BSP footnote:[BSP: Board Support Package] or SDK footnote:[SDK: Software Development Kit] on top of Buildroot.
+
+["graphviz", "sample2.png"]
+---------------------------------------------------------------------
+digraph automata_0 {

+  size ="8.5, 11";
+  node [shape = circle];
+  0 [ style = filled, color=lightgrey ];
+  2 [ shape = doublecircle ];
+  0 -> 2 [ label = "a " ];
+  0 -> 1 [ label = "other " ];
+  1 -> 2 [ label = "a " ];
+  1 -> 1 [ label = "other " ];
+  2 -> 2 [ label = "a " ];
+  2 -> 1 [ label = "other " ];
+  "Machine: a" [ shape = plaintext ];

+}
+---------------------------------------------------------------------
--
1.9.1

Signature · 8 lines
Matthew L Weber / Pr Software Engineer
Airborne Information Systems / Security Systems and Software / Secure Platforms
MS 131-100, C Ave NE, Cedar Rapids, IA, 52498, USA
www.rockwellcollins.com

Note: Any Export License Required Information and License Restricted
Third Party Intellectual Property (TPIP) content must be encrypted and
sent to matthew.weber at corp.rockwellcollins.com.
#3 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

Matthew, All,

On 2016-07-28 08:04 -0500, Matthew Weber spake thusly:

Quoted 9 lines · Peter Korsgaard
Quoted 8 lines
Quoted 8 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matt" == Matt Weber <[email protected]> writes:

From: Atul Singh <[email protected]>
One of the "features" of a2x is that the '-r|--resource' flag imports resources relative to the [SOURCE_FILE], not the CWD. The current implementation tries to import resources from the destination dir $(@D), which works fine for out-of-tree builds because $(@D) is an absolute path, however in-tree builds treat $(@D) as a relative path, which breaks because a2x treats $(@D) relative to SOURCE_FILE.

[--SNIP--]

Quoted 47 lines
Quoted 2 lines

Like Yann, I also cannot reproduce any errors without it. How do you trigger it?

You can see the issue by running "make V=1 manual". Normally you'll see the following

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Generating split HTML manual...

mkdir -p output/docs/manual
a2x --xsltproc-opts "--stringparam toc.section.depth 1" -f chunked -d
book -L -r /home/foobar/projects/asciidoc-upstream/buildroot-main/docs/images -r output/docs/manual --destination-dir="output/docs/manual" --asciidoc-opts="" /home/foobar/projects/asciidoc-upstream/buildroot-main/output/build/docs/manual/manual.txt

The issue is with the flag "-r output/docs/manual" which uses a relative path. However only generated files are stored there, which isn't a problem with the current Buildroot as it doesn't use any. The issue appears when you use generated files like a graphviz element because the generated graph is stored in that directory.

You can recreate the bug by applying this patch

From: Brandon Maier <[email protected]>
Date: Wed, 27 Jul 2016 17:05:43 -0500
Subject: [PATCH] Example graph to show asciidoc bug

---
 docs/manual/introduction.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
docs/manual/introduction.txt +0 -0
index 476aa81..2297efd 100644
@@ -24,3 +24,20 @@ comes with default configurations for several

boards available
off-the-shelf. Besides this, a number of third-party projects are based on, or develop their BSP footnote:[BSP: Board Support Package] or SDK footnote:[SDK: Software Development Kit] on top of Buildroot.

docs/manual/introduction.txt +7 -0
+
+["graphviz", "sample2.png"]
+---------------------------------------------------------------------
+digraph automata_0 {
+  size ="8.5, 11";
+  node [shape = circle];
+  0 [ style = filled, color=lightgrey ];

docs/manual/introduction.txt

Quoted 10 lines
docs/manual/introduction.txt +10 -0
+  2 [ shape = doublecircle ];
+  0 -> 2 [ label = "a " ];
+  0 -> 1 [ label = "other " ];
+  1 -> 2 [ label = "a " ];
+  1 -> 1 [ label = "other " ];
+  2 -> 2 [ label = "a " ];
+  2 -> 1 [ label = "other " ];
+  "Machine: a" [ shape = plaintext ];
+}
+---------------------------------------------------------------------

Thanks for this example. However, the generated manual does include the graph of that state machine.

    $ git checkout 9d4a1a7^  # 9d4a1a7 is your commit
    $ make manual-html
    [--SNIP--]
    $ ls -l output/docs/manual/sample2.png docs/manual/sample2.png
    ls: cannot access 'docs/manual/sample2.png': No such file or directory
    -rw-r--r-- 1 ymorin ymorin 17K Jul 28 21:25 output/docs/manual/sample2.png
    $ mkdir ../O
    $ make O=$(cd ../O; pwd) manual-html
    [--SNIP--]
    $ ls -l ../O/docs/manual/sample2.png docs/manual/sample2.png
    ls: cannot access 'docs/manual/sample2.png': No such file or directory
    -rw-r--r-- 1 ymorin ymorin 16512 Jul 28 21:26 ../O/docs/manual/sample2.png

Both in-tree and out-of-tree manuals have the state machine, and the graph *is* generated in the output dir, not the source dir.

Did I miss something?

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#4 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

The bug crops up when generating the chunked/split-HTML manual. Try the "manual" target instead of "manual-html".

Quoted 116 lines · Yann E. MORIN

Matthew, All,

On 2016-07-28 08:04 -0500, Matthew Weber spake thusly:

Quoted 1 line

On Wed, Jul 27, 2016 at 2:21 PM, Peter Korsgaard <[email protected]>

Quoted 3 lines · wrote:
Quoted 3 lines
Quoted 3 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Matt" == Matt Weber <[email protected]> writes:

From: Atul Singh <[email protected]> One of the "features" of a2x is that the '-r|--resource' flag

imports

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

resources relative to the [SOURCE_FILE], not the CWD. The current implementation tries to import resources from the destination dir

$(@D),

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

which works fine for out-of-tree builds because $(@D) is an absolute path, however in-tree builds treat $(@D) as a relative path, which

breaks

Quoted 1 line
Quoted 1 line
Quoted 1 line

because a2x treats $(@D) relative to SOURCE_FILE.

[--SNIP--]

Quoted 10 lines
Quoted 2 lines

Like Yann, I also cannot reproduce any errors without it. How do you trigger it?

You can see the issue by running "make V=1 manual". Normally you'll see the following

...

Quoted 1 line
Quoted 1 line
Quoted 1 line

Generating split HTML manual...

mkdir -p output/docs/manual
a2x --xsltproc-opts "--stringparam toc.section.depth 1" -f chunked -d book -L -r

/home/foobar/projects/asciidoc-upstream/buildroot-main/docs/images

Quoted 3 lines

-r output/docs/manual --destination-dir="output/docs/manual" --asciidoc-opts=""

/home/foobar/projects/asciidoc-upstream/buildroot-main/output/build/docs/manual/manual.txt

Quoted 23 lines

The issue is with the flag "-r output/docs/manual" which uses a relative path. However only generated files are stored there, which isn't a problem with the current Buildroot as it doesn't use any. The issue appears when you use generated files like a graphviz element because the generated graph is stored in that directory.

You can recreate the bug by applying this patch

From: Brandon Maier <[email protected]>
Date: Wed, 27 Jul 2016 17:05:43 -0500
Subject: [PATCH] Example graph to show asciidoc bug

---
 docs/manual/introduction.txt | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
docs/manual/introduction.txt +0 -0
index 476aa81..2297efd 100644
@@ -24,3 +24,20 @@ comes with default configurations for several
Quoted 2 lines

boards available
off-the-shelf. Besides this, a number of third-party projects are based

on,

Quoted 9 lines

or develop their BSP footnote:[BSP: Board Support Package] or SDK footnote:[SDK: Software Development Kit] on top of Buildroot.

docs/manual/introduction.txt +7 -0
+
+["graphviz", "sample2.png"]
+---------------------------------------------------------------------
+digraph automata_0 {
+  size ="8.5, 11";
+  node [shape = circle];
+  0 [ style = filled, color=lightgrey ];

docs/manual/introduction.txt

Quoted 10 lines
docs/manual/introduction.txt +10 -0
+  2 [ shape = doublecircle ];
+  0 -> 2 [ label = "a " ];
+  0 -> 1 [ label = "other " ];
+  1 -> 2 [ label = "a " ];
+  1 -> 1 [ label = "other " ];
+  2 -> 2 [ label = "a " ];
+  2 -> 1 [ label = "other " ];
+  "Machine: a" [ shape = plaintext ];
+}
+---------------------------------------------------------------------

Thanks for this example. However, the generated manual does include the graph of that state machine.

    $ git checkout 9d4a1a7^  # 9d4a1a7 is your commit
    $ make manual-html
    [--SNIP--]
    $ ls -l output/docs/manual/sample2.png docs/manual/sample2.png
    ls: cannot access 'docs/manual/sample2.png': No such file or directory
    -rw-r--r-- 1 ymorin ymorin 17K Jul 28 21:25
output/docs/manual/sample2.png
    $ mkdir ../O
    $ make O=$(cd ../O; pwd) manual-html
    [--SNIP--]
    $ ls -l ../O/docs/manual/sample2.png docs/manual/sample2.png
    ls: cannot access 'docs/manual/sample2.png': No such file or directory
    -rw-r--r-- 1 ymorin ymorin 16512 Jul 28 21:26
../O/docs/manual/sample2.png

Both in-tree and out-of-tree manuals have the state machine, and the graph *is* generated in the output dir, not the source dir.

Did I miss something?

Regards,
Yann E. MORIN.

--

.-----------------.--------------------.------------------.--------------------.

|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics'
conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___
     |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There
is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v
 conspiracy.  |
Quoted 2 lines

'------------------------------^-------^------------------^--------------------'

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160728/0c8523f1/attachment.html>

#5 lore raw

PATCH v3 1/1 asciidoc: use absolute path for resources

Brandon, All,

On 2016-07-28 14:44 -0500, Brandon Maier spake thusly:

Quoted 2 lines

The bug crops up when generating the chunked/split-HTML manual. Try the "manual" target instead of "manual-html".

Indeed, I could reproduce. Your patch indeed fixes it.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'