Thread: [Autogen-users] easiest way to print a custom version string
Brought to you by:
bkorb
From: Nikos M. <nm...@gn...> - 2014-06-22 10:54:07
|
Hello, I'd like to override the default version string in order to print (in addition to the default information), some other data, e.g., the versions of the used libraries and features enabled. I've currently tried to do that using a method similar to [0] for usage, by un-defining the version from the .def file, and adding a custom flag version. That unfortunately conflicts with autoconf's VERSION definition, so it requires some special re-arrangement of headers, such as moving the generated header over config.h. The issues with this approach are that (1) optionPrintVersion() starts with the name of the program but no version string (as the version directive was removed), and it does exit after printing the version, so the additional data can only precede the copyright string which is pretty impractical. Is there a better way to achieve that functionality? regards, Nikos [0]. http://www.gnu.org/software/autogen/manual/autogen.html#usage-attributes |
From: Bruce K. <bru...@gm...> - 2014-06-23 15:46:06
|
On 06/22/14 03:53, Nikos Mavrogiannopoulos wrote: > Hello, > I'd like to override the default version string in order to print (in > addition to the default information), some other data, e.g., the > versions of the used libraries and features enabled. > > I've currently tried to do that using a method similar to [0] for usage, > by un-defining the version from the .def file, and adding a custom flag > version. That unfortunately conflicts with autoconf's VERSION > definition, so it requires some special re-arrangement of headers, such > as moving the generated header over config.h. or undef-ing before sourcing the option header? > The issues with this approach are that (1) optionPrintVersion() starts > with the name of the program but no version string (as the version > directive was removed), and it does exit after printing the version, so > the additional data can only precede the copyright string which is > pretty impractical. Is there a better way to achieve that functionality? After line 177 in optcode.tlib: (set! tmp-text (string-append version-text "\n" tmp-text)) add this: (if (exist? "full-version") (set! tmp-text (get "full-version"))) and add this to your .def file: full-version = <<- _EOVer_ whatever you like _EOVer_; that is probably the easiest way. Let me know if it suits your need. Otherwise, we have to go through the assembly of the text and define a new permutation based on some other indicator, like: (if (exist? "gnuly-correct-version") (set! tmp-text (....)) ) That would _probably_ be the best solution, but it takes a bit of effort: > IF (not (exist? "copyright")) > > =] > #define zCopyright NULL > #define zLicenseDescrip NULL[= > ELSE =][= > CASE (define cright-owner (get "copyright.owner" (get "copyright.author"))) > (get "copyright.type") =][= > > = note =][= > (set! tmp-text (get "copyright.text")) > (define ext-text tmp-text) =][= > > ~~* . =][= > (define ext-text > (license-description (get "copyright.type") > prog-name "" cright-owner ) ) > > (set! tmp-text > (license-info (get "copyright.type") > prog-name "" cright-owner (get "copyright.date") ) ) > =][= > > * =][= > (set! tmp-text (sprintf > "Copyright (C) %s %s, all rights reserved" > (get "copyright.date") cright-owner )) > (define ext-text tmp-text) =][= > > ESAC =][= > > (set! tmp-text (string-append version-text "\n" tmp-text)) ;;; line 177 > (if (not omit-nls-code) > (put-xget "pzCopyright" tmp-text)) > > (string-append "\n#define zCopyright (" > (string-table-add-ref opt-strs tmp-text) > ")\n#define zLicenseDescrip (" > > (if (= tmp-text ext-text) > "zCopyright" > (begin > (set! ext-text (string-append (shell (string-append > "${CLexe} --fill -I0 -W75 <<_EOF_\n" ext-text "\n_EOF_" )) "\n" )) > > (if (not omit-nls-code) > (put-xget "pzCopyNotice" ext-text)) > (string-table-add-ref opt-strs ext-text) > ) ) > ")\n" ) =][= > > ENDIF "copyright" =][= |
From: Bruce K. <bru...@gm...> - 2014-06-23 17:30:22
|
On 06/22/14 03:53, Nikos Mavrogiannopoulos wrote: > Hello, > I'd like to override the default version string Specify a "version-proc": http://www.gnu.org/software/autogen/manual/html_node/automatic-options.html#automatic-options third paragraph. :) You found "optionVersionProc", if you grep for that in the templates, you see this code: IF (exist? "version") =][= IF (exist? "version-proc") =] #define VER_PROC [= (get "version-proc") =][= ELIF (. guarded-test-main) =] #ifdef [=(. main-guard) =] # define VER_PROC optionVersionStderr #else # define VER_PROC optionPrintVersion #endif /* [=(. main-guard)=] */[= ELSE =] #define VER_PROC optionPrintVersion[= ENDIF guarded-test-main =][= ENDIF there is a version |
From: Nikos M. <nm...@gn...> - 2014-06-23 19:08:19
|
On Mon, 2014-06-23 at 10:30 -0700, Bruce Korb wrote: On 06/22/14 03:53, Nikos Mavrogiannopoulos wrote: > > Hello, > > I'd like to override the default version string > > Specify a "version-proc": > > http://www.gnu.org/software/autogen/manual/html_node/automatic-options.html#automatic-options > > third paragraph. :) Thanks, that seems to be very close to what I want. The issue is that I can't combine it with optionPrintVersion(), as optionPrintVersion() exits, so I'd have to duplicate printing the license message, and bugs address. Anyway maybe, I'm nitpicking, I think it is ok by having a more terse version text. regards, Nikos |
From: Bruce K. <bru...@gm...> - 2014-06-23 20:27:45
|
On 06/23/14 12:08, Nikos Mavrogiannopoulos wrote: > On Mon, 2014-06-23 at 10:30 -0700, Bruce Korb wrote: > On 06/22/14 03:53, Nikos Mavrogiannopoulos wrote: >>> Hello, >>> I'd like to override the default version string >> >> Specify a "version-proc": >> >> http://www.gnu.org/software/autogen/manual/html_node/automatic-options.html#automatic-options >> >> third paragraph. :) > > Thanks, that seems to be very close to what I want. The issue is that > I can't combine it with optionPrintVersion(), as optionPrintVersion() > exits, so I'd have to duplicate printing the license message, and bugs > address. Anyway maybe, I'm nitpicking, I think it is ok by having a > more terse version text. Ah. Then: OPT_SET_VERSION_DOES_NOT_EXIT(&progOptions); optionPrintVersion(&progOptions, progOptions.pOptDesc + INDEX_OPT_HELP); I still have 6 bits in the OPTPROC_* flags, before I have to do something disruptive. Won't be doing it today though. :) |
From: Bruce K. <bru...@gm...> - 2014-06-24 00:44:52
|
Never mind. I was on a long hold and looked at the code. The answer jumped out at me: print_ver() gets a new argument to indicate, "please do not exit" and I add: /*=export_func optionPrintVersionAndReturn * private: * * what: Print the program version * arg: + tOptions* + opts + program options descriptor + * arg: + tOptDesc* + od + the descriptor for this arg + * * doc: * This routine will print the version to stdout. =*/ void optionPrintVersionAndReturn(tOptions * opts, tOptDesc * od) { print_ver(opts, od, print_exit ? stderr : stdout, false); } "false" meaning "don't call exit()". http://autogen.sourceforge.net/data/autogen-5.18.4pre4.tar.xz On Mon, Jun 23, 2014 at 1:27 PM, Bruce Korb <bru...@gm...> wrote: > On 06/23/14 12:08, Nikos Mavrogiannopoulos wrote: >> >> On Mon, 2014-06-23 at 10:30 -0700, Bruce Korb wrote: >> On 06/22/14 03:53, Nikos Mavrogiannopoulos wrote: >>>> >>>> Hello, >>>> I'd like to override the default version string >>> >>> >>> Specify a "version-proc": >>> >>> >>> http://www.gnu.org/software/autogen/manual/html_node/automatic-options.html#automatic-options >>> >>> third paragraph. :) >> >> >> Thanks, that seems to be very close to what I want. The issue is that >> I can't combine it with optionPrintVersion(), as optionPrintVersion() >> exits, so I'd have to duplicate printing the license message, and bugs >> address. Anyway maybe, I'm nitpicking, I think it is ok by having a >> more terse version text. > > > Ah. Then: > > OPT_SET_VERSION_DOES_NOT_EXIT(&progOptions); > optionPrintVersion(&progOptions, progOptions.pOptDesc + INDEX_OPT_HELP); > > I still have 6 bits in the OPTPROC_* flags, before I have to do something > disruptive. Won't be doing it today though. :) |
From: Nikos M. <nm...@gn...> - 2014-06-24 09:58:46
|
On Tue, Jun 24, 2014 at 2:44 AM, Bruce Korb <bru...@gm...> wrote: > Never mind. I was on a long hold and looked at the code. The answer > jumped out at me: print_ver() gets a new argument to indicate, > "please do not exit" and I add: Thank you. |