summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@osg.samsung.com>2017-07-17 12:57:19 -0400
committerMike Blumenkrantz <zmike@osg.samsung.com>2017-07-18 11:34:18 -0400
commitc5155d2fccc020958c9a2d129076aec51f536d7f (patch)
tree77d79306c27bb56b0267f3950154b49e803f6968
parentf1bcd804eccef1778873598d073d8fb2e550f275 (diff)
downloadefl-c5155d2fccc020958c9a2d129076aec51f536d7f.tar.gz
eldbus: support output dir in codegen
@feature
-rw-r--r--src/bin/eldbus/client.c4
-rw-r--r--src/bin/eldbus/codegen.h2
-rw-r--r--src/bin/eldbus/utils.c11
3 files changed, 16 insertions, 1 deletions
diff --git a/src/bin/eldbus/client.c b/src/bin/eldbus/client.c
index c82ee3c8eb..c67da0c427 100644
--- a/src/bin/eldbus/client.c
+++ b/src/bin/eldbus/client.c
@@ -4,6 +4,8 @@
#include "codegen.h"
+char *output_dir = NULL;
+
static const Ecore_Getopt optdesc = {
"eldbus_codegen",
"%prog [options] <file.xml>",
@@ -16,6 +18,7 @@ static const Ecore_Getopt optdesc = {
ECORE_GETOPT_STORE_STR('p', "prefix", "The prefix for the generated code."),
ECORE_GETOPT_STORE_STR('i', "interface", "To generate code of only one interface of xml."),
ECORE_GETOPT_STORE_STR('o', "output file name", "The name of output files, only used if a interface is selected."),
+ ECORE_GETOPT_STORE_STR('O', "output dir", "The directory to output files to."),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"),
@@ -36,6 +39,7 @@ main(int argc, char **argv)
ECORE_GETOPT_VALUE_STR(prefix),
ECORE_GETOPT_VALUE_STR(interface),
ECORE_GETOPT_VALUE_STR(output),
+ ECORE_GETOPT_VALUE_STR(output_dir),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
diff --git a/src/bin/eldbus/codegen.h b/src/bin/eldbus/codegen.h
index ffcaf993ef..4f9ba76592 100644
--- a/src/bin/eldbus/codegen.h
+++ b/src/bin/eldbus/codegen.h
@@ -110,3 +110,5 @@ char *replace_string(const char *string, const char *substr, const char *replace
char *dbus_name_to_c(const char *dbus);
char *string_build(const char *fmt, ...);
char *get_pieces(const char *string, char break_in, int amount);
+
+extern char *output_dir;
diff --git a/src/bin/eldbus/utils.c b/src/bin/eldbus/utils.c
index 514c209069..aaad290609 100644
--- a/src/bin/eldbus/utils.c
+++ b/src/bin/eldbus/utils.c
@@ -34,8 +34,16 @@ Eina_Bool
file_write(const char *file_name, const char *buffer)
{
FILE *file_handler;
+ const char *filename = file_name;
+ Eina_Strbuf *fname = NULL;
- file_handler = fopen(file_name, "wt");
+ if (output_dir)
+ {
+ fname = eina_strbuf_new();
+ eina_strbuf_append_printf(fname, "%s/%s", output_dir, file_name);
+ filename = eina_strbuf_string_get(fname);
+ }
+ file_handler = fopen(filename, "wt");
if (!file_handler)
{
printf("Error to write file: %s\n", file_name);
@@ -47,6 +55,7 @@ file_write(const char *file_name, const char *buffer)
printf("Error writing to file: %s\n", file_name);
}
fclose(file_handler);
+ eina_strbuf_free(fname);
return EINA_TRUE;
}