Commit f218e785 authored by Lev Walkin's avatar Lev Walkin

CONVERTER is now in dependencies

parent f5b49399
...@@ -13,7 +13,7 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d ...@@ -13,7 +13,7 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d
return 0; return 0;
if(!cur) cur = deps; if(!cur) cur = deps;
if(cur->used_somewhere) if(cur->usage != FDEP_NOTUSED)
return 1; /* Already activated */ return 1; /* Already activated */
fname = data; fname = data;
...@@ -37,7 +37,7 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d ...@@ -37,7 +37,7 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d
} }
if(cur->filename && strcmp(cur->filename, fname) == 0) { if(cur->filename && strcmp(cur->filename, fname) == 0) {
cur->used_somewhere = 1; cur->usage = FDEP_REFERRED;
/* Activate subdependencies */ /* Activate subdependencies */
for(i = 0; i < cur->el_count; i++) { for(i = 0; i < cur->el_count; i++) {
...@@ -62,16 +62,11 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d ...@@ -62,16 +62,11 @@ asn1c_activate_dependency(asn1c_fdeps_t *deps, asn1c_fdeps_t *cur, const char *d
asn1c_fdeps_t * asn1c_fdeps_t *
asn1c_read_file_dependencies(arg_t *arg, const char *datadir) { asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
char buf[4096];
asn1c_fdeps_t *deps; asn1c_fdeps_t *deps;
asn1c_fdeps_t *cur; asn1c_fdeps_t *cur;
char buf[4096];
FILE *f; FILE *f;
enum { enum fdep_usage special_section = FDEP_REFERRED;
SS_DYNAMIC, /* Dynamic list of dependencies */
SS_CODEC_PER, /* Use contents only if -gen-PER */
SS_COMMON_FILES, /* Section for dependencies */
SS_IGNORE /* Ignore contents of this section */
} special_section = SS_DYNAMIC;
(void)arg; (void)arg;
...@@ -101,22 +96,24 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) { ...@@ -101,22 +96,24 @@ asn1c_read_file_dependencies(arg_t *arg, const char *datadir) {
* Special "prefix" section. * Special "prefix" section.
*/ */
if(strchr(p, ':')) { if(strchr(p, ':')) {
special_section = SS_IGNORE; special_section = FDEP_IGNORE;
if(strcmp(p, "COMMON-FILES:") == 0) { if(strcmp(p, "COMMON-FILES:") == 0) {
special_section = SS_COMMON_FILES; special_section = FDEP_COMMON_FILES;
} else if(strcmp(p, "CONVERTER:") == 0) {
special_section = FDEP_CONVERTER;
} else if((arg->flags & A1C_GEN_PER) } else if((arg->flags & A1C_GEN_PER)
&& strcmp(p, "CODEC-PER:") == 0) { && strcmp(p, "CODEC-PER:") == 0) {
special_section = SS_CODEC_PER; special_section = FDEP_CODEC_PER;
} }
break; break;
} }
if(special_section == SS_IGNORE) if(special_section == FDEP_IGNORE)
continue; continue;
d = asn1c_new_dep(p); d = asn1c_new_dep(p);
assert(d); assert(d);
d->used_somewhere = special_section; d->usage = special_section;
if(asn1c_dep_add(cur, d) == 1) if(asn1c_dep_add(cur, d) == 1)
cur = d; cur = d;
...@@ -178,8 +175,9 @@ asn1c_deps_makelist(asn1c_fdeps_t *deps) { ...@@ -178,8 +175,9 @@ asn1c_deps_makelist(asn1c_fdeps_t *deps) {
dlist = asn1c_new_dep(0); dlist = asn1c_new_dep(0);
if(deps->filename && deps->used_somewhere) { if(deps->filename && deps->usage != FDEP_NOTUSED) {
d = asn1c_new_dep(deps->filename); d = asn1c_new_dep(deps->filename);
d->usage = deps->usage;
asn1c_dep_add(dlist, d); asn1c_dep_add(dlist, d);
} }
......
...@@ -4,7 +4,14 @@ ...@@ -4,7 +4,14 @@
typedef struct asn1c_fdeps_s { typedef struct asn1c_fdeps_s {
char *filename; /* Or 0, if root. */ char *filename; /* Or 0, if root. */
int used_somewhere; /* Somefile refers to it */ enum fdep_usage {
FDEP_IGNORE = -1, /* Ignore contents of the section */
FDEP_NOTUSED = 0,
FDEP_REFERRED = 1, /* Dynamic list of dependencies */
FDEP_CONVERTER = 2, /* Name of the int main() file */
FDEP_COMMON_FILES = 3, /* Section for mandatory dependencies */
FDEP_CODEC_PER = 4, /* Use contents only if -gen-PER */
} usage; /* Some file refers to it */
struct asn1c_fdeps_s **elements; struct asn1c_fdeps_s **elements;
int el_size; int el_size;
......
...@@ -90,6 +90,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir, ...@@ -90,6 +90,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
*dir_end++ = '/'; *dir_end++ = '/';
for(i = 0; i < dlist->el_count; i++) { for(i = 0; i < dlist->el_count; i++) {
char *what_class; /* MODULE or CONVERTER */
char *what_kind; /* HEADERS or SOURCES */
char *fname = dlist->elements[i]->filename; char *fname = dlist->elements[i]->filename;
char *dotH; char *dotH;
...@@ -101,17 +103,26 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir, ...@@ -101,17 +103,26 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
fclose(mkf); fclose(mkf);
return -1; return -1;
} }
dotH = strrchr(fname, 'h');
if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1]) { /* MODULE data versus CONVERTER data */
fprintf(mkf, "ASN_MODULE_HEADERS+=%s\n", fname); switch(dlist->elements[i]->usage) {
} else { case FDEP_CONVERTER: what_class = "CONVERTER"; break;
fprintf(mkf, "ASN_MODULE_SOURCES+=%s\n", fname); default: what_class= "MODULE"; break;
} }
/* HEADERS versus SOURCES */
dotH = strrchr(fname, 'h');
if(dotH && fname<dotH && dotH[-1] == '.' && !dotH[1])
what_kind = "HEADERS";
else
what_kind = "SOURCES";
fprintf(mkf, "ASN_%s_%s+=%s\n",
what_class, what_kind, fname);
} }
} }
if(arg->flags & A1C_PDU_AUTO) { if(arg->flags & A1C_PDU_AUTO) {
fprintf(mkf, "ASN_MODULE_SOURCES+=pdu_collection.c\n"); fprintf(mkf, "ASN_CONVERTER_SOURCES+=pdu_collection.c\n");
if(generate_pdu_collection_file(arg)) if(generate_pdu_collection_file(arg))
return -1; return -1;
} }
...@@ -125,7 +136,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir, ...@@ -125,7 +136,8 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir,
"# Remove the lines below to convert it into a pure .am file\n" "# Remove the lines below to convert it into a pure .am file\n"
"TARGET = progname\n" "TARGET = progname\n"
"CFLAGS += -I.\n" "CFLAGS += -I.\n"
"OBJS=${ASN_MODULE_SOURCES:.c=.o} $(TARGET).o\n" "OBJS=${ASN_MODULE_SOURCES:.c=.o}"
" ${ASN_CONVERTER_SOURCES:.c=.o}\n"
"\nall: $(TARGET)\n" "\nall: $(TARGET)\n"
"\n$(TARGET): ${OBJS}" "\n$(TARGET): ${OBJS}"
"\n\t$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)\n" "\n\t$(CC) $(CFLAGS) -o $(TARGET) ${OBJS} $(LDFLAGS) $(LIBS)\n"
......
...@@ -61,6 +61,8 @@ xer_encoder.h xer_encoder.c # XER encoding support ...@@ -61,6 +61,8 @@ xer_encoder.h xer_encoder.c # XER encoding support
per_support.h per_support.c # PER parsing per_support.h per_support.c # PER parsing
per_decoder.h per_decoder.c # PER decoding support per_decoder.h per_decoder.c # PER decoding support
per_encoder.h per_encoder.c # PER encoding support per_encoder.h per_encoder.c # PER encoding support
#converter-sample.c # A sample of transcoder
CONVERTER: # THIS IS A SPECIAL SECTION
converter-sample.c # A default name for sample transcoder
CODEC-PER: # THIS IS A SPECIAL SECTION CODEC-PER: # THIS IS A SPECIAL SECTION
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment