From 08ef55ab91f8eab311b9c12b692ac9a944a7137c Mon Sep 17 00:00:00 2001 From: neil Date: Thu, 28 Aug 2014 15:27:10 +0000 Subject: [PATCH] Added support for a new config option, "includename". This value defaults to the module name, and is used as the basis of all public include file names and #defines. git-svn-id: https://svn.aros.org/svn/aros/trunk/AROS@49552 fb15a70f-31f2-0310-bbcc-cdcc74a49acc --- tools/genmodule/config.c | 21 +++++++++++++++---- tools/genmodule/config.h | 3 ++- tools/genmodule/functionhead.c | 10 ++++----- tools/genmodule/writeautoinit.c | 6 +++--- tools/genmodule/writefd.c | 6 +++--- tools/genmodule/writefunclist.c | 4 ++-- tools/genmodule/writeincclib.c | 8 ++++---- tools/genmodule/writeincdefines.c | 20 +++++++++--------- tools/genmodule/writeincinline.c | 18 ++++++++-------- tools/genmodule/writeincproto.c | 43 ++++++++++++++++++++------------------- tools/genmodule/writemakefile.c | 2 +- tools/genmodule/writestubs.c | 8 ++++---- 12 files changed, 82 insertions(+), 67 deletions(-) diff --git a/tools/genmodule/config.c b/tools/genmodule/config.c index 883038d355..ddf82c7dc9 100644 --- a/tools/genmodule/config.c +++ b/tools/genmodule/config.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2013, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ Code to parse the command line options and the module config file for @@ -724,7 +724,8 @@ static void readsectionconfig(struct config *cfg, struct classinfo *cl, struct i "classid", "classdatatype", "beginio_func", "abortio_func", "dispatcher", "initpri", "type", "addromtag", "oopbase_field", "rellib", "interfaceid", "interfacename", - "methodstub", "methodbase", "attributebase", "handler_func" + "methodstub", "methodbase", "attributebase", "handler_func", + "includename" }; const unsigned int namenums = sizeof(names)/sizeof(char *); unsigned int namenum; @@ -761,7 +762,7 @@ static void readsectionconfig(struct config *cfg, struct classinfo *cl, struct i if (cl != NULL) cl->basename = strdup(s); if (in != NULL) - exitfileerror(20, "basename not valid config option when in a interface section\n"); + exitfileerror(20, "basename not valid config option when in an interface section\n"); break; case 2: /* libbase */ @@ -1142,7 +1143,13 @@ static void readsectionconfig(struct config *cfg, struct classinfo *cl, struct i exitfileerror(20, "handler specified when not a handler\n"); cfg->handlerfunc = strdup(s); break; - } + case 35: /* includename */ + if (inclass) + exitfileerror(20, "includename not valid config option" + " when in a class section\n"); + cfg->includename = strdup(s); + break; + } } else /* Line starts with ## */ { @@ -1248,6 +1255,12 @@ static void readsectionconfig(struct config *cfg, struct classinfo *cl, struct i strcat(cfg->libbasetypeptrextern, " *"); free(libbasetypeextern); } + + if (cfg->includename == NULL) + cfg->includename = cfg->modulename; + cfg->includenameupper = strdup(cfg->includename); + for (s=cfg->includenameupper; *s!='\0'; *s = toupper(*s), s++) + if (!isalnum(*s)) *s = '_'; } /* When class was given too fill in some defaults when not specified */ diff --git a/tools/genmodule/config.h b/tools/genmodule/config.h index 14f00f2c84..daa01dd5c3 100644 --- a/tools/genmodule/config.h +++ b/tools/genmodule/config.h @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. Desc: Define the C structure for storing the command line options and the module config data @@ -127,6 +127,7 @@ struct config enum modtype modtype; char *modtypestr; char *suffix; + char *includename, *includenameupper; /* Extra string to include in version */ char *versionextra; diff --git a/tools/genmodule/functionhead.c b/tools/genmodule/functionhead.c index 827b494bd6..905b0afa89 100644 --- a/tools/genmodule/functionhead.c +++ b/tools/genmodule/functionhead.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2012, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ The code for storing information of functions present in the module @@ -257,9 +257,9 @@ void writefuncprotos(FILE *out, struct config *cfg, struct functionhead *funclis "\n" "#if !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__)" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); switch (funclistit->libcall) @@ -373,9 +373,9 @@ void writefuncprotos(FILE *out, struct config *cfg, struct functionhead *funclis "\n" "#endif /* !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__) */" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); } } diff --git a/tools/genmodule/writeautoinit.c b/tools/genmodule/writeautoinit.c index b5f304e8ac..84642dc9fb 100644 --- a/tools/genmodule/writeautoinit.c +++ b/tools/genmodule/writeautoinit.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ Function to write module_autoinit.c. Part of genmodule. @@ -35,13 +35,13 @@ void writeautoinit(struct config *cfg, int is_rel) freeBanner(banner); if (!(cfg->options & OPTION_NOINCLUDES)) - fprintf(out, "#include \n", cfg->modulename); + fprintf(out, "#include \n", cfg->includename); fprintf(out, "#include \n" "\n" "AROS_%sLIBSET(\"%s.%s\", %s, %s)\n", is_rel ? "REL" : "", - cfg->modulename, cfg->suffix, + cfg->includename, cfg->suffix, cfg->libbasetypeptrextern, cfg->libbase ); diff --git a/tools/genmodule/writefd.c b/tools/genmodule/writefd.c index aa6710c5ca..68b9bd23d2 100644 --- a/tools/genmodule/writefd.c +++ b/tools/genmodule/writefd.c @@ -1,8 +1,8 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ - Write the functionlist to a FD file for identify.library. + Write the functionlist to an FD file for identify.library. */ #include "genmodule.h" @@ -65,7 +65,7 @@ void writefd(struct config *cfg) } } - snprintf(line, 255, "%s/%s_lib.fd", cfg->gendir, cfg->modulename); + snprintf(line, 255, "%s/%s_lib.fd", cfg->gendir, cfg->includename); out = fopen(line, "w"); diff --git a/tools/genmodule/writefunclist.c b/tools/genmodule/writefunclist.c index 0ee23f0211..e40720d21a 100644 --- a/tools/genmodule/writefunclist.c +++ b/tools/genmodule/writefunclist.c @@ -1,8 +1,8 @@ /* - Copyright © 1995-2008, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ - Write the functionlist to a file that can be includes the .conf file. + Write the functionlist to a file that can be included in the .conf file. */ #include "genmodule.h" diff --git a/tools/genmodule/writeincclib.c b/tools/genmodule/writeincclib.c index e1fc2e56de..91c1a80531 100644 --- a/tools/genmodule/writeincclib.c +++ b/tools/genmodule/writeincclib.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2010, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ Function to write clib/modulename_protos.h. Part of genmodule. @@ -14,7 +14,7 @@ void writeincclib(struct config *cfg) struct functionarg *arglistit; struct stringlist *linelistit; - snprintf(line, 255, "%s/clib/%s_protos.h", cfg->gendir, cfg->modulename); + snprintf(line, 255, "%s/clib/%s_protos.h", cfg->gendir, cfg->includename); out = fopen(line, "w"); @@ -33,7 +33,7 @@ void writeincclib(struct config *cfg) "\n" "#include \n" "\n", - cfg->modulenameupper, cfg->modulenameupper, banner + cfg->includenameupper, cfg->includenameupper, banner ); freeBanner(banner); @@ -53,5 +53,5 @@ void writeincclib(struct config *cfg) "__END_DECLS\n" "\n" "#endif /* CLIB_%s_PROTOS_H */\n", - cfg->modulenameupper); + cfg->includenameupper); } diff --git a/tools/genmodule/writeincdefines.c b/tools/genmodule/writeincdefines.c index 997fe16b15..890c9e6a53 100644 --- a/tools/genmodule/writeincdefines.c +++ b/tools/genmodule/writeincdefines.c @@ -1,5 +1,5 @@ /* - Copyright © 1995-2012, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. $Id$ Function to write defines/modulename.h. Part of genmodule. @@ -16,7 +16,7 @@ void writeincdefines(struct config *cfg) char line[256], *banner; struct functionhead *funclistit; - snprintf(line, 255, "%s/defines/%s.h", cfg->gendir, cfg->modulename); + snprintf(line, 255, "%s/defines/%s.h", cfg->gendir, cfg->includename); out = fopen(line, "w"); if (out == NULL) @@ -43,7 +43,7 @@ void writeincdefines(struct config *cfg) "\n" "__BEGIN_DECLS\n" "\n", - cfg->modulenameupper, cfg->modulenameupper, banner, cfg->modulename + cfg->includenameupper, cfg->includenameupper, banner, cfg->modulename ); freeBanner(banner); @@ -55,9 +55,9 @@ void writeincdefines(struct config *cfg) "\n" "#if !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__)" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); writedefineregister(out, funclistit, cfg); @@ -70,9 +70,9 @@ void writeincdefines(struct config *cfg) "\n" "#endif /* !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__) */" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); } @@ -82,7 +82,7 @@ void writeincdefines(struct config *cfg) "__END_DECLS\n" "\n" "#endif /* DEFINES_%s_H*/\n", - cfg->modulenameupper + cfg->includenameupper ); fclose(out); } @@ -294,7 +294,7 @@ writedefinevararg(FILE *out, struct functionhead *funclistit, struct config *cfg fprintf(out, "\n#if !defined(NO_INLINE_STDARG) && !defined(%s_NO_INLINE_STDARG)\n" "#define %s(", - cfg->modulenameupper, varargname + cfg->includenameupper, varargname ); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL && arglistit->next != NULL; @@ -343,7 +343,7 @@ writedefinevararg(FILE *out, struct functionhead *funclistit, struct config *cfg fprintf(out, "\n#if !defined(NO_INLINE_STDARG) && !defined(%s_NO_INLINE_STDARG)\n" "static inline %s __%s_WB(%s __%s", - cfg->modulenameupper, + cfg->includenameupper, funclistit->type, varargname, cfg->libbasetypeptrextern, cfg->libbase ); for (arglistit = funclistit->arguments; diff --git a/tools/genmodule/writeincinline.c b/tools/genmodule/writeincinline.c index b6f61ef10a..af97d92ac4 100644 --- a/tools/genmodule/writeincinline.c +++ b/tools/genmodule/writeincinline.c @@ -16,7 +16,7 @@ void writeincinline(struct config *cfg) char line[256], *banner; struct functionhead *funclistit; - snprintf(line, 255, "%s/inline/%s.h", cfg->gendir, cfg->modulename); + snprintf(line, 255, "%s/inline/%s.h", cfg->gendir, cfg->includename); out = fopen(line, "w"); if (out == NULL) @@ -41,7 +41,7 @@ void writeincinline(struct config *cfg) "#include \n" "#include \n" "\n", - cfg->modulenameupper, cfg->modulenameupper, banner, cfg->modulename + cfg->includenameupper, cfg->includenameupper, banner, cfg->modulename ); freeBanner(banner); @@ -53,9 +53,9 @@ void writeincinline(struct config *cfg) "\n" "#if !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__)" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); writeinlineregister(out, funclistit, cfg); @@ -68,9 +68,9 @@ void writeincinline(struct config *cfg) "\n" "#endif /* !defined(__%s_LIBAPI__) || (%d <= __%s_LIBAPI__) */" "\n", - cfg->modulenameupper, + cfg->includenameupper, funclistit->version, - cfg->modulenameupper + cfg->includenameupper ); } } @@ -78,7 +78,7 @@ void writeincinline(struct config *cfg) fprintf(out, "\n" "#endif /* INLINE_%s_H*/\n", - cfg->modulenameupper + cfg->includenameupper ); fclose(out); } @@ -296,7 +296,7 @@ writeinlinevararg(FILE *out, struct functionhead *funclistit, struct config *cfg fprintf(out, "\n#if !defined(NO_INLINE_STDARG) && !defined(%s_NO_INLINE_STDARG)\n" "#define %s(", - cfg->modulenameupper, varargname + cfg->includenameupper, varargname ); for (arglistit = funclistit->arguments, count = 1; arglistit != NULL && arglistit->next != NULL; @@ -344,7 +344,7 @@ writeinlinevararg(FILE *out, struct functionhead *funclistit, struct config *cfg fprintf(out, "\n#if !defined(NO_INLINE_STDARG) && !defined(%s_NO_INLINE_STDARG)\n" "static inline %s __inline_%s_%s(%s __%s", - cfg->modulenameupper, + cfg->includenameupper, funclistit->type, cfg->basename, varargname, cfg->libbasetypeptrextern, cfg->libbase ); for (arglistit = funclistit->arguments, count = 0; diff --git a/tools/genmodule/writeincproto.c b/tools/genmodule/writeincproto.c index c2fdf43d62..f7113e7c6f 100644 --- a/tools/genmodule/writeincproto.c +++ b/tools/genmodule/writeincproto.c @@ -1,8 +1,9 @@ /* - Copyright © 1995-2011, The AROS Development Team. All rights reserved. + Copyright © 1995-2014, The AROS Development Team. All rights reserved. Desc: Function to write proto/modulename(_rel).h. Part of genmodule. */ + #include "genmodule.h" void writeincproto(struct config *cfg) @@ -12,7 +13,7 @@ void writeincproto(struct config *cfg) struct linelist *linelistit; snprintf(line, 255, "%s/proto/%s.h", - cfg->gendir, cfg->modulename + cfg->gendir, cfg->includename ); out = fopen(line, "w"); @@ -29,8 +30,8 @@ void writeincproto(struct config *cfg) "\n" "%s" "\n" - , cfg->modulenameupper - , cfg->modulenameupper + , cfg->includenameupper + , cfg->includenameupper , banner ); fprintf(out, @@ -41,14 +42,14 @@ void writeincproto(struct config *cfg) "#include \n" "\n", (cfg->modtype == DEVICE) ? "#include \n" : "", - cfg->modulename + cfg->includename ); freeBanner(banner); if (!(cfg->options & OPTION_DUPBASE)) { /* If single libbase store libbase in global variable. This is here to be legacy compliant for code that expects this - global libbase. If that would not needed we could always use + global libbase. If that would not be needed we could always use __aros_getbase_ModName() to access libbase */ fprintf(out, @@ -77,18 +78,18 @@ void writeincproto(struct config *cfg) " #endif\n" "#endif\n" "\n", - cfg->modulenameupper, - cfg->modulenameupper, + cfg->includenameupper, + cfg->includenameupper, cfg->libbase, - cfg->modulenameupper, + cfg->includenameupper, cfg->libbase, cfg->libbasetypeptrextern, cfg->libbase, cfg->libbase, cfg->libbase, cfg->libbase, - cfg->modulenameupper, + cfg->includenameupper, cfg->libbase, - cfg->modulenameupper, cfg->libbase, - cfg->modulenameupper, cfg->libbase, + cfg->includenameupper, cfg->libbase, + cfg->includenameupper, cfg->libbase, cfg->libbase, cfg->libbase, cfg->libbasetypeptrextern, cfg->libbase ); @@ -104,20 +105,20 @@ void writeincproto(struct config *cfg) "\n", cfg->libbasetypeptrextern, cfg->libbase, cfg->libbase, - cfg->modulenameupper, cfg->libbase, - cfg->modulenameupper, cfg->libbase + cfg->includenameupper, cfg->libbase, + cfg->includenameupper, cfg->libbase ); } // define name must not start with a digit // this solves a problem with proto/8svx.h - if (isdigit(cfg->modulenameupper[0])) + if (isdigit(cfg->includenameupper[0])) { - snprintf(define, sizeof define, "X%s", cfg->modulenameupper); + snprintf(define, sizeof define, "X%s", cfg->includenameupper); } else { - strncpy(define, cfg->modulenameupper, sizeof define); + strncpy(define, cfg->includenameupper, sizeof define); } fprintf(out, @@ -128,11 +129,11 @@ void writeincproto(struct config *cfg) "#endif\n" "\n" "#endif /* PROTO_%s_H */\n", - define, cfg->modulenameupper, - cfg->modulename, + define, cfg->includenameupper, + cfg->includename, define, - cfg->modulename, - cfg->modulenameupper + cfg->includename, + cfg->includenameupper ); fclose(out); diff --git a/tools/genmodule/writemakefile.c b/tools/genmodule/writemakefile.c index 25a80d8b0c..d5c3843aa0 100644 --- a/tools/genmodule/writemakefile.c +++ b/tools/genmodule/writemakefile.c @@ -93,7 +93,7 @@ void writemakefile(struct config *cfg) { fprintf(out, "clib/%s_protos.h inline/%s.h defines/%s.h proto/%s.h", - cfg->modulename, cfg->modulename, cfg->modulename, cfg->modulename + cfg->includename, cfg->includename, cfg->includename, cfg->includename ); } if (cfg->interfacelist) diff --git a/tools/genmodule/writestubs.c b/tools/genmodule/writestubs.c index 71ef92640d..59696e6722 100644 --- a/tools/genmodule/writestubs.c +++ b/tools/genmodule/writestubs.c @@ -100,7 +100,7 @@ static void writeheader(struct config *cfg, int is_rel, FILE *out) "/* Do not include the libbase */\n" "#define __%s_NOLIBBASE__\n" "#endif\n", - banner, cfg->modulenameupper, cfg->modulenameupper + banner, cfg->includenameupper, cfg->includenameupper ); } else { fprintf @@ -114,7 +114,7 @@ static void writeheader(struct config *cfg, int is_rel, FILE *out) "/* Be sure that the libbases are included in the stubs file */\n" "#undef __NOLIBBASE__\n" "#undef __%s_NOLIBBASE__\n", - banner, cfg->modulenameupper + banner, cfg->includenameupper ); } freeBanner(banner); @@ -122,8 +122,8 @@ static void writeheader(struct config *cfg, int is_rel, FILE *out) if (!(cfg->options & OPTION_NOINCLUDES)) { if (is_rel) - fprintf(out, "#define __%s_RELLIBBASE__\n", cfg->modulenameupper); - fprintf(out, "#include \n", cfg->modulename); + fprintf(out, "#define __%s_RELLIBBASE__\n", cfg->includenameupper); + fprintf(out, "#include \n", cfg->includename); } else { -- 2.11.4.GIT