eolian: scan system dir by default

The '-S' option lets you reverse that. But by default, most
people will want the prefix to be scanned for eo files.
This commit is contained in:
Daniel Kolesa 2017-11-14 13:42:38 +01:00
parent 7e83545ab3
commit 2f81b26367
6 changed files with 45 additions and 18 deletions

View File

@ -5,7 +5,7 @@ includedir=@includedir@
datarootdir=@datarootdir@
datadir=@datadir@
eoincludedir=@datadir@/eolian/include
eolian_flags=-I${pc_sysrootdir}${eoincludedir}/eo-@VMAJ@
eolian_flags=-S -I${pc_sysrootdir}${eoincludedir}/eo-@VMAJ@
Name: Eo
Description: EFL's generic object system library.

View File

@ -4,6 +4,7 @@ CLEANFILES =
BUILT_SOURCES =
EOLIAN_FLAGS = -I$(srcdir)
EOLIAN_GEN_FLAGS = -S
DIST_SUBDIRS =
SUBDIRS =

View File

@ -8,19 +8,19 @@ SUFFIXES = .eo .eo.c .eo.h .eo.legacy.h .eot .eot.h
%.eo.c: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL) \
$(MKDIR_P) $(dir $@); \
$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gc -o c:$@ $<
$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gc -o c:$@ $<
%.eo.h: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL) \
$(MKDIR_P) $(dir $@); \
$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gh -o h:$@ $<
$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gh -o h:$@ $<
%.eot.h: %.eot ${_EOLIAN_GEN_DEP}
$(AM_V_EOL) \
$(MKDIR_P) $(dir $@); \
$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gh -o h:$@ $<
$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gh -o h:$@ $<
%.eo.legacy.h: %.eo ${_EOLIAN_GEN_DEP}
$(AM_V_EOL) \
$(MKDIR_P) $(dir $@); \
$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gl -o l:$@ $<
$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gl -o l:$@ $<

View File

@ -37,6 +37,7 @@ _print_usage(const char *progn, FILE *outf)
fprintf(outf, "Usage: %s [options] [input]\n", progn);
fprintf(outf, "Options:\n"
" -I inc include path \"inc\"\n"
" -S do not scan system dir for eo files\n"
" -g type generate file of type \"type\"\n"
" -o name specify the base name for output\n"
" -o type:name specify a particular output filename\n"
@ -50,7 +51,9 @@ _print_usage(const char *progn, FILE *outf)
" c: C source file (.eo.c)\n"
" i: Implementation file (.c, merged with existing)\n"
"\n"
"By default, the 'hc' set is used ('h' for .eot files).\n"
"By default, the 'hc' set is used ('h' for .eot files).\n\n"
"The system-wide Eolian directory is scanned for eo files\n"
"by default, together with all specified '-I' flags.\n\n"
"Output filenames are determined from input .eo filename.\n"
"Default output path is where the input file is.\n\n"
"Also, specifying a type-dependent input file automatically\n"
@ -420,6 +423,10 @@ main(int argc, char **argv)
{
int pret = 1;
char *outs[5] = { NULL, NULL, NULL, NULL, NULL };
char *basen = NULL;
Eina_List *includes = NULL;
eina_init();
eolian_init();
@ -433,21 +440,20 @@ main(int argc, char **argv)
eina_log_timing(_eolian_gen_log_dom, EINA_LOG_STATE_STOP, EINA_LOG_STATE_INIT);
char *outs[5] = { NULL, NULL, NULL, NULL, NULL };
char *basen = NULL;
int gen_what = 0;
for (int opt; (opt = getopt(argc, argv, "I:g:o:hv")) != -1;)
Eina_Bool scan_system = EINA_TRUE;
for (int opt; (opt = getopt(argc, argv, "SI:g:o:hv")) != -1;)
switch (opt)
{
case 0:
break;
case 'S':
scan_system = EINA_FALSE;
break;
case 'I':
if (!eolian_directory_scan(optarg))
{
fprintf(stderr, "eolian: could not scan '%s'\n", optarg);
goto end;
}
/* just a pointer to argv contents, so it persists */
includes = eina_list_append(includes, optarg);
break;
case 'g':
for (const char *wstr = optarg; *wstr; ++wstr)
@ -522,6 +528,25 @@ main(int argc, char **argv)
goto end;
}
if (scan_system)
{
if (!eolian_system_directory_scan())
{
fprintf(stderr, "eolian: could not scan system directory\n");
goto end;
}
}
const char *inc;
EINA_LIST_FREE(includes, inc)
{
if (!eolian_directory_scan(inc))
{
fprintf(stderr, "eolian: could not scan '%s'\n", inc);
goto end;
}
}
const Eolian_Unit *src = eolian_file_parse(input);
if (!src)
{
@ -559,6 +584,7 @@ end:
eina_log_domain_unregister(_eolian_gen_log_dom);
}
eina_list_free(includes);
for (size_t i = 0; i < (sizeof(_dexts) / sizeof(char *)); ++i)
free(outs[i]);
free(basen);

View File

@ -138,10 +138,10 @@ eolian_cxx_callbacks_01_SOURCES = eolian_cxx_callbacks_01.cc
true $<
%.eo.c: %.eo
$(AM_V_EOL)$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gc -o c:$@ $<
$(AM_V_EOL)$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gc -o c:$@ $<
%.eo.h: %.eo
$(AM_V_EOL)$(EOLIAN_GEN) $(EOLIAN_FLAGS) -gh -o h:$@ $<
$(AM_V_EOL)$(EOLIAN_GEN) $(EOLIAN_FLAGS) $(EOLIAN_GEN_FLAGS) -gh -o h:$@ $<
examples: $(ECXX_EXAMPLE_EOS) $(GENERATED) $(EXTRA_PROGRAMS)

View File

@ -85,7 +85,7 @@ _eolian_gen_execute(const char *eo_filename, const char *options, const char *ou
{
char command[PATH_MAX];
snprintf(command, PATH_MAX,
EOLIAN_GEN" %s -I \""PACKAGE_DATA_DIR"/data\" -o %s %s",
EOLIAN_GEN" %s -S -I \""PACKAGE_DATA_DIR"/data\" -o %s %s",
options, output_filename, eo_filename);
return system(command);
}