summaryrefslogtreecommitdiff
path: root/src/bin/eldbus
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 /src/bin/eldbus
parentf1bcd804eccef1778873598d073d8fb2e550f275 (diff)
eldbus: support output dir in codegen
@feature
Diffstat (limited to 'src/bin/eldbus')
-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 c82ee3c..c67da0c4 100644
--- a/src/bin/eldbus/client.c
+++ b/src/bin/eldbus/client.c
@@ -4,6 +4,8 @@
4 4
5#include "codegen.h" 5#include "codegen.h"
6 6
7char *output_dir = NULL;
8
7static const Ecore_Getopt optdesc = { 9static const Ecore_Getopt optdesc = {
8 "eldbus_codegen", 10 "eldbus_codegen",
9 "%prog [options] <file.xml>", 11 "%prog [options] <file.xml>",
@@ -16,6 +18,7 @@ static const Ecore_Getopt optdesc = {
16 ECORE_GETOPT_STORE_STR('p', "prefix", "The prefix for the generated code."), 18 ECORE_GETOPT_STORE_STR('p', "prefix", "The prefix for the generated code."),
17 ECORE_GETOPT_STORE_STR('i', "interface", "To generate code of only one interface of xml."), 19 ECORE_GETOPT_STORE_STR('i', "interface", "To generate code of only one interface of xml."),
18 ECORE_GETOPT_STORE_STR('o', "output file name", "The name of output files, only used if a interface is selected."), 20 ECORE_GETOPT_STORE_STR('o', "output file name", "The name of output files, only used if a interface is selected."),
21 ECORE_GETOPT_STORE_STR('O', "output dir", "The directory to output files to."),
19 ECORE_GETOPT_LICENSE('L', "license"), 22 ECORE_GETOPT_LICENSE('L', "license"),
20 ECORE_GETOPT_COPYRIGHT('C', "copyright"), 23 ECORE_GETOPT_COPYRIGHT('C', "copyright"),
21 ECORE_GETOPT_VERSION('V', "version"), 24 ECORE_GETOPT_VERSION('V', "version"),
@@ -36,6 +39,7 @@ main(int argc, char **argv)
36 ECORE_GETOPT_VALUE_STR(prefix), 39 ECORE_GETOPT_VALUE_STR(prefix),
37 ECORE_GETOPT_VALUE_STR(interface), 40 ECORE_GETOPT_VALUE_STR(interface),
38 ECORE_GETOPT_VALUE_STR(output), 41 ECORE_GETOPT_VALUE_STR(output),
42 ECORE_GETOPT_VALUE_STR(output_dir),
39 ECORE_GETOPT_VALUE_BOOL(quit_option), 43 ECORE_GETOPT_VALUE_BOOL(quit_option),
40 ECORE_GETOPT_VALUE_BOOL(quit_option), 44 ECORE_GETOPT_VALUE_BOOL(quit_option),
41 ECORE_GETOPT_VALUE_BOOL(quit_option), 45 ECORE_GETOPT_VALUE_BOOL(quit_option),
diff --git a/src/bin/eldbus/codegen.h b/src/bin/eldbus/codegen.h
index ffcaf99..4f9ba76 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
110char *dbus_name_to_c(const char *dbus); 110char *dbus_name_to_c(const char *dbus);
111char *string_build(const char *fmt, ...); 111char *string_build(const char *fmt, ...);
112char *get_pieces(const char *string, char break_in, int amount); 112char *get_pieces(const char *string, char break_in, int amount);
113
114extern char *output_dir;
diff --git a/src/bin/eldbus/utils.c b/src/bin/eldbus/utils.c
index 514c209..aaad290 100644
--- a/src/bin/eldbus/utils.c
+++ b/src/bin/eldbus/utils.c
@@ -34,8 +34,16 @@ Eina_Bool
34file_write(const char *file_name, const char *buffer) 34file_write(const char *file_name, const char *buffer)
35{ 35{
36 FILE *file_handler; 36 FILE *file_handler;
37 const char *filename = file_name;
38 Eina_Strbuf *fname = NULL;
37 39
38 file_handler = fopen(file_name, "wt"); 40 if (output_dir)
41 {
42 fname = eina_strbuf_new();
43 eina_strbuf_append_printf(fname, "%s/%s", output_dir, file_name);
44 filename = eina_strbuf_string_get(fname);
45 }
46 file_handler = fopen(filename, "wt");
39 if (!file_handler) 47 if (!file_handler)
40 { 48 {
41 printf("Error to write file: %s\n", file_name); 49 printf("Error to write file: %s\n", file_name);
@@ -47,6 +55,7 @@ file_write(const char *file_name, const char *buffer)
47 printf("Error writing to file: %s\n", file_name); 55 printf("Error writing to file: %s\n", file_name);
48 } 56 }
49 fclose(file_handler); 57 fclose(file_handler);
58 eina_strbuf_free(fname);
50 59
51 return EINA_TRUE; 60 return EINA_TRUE;
52} 61}