2009-01-05 14:08:57

by Jiri Slaby

[permalink] [raw]
Subject: [PATCH 1/1] scripts: allow docproc invocation from external

- getcwd returns path without slash at the end, add the slash
- add KERNSRCTREE env, so that we can specify path for kernel
(for knowing where to find scripts/kernel-doc) and SRCTREE
(for searching files referenced in .tmpl) separately

Signed-off-by: Jiri Slaby <[email protected]>
Cc: Sam Ravnborg <[email protected]>
Cc: Randy Dunlap <[email protected]>
---
scripts/basic/docproc.c | 13 +++++++++----
1 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
index 35bdc68..c716ae8 100644
--- a/scripts/basic/docproc.c
+++ b/scripts/basic/docproc.c
@@ -69,7 +69,7 @@ FILELINE * docsection;
#define NOFUNCTION "-nofunction"
#define NODOCSECTIONS "-no-doc-sections"

-char *srctree;
+static char *srctree, *kernsrctree;

void usage (void)
{
@@ -77,7 +77,8 @@ void usage (void)
fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
fprintf(stderr, "doc: frontend when generating kernel documentation\n");
fprintf(stderr, "depend: generate list of files referenced within file\n");
- fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n");
+ fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");
+ fprintf(stderr, " KERNSRCTREE: absolute path to kernel source tree.\n");
}

/*
@@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec)
exit(1);
case 0:
memset(real_filename, 0, sizeof(real_filename));
- strncat(real_filename, srctree, PATH_MAX);
- strncat(real_filename, KERNELDOCPATH KERNELDOC,
+ strncat(real_filename, kernsrctree, PATH_MAX);
+ strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
PATH_MAX - strlen(real_filename));
execvp(real_filename, svec);
fprintf(stderr, "exec ");
@@ -178,6 +179,7 @@ void find_export_symbols(char * filename)
char real_filename[PATH_MAX + 1];
memset(real_filename, 0, sizeof(real_filename));
strncat(real_filename, srctree, PATH_MAX);
+ strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
strncat(real_filename, filename,
PATH_MAX - strlen(real_filename));
sym = add_new_file(filename);
@@ -382,6 +384,9 @@ int main(int argc, char *argv[])
srctree = getenv("SRCTREE");
if (!srctree)
srctree = getcwd(NULL, 0);
+ kernsrctree = getenv("KERNSRCTREE");
+ if (!kernsrctree)
+ kernsrctree = srctree;
if (argc != 3) {
usage();
exit(1);
--
1.6.0.6


2009-01-07 19:54:19

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts: allow docproc invocation from external

On Mon, Jan 05, 2009 at 03:08:30PM +0100, Jiri Slaby wrote:
> - getcwd returns path without slash at the end, add the slash
> - add KERNSRCTREE env, so that we can specify path for kernel
> (for knowing where to find scripts/kernel-doc) and SRCTREE
> (for searching files referenced in .tmpl) separately


Kbuild already have:

KBUILD_SRC that point to the source tree
KBUILD_OUTPUT that points to the output directory

Could we reuse these?

Sam

>
> Signed-off-by: Jiri Slaby <[email protected]>
> Cc: Sam Ravnborg <[email protected]>
> Cc: Randy Dunlap <[email protected]>
> ---
> scripts/basic/docproc.c | 13 +++++++++----
> 1 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
> index 35bdc68..c716ae8 100644
> --- a/scripts/basic/docproc.c
> +++ b/scripts/basic/docproc.c
> @@ -69,7 +69,7 @@ FILELINE * docsection;
> #define NOFUNCTION "-nofunction"
> #define NODOCSECTIONS "-no-doc-sections"
>
> -char *srctree;
> +static char *srctree, *kernsrctree;
>
> void usage (void)
> {
> @@ -77,7 +77,8 @@ void usage (void)
> fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
> fprintf(stderr, "doc: frontend when generating kernel documentation\n");
> fprintf(stderr, "depend: generate list of files referenced within file\n");
> - fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n");
> + fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");
> + fprintf(stderr, " KERNSRCTREE: absolute path to kernel source tree.\n");
> }
>
> /*
> @@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec)
> exit(1);
> case 0:
> memset(real_filename, 0, sizeof(real_filename));
> - strncat(real_filename, srctree, PATH_MAX);
> - strncat(real_filename, KERNELDOCPATH KERNELDOC,
> + strncat(real_filename, kernsrctree, PATH_MAX);
> + strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
> PATH_MAX - strlen(real_filename));
> execvp(real_filename, svec);
> fprintf(stderr, "exec ");
> @@ -178,6 +179,7 @@ void find_export_symbols(char * filename)
> char real_filename[PATH_MAX + 1];
> memset(real_filename, 0, sizeof(real_filename));
> strncat(real_filename, srctree, PATH_MAX);
> + strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
> strncat(real_filename, filename,
> PATH_MAX - strlen(real_filename));
> sym = add_new_file(filename);
> @@ -382,6 +384,9 @@ int main(int argc, char *argv[])
> srctree = getenv("SRCTREE");
> if (!srctree)
> srctree = getcwd(NULL, 0);
> + kernsrctree = getenv("KERNSRCTREE");
> + if (!kernsrctree)
> + kernsrctree = srctree;
> if (argc != 3) {
> usage();
> exit(1);
> --
> 1.6.0.6
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-06-01 16:02:21

by Randy Dunlap

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts: allow docproc invocation from external

Jiri Slaby wrote:
> - getcwd returns path without a slash at the end, add the slash

Hi Jiri,

This part (above) fixes a bug, right?

> - add KBUILD_SRC env support, so that we can specify path for
> kernel (to know where scripts/kernel-doc resides) and SRCTREE
> (for searching files referenced in .tmpl) separately

Can you explain your usage a bit more so that I can understand some
justification for this change? (not that I'm objecting to it)


> [v2]
> - use KBUILD_SRC instead of a newly introduced environment variable
>
> Signed-off-by: Jiri Slaby <[email protected]>
> Cc: Sam Ravnborg <[email protected]>
> Cc: Randy Dunlap <[email protected]>
> ---
> scripts/basic/docproc.c | 13 +++++++++----
> 1 files changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/scripts/basic/docproc.c b/scripts/basic/docproc.c
> index 35bdc68..4c9523e 100644
> --- a/scripts/basic/docproc.c
> +++ b/scripts/basic/docproc.c
> @@ -69,7 +69,7 @@ FILELINE * docsection;
> #define NOFUNCTION "-nofunction"
> #define NODOCSECTIONS "-no-doc-sections"
>
> -char *srctree;
> +static char *srctree, *kernsrctree;
>
> void usage (void)
> {
> @@ -77,7 +77,8 @@ void usage (void)
> fprintf(stderr, "Input is read from file.tmpl. Output is sent to stdout\n");
> fprintf(stderr, "doc: frontend when generating kernel documentation\n");
> fprintf(stderr, "depend: generate list of files referenced within file\n");
> - fprintf(stderr, "Environment variable SRCTREE: absolute path to kernel source tree.\n");
> + fprintf(stderr, "Environment variable SRCTREE: absolute path to sources.\n");

What "sources" other than the kernel source tree is SRCTREE used for?

> + fprintf(stderr, " KBUILD_SRC: absolute path to kernel source tree.\n");
> }
>
> /*
> @@ -96,8 +97,8 @@ void exec_kernel_doc(char **svec)
> exit(1);
> case 0:
> memset(real_filename, 0, sizeof(real_filename));
> - strncat(real_filename, srctree, PATH_MAX);
> - strncat(real_filename, KERNELDOCPATH KERNELDOC,
> + strncat(real_filename, kernsrctree, PATH_MAX);
> + strncat(real_filename, "/" KERNELDOCPATH KERNELDOC,
> PATH_MAX - strlen(real_filename));
> execvp(real_filename, svec);
> fprintf(stderr, "exec ");
> @@ -178,6 +179,7 @@ void find_export_symbols(char * filename)
> char real_filename[PATH_MAX + 1];
> memset(real_filename, 0, sizeof(real_filename));
> strncat(real_filename, srctree, PATH_MAX);
> + strncat(real_filename, "/", PATH_MAX - strlen(real_filename));
> strncat(real_filename, filename,
> PATH_MAX - strlen(real_filename));
> sym = add_new_file(filename);
> @@ -382,6 +384,9 @@ int main(int argc, char *argv[])
> srctree = getenv("SRCTREE");
> if (!srctree)
> srctree = getcwd(NULL, 0);
> + kernsrctree = getenv("KBUILD_SRC");
> + if (!kernsrctree)
> + kernsrctree = srctree;
> if (argc != 3) {
> usage();
> exit(1);


Thanks.
--
~Randy
LPC 2009, Sept. 23-25, Portland, Oregon
http://linuxplumbersconf.org/2009/

2009-06-01 17:02:17

by Jiri Slaby

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts: allow docproc invocation from external

On 06/01/2009 06:05 PM, Randy Dunlap wrote:
> Jiri Slaby wrote:
>> - getcwd returns path without a slash at the end, add the slash
>
> Hi Jiri,
>
> This part (above) fixes a bug, right?

Yes, but the bug is not triggered when building from a kernel tree.

>> - add KBUILD_SRC env support, so that we can specify path for
>> kernel (to know where scripts/kernel-doc resides) and SRCTREE
>> (for searching files referenced in .tmpl) separately
>
> Can you explain your usage a bit more so that I can understand some
> justification for this change? (not that I'm objecting to it)

Sure, I have out-of-kernel drivers (which I plan to merge, but keep
out-of-tree development anyway) and have this in a makefile:
%.xml: %.tmpl
KBUILD_SRC=$(KSRC) $(KDIR)/scripts/basic/docproc doc $^ > $@
so that I can build documentation from a .tmpl file for those drivers.
SRCTREE defaults to cwd, so it finds sources referenced from the .tmpl
file in current location. What didn't work is execution of
scripts/kernel-doc. This is now executed with KBUILD_SRC prepended,
which is what it should be.

2009-06-05 21:43:17

by Sam Ravnborg

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts: allow docproc invocation from external

On Mon, Jun 01, 2009 at 09:05:00AM -0700, Randy Dunlap wrote:
> Jiri Slaby wrote:
> > - getcwd returns path without a slash at the end, add the slash
>
> Hi Jiri,
>
> This part (above) fixes a bug, right?
>
> > - add KBUILD_SRC env support, so that we can specify path for
> > kernel (to know where scripts/kernel-doc resides) and SRCTREE
> > (for searching files referenced in .tmpl) separately
>
> Can you explain your usage a bit more so that I can understand some
> justification for this change? (not that I'm objecting to it)

Randy - it took this as an "Acked-by" and applied the patch with that.
Please let me know if this is not ok.

Sam

2009-06-16 14:29:47

by William Cohen

[permalink] [raw]
Subject: Re: [PATCH 1/1] scripts: allow docproc invocation from external

This patch appears to be adversely affect the documentation build in the kernel
source directory. When trying "make htmldocs" in the source directory of the
kernel this git commit causes the make to fail with:

$ make htmldocs V=1make -f scripts/Makefile.build obj=scripts/basic
make -f scripts/Makefile.build obj=Documentation/DocBook htmldocs
SRCTREE=/home/wcohen/kernel/mingo/linux.trees.git/
/home/wcohen/kernel/mingo/linux.trees.git/scripts/basic/docproc doc
Documentation/DocBook/alsa-driver-api.tmpl
> >Documentation/DocBook/alsa-driver-api.xml
exec /scripts/kernel-doc: No such file or directory
exec /scripts/kernel-doc: No such file or directory
...

-Will