[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [help-gengetopt] [feature-request] different output folders for *.h
From: |
Yegor Yefremov |
Subject: |
Re: [help-gengetopt] [feature-request] different output folders for *.h and *.c and dummy conf file |
Date: |
Thu, 17 Sep 2009 17:14:21 +0200 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.8.1.23) Gecko/20090812 Lightning/0.9 Thunderbird/2.0.0.23 Mnenhy/0.7.6.666 |
Hi Lorenzo,
I've made a quick patch to enable different output folders for *.h and *.c
files. Could you review it?
Add --header-output-dir and --src_output-dir to store cmdline.h separately from
cmdline.c
Signed-off-by: Yegor Yefremov <address@hidden>
Index: gengetopt/src/cmdline.ggo
===================================================================
--- gengetopt.orig/src/cmdline.ggo
+++ gengetopt/src/cmdline.ggo
@@ -73,6 +73,8 @@ option "file-name" F "name of gener
option "output-dir" - "output directory" string typestr="path" optional
details="\nif this option is not specified, the \
files are generated in the current directory.\n"
+option "header-output-dir" - "header output directory" string
typestr="path" optional
+option "src-output-dir" - "source output directory" string
typestr="path" optional
option "c-extension" c "extension of c file" string typestr="ext"
default="c" optional
option "header-extension" H "extension of header file" string typestr="ext"
default="h" optional
option "long-help" l "long usage line in help" optional
Index: gengetopt/src/gengetopt.cc
===================================================================
--- gengetopt.orig/src/gengetopt.cc
+++ gengetopt/src/gengetopt.cc
@@ -108,7 +108,7 @@ main (int argc, char **argv)
char *cmdline_filename ; /* name of generated file */
char *c_ext ; /* extenstion of c file */
char *header_ext ; /* extenstion of header file */
- string output_dir; /* output directory (default empty -> current dir)*/
+ string output_dir, header_output_dir, src_output_dir; /* output directory
(default empty -> current dir)*/
int i, has_help, has_version;
FILE *input_file ;
@@ -252,6 +252,10 @@ main (int argc, char **argv)
if (args_info.output_dir_given)
output_dir = args_info.output_dir_arg;
+ if (args_info.header_output_dir_given)
+ header_output_dir = args_info.header_output_dir_arg;
+ if (args_info.src_output_dir_given)
+ src_output_dir = args_info.src_output_dir_arg;
CmdlineParserCreator cmdline_parser_creator
(cmdline_parser_name,
@@ -273,6 +277,8 @@ main (int argc, char **argv)
no_options,
command_line.str (),
output_dir,
+ header_output_dir,
+ src_output_dir,
(args_info.show_required_given ? args_info.show_required_arg : ""));
if (! gengetopt_package && (args_info.show_version_given ||
args_info.show_help_given))
Index: gengetopt/src/gm.cc
===================================================================
--- gengetopt.orig/src/gm.cc
+++ gengetopt/src/gm.cc
@@ -167,10 +167,14 @@ CmdlineParserCreator::CmdlineParserCreat
bool no_options_,
const string &comment_,
const string &outdir,
+ const string &header_outdir,
+ const string &src_outdir,
const string &show_required) :
filename (filename_),
args_info_name (struct_name),
output_dir (outdir),
+ header_output_dir (header_outdir),
+ src_output_dir (src_outdir),
comment (comment_),
unamed_options (unamed_options_),
show_required_string (show_required),
@@ -378,7 +382,9 @@ CmdlineParserCreator::generate_header_fi
/* ****************************************************** */
string header_file = header_filename;
- if (output_dir.size())
+ if (header_output_dir.size())
+ header_file = header_output_dir + "/" + header_file;
+ else if (output_dir.size())
header_file = output_dir + "/" + header_file;
ofstream *output_file = open_fstream
@@ -1947,7 +1953,10 @@ CmdlineParserCreator::generate_source ()
set_getopt_string (generate_getopt_string ());
string output_source = c_filename;
- if (output_dir.size())
+
+ if (src_output_dir.size())
+ output_source = src_output_dir + "/" + output_source;
+ else if (output_dir.size())
output_source = output_dir + "/" + output_source;
ofstream *output_file = open_fstream (output_source.c_str());
Index: gengetopt/src/gm.h
===================================================================
--- gengetopt.orig/src/gm.h
+++ gengetopt/src/gm.h
@@ -42,6 +42,8 @@ class CmdlineParserCreator : public head
char *header_filename;
char *c_filename;
string output_dir;
+ string header_output_dir;
+ string src_output_dir;
string comment;
char *unamed_options;
string show_required_string;
@@ -138,6 +140,8 @@ class CmdlineParserCreator : public head
bool gen_version, bool gen_getopt, bool no_options,
const string &comment,
const string &outdir,
+ const string &header_outdir,
+ const string &src_outdir,
const string &show_required);
int generate();