support for regen target

git-svn-id: https://asn1c.svn.sourceforge.net/svnroot/asn1c/trunk@756 59561ff5-6e30-0410-9f3c-9617f08c8826
This commit is contained in:
vlm 2005-03-05 00:50:53 +00:00
parent 9f554a3a6f
commit 2c874fedc4
5 changed files with 22 additions and 11 deletions

View File

@ -277,7 +277,8 @@ main(int ac, char **av) {
* Compile the ASN.1 tree into a set of source files * Compile the ASN.1 tree into a set of source files
* of another language. * of another language.
*/ */
if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags)) { if(asn1_compile(asn, skeletons_dir, asn1_compiler_flags,
ac + optind, av - optind)) {
exit(EX_SOFTWARE); exit(EX_SOFTWARE);
} }

View File

@ -13,10 +13,12 @@ static int asn1c_copy_over(arg_t *arg, char *path);
static int identical_files(const char *fname1, const char *fname2); static int identical_files(const char *fname1, const char *fname2);
int int
asn1c_save_compiled_output(arg_t *arg, const char *datadir) { asn1c_save_compiled_output(arg_t *arg, const char *datadir,
int argc, char **argv) {
asn1c_fdeps_t *deps = 0; asn1c_fdeps_t *deps = 0;
FILE *mkf;
asn1c_fdeps_t *dlist; asn1c_fdeps_t *dlist;
FILE *mkf;
int i;
deps = asn1c_read_file_dependencies(arg, datadir); deps = asn1c_read_file_dependencies(arg, datadir);
if(!deps && datadir) { if(!deps && datadir) {
@ -78,7 +80,6 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
char buf[8129]; char buf[8129];
char *dir_end; char *dir_end;
size_t dlen = strlen(datadir); size_t dlen = strlen(datadir);
int i;
assert(dlen < (sizeof(buf) / 2 - 2)); assert(dlen < (sizeof(buf) / 2 - 2));
memcpy(buf, datadir, dlen); memcpy(buf, datadir, dlen);
@ -126,8 +127,14 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
"\nclean:" "\nclean:"
"\n\trm -f $(TARGET)" "\n\trm -f $(TARGET)"
"\n\trm -f $(OBJS)\n" "\n\trm -f $(OBJS)\n"
"\n" "\nregen: regenerate-from-asn1-source\n"
"\nregenerate-from-asn1-source:\n\t"
); );
for(i = 0; i < argc; i++)
fprintf(mkf, "%s%s", i ? " " : "", argv[i]);
fprintf(mkf, "\n\n");
fclose(mkf); fclose(mkf);
fprintf(stderr, "Generated Makefile.am.sample\n"); fprintf(stderr, "Generated Makefile.am.sample\n");
@ -225,7 +232,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_h, "#include <asn_application.h>\n"); fprintf(fp_h, "#include <asn_application.h>\n");
#define SAVE_STREAM(fp, idx, msg, actdep) do { \ #define SAVE_STREAM(fp, idx, msg, actdep) do { \
if(TQ_FIRST(&(cs->destination[idx].chunks)) && msg) \ if(TQ_FIRST(&(cs->destination[idx].chunks)) && *msg) \
fprintf(fp, "\n/* %s */\n", msg); \ fprintf(fp, "\n/* %s */\n", msg); \
TQ_FOR(ot, &(cs->destination[idx].chunks), next) { \ TQ_FOR(ot, &(cs->destination[idx].chunks), next) { \
if(actdep) asn1c_activate_dependency(deps, 0, ot->buf); \ if(actdep) asn1c_activate_dependency(deps, 0, ot->buf); \
@ -248,7 +255,7 @@ asn1c_save_streams(arg_t *arg, asn1c_fdeps_t *deps) {
fprintf(fp_c, "#include <asn_internal.h>\n\n"); fprintf(fp_c, "#include <asn_internal.h>\n\n");
fprintf(fp_c, "#include <%s.h>\n\n", expr->Identifier); /* Myself */ fprintf(fp_c, "#include <%s.h>\n\n", expr->Identifier); /* Myself */
if(arg->flags & A1C_NO_INCLUDE_DEPS) if(arg->flags & A1C_NO_INCLUDE_DEPS)
SAVE_STREAM(fp_c, OT_POST_INCLUDE, 0, 1); SAVE_STREAM(fp_c, OT_POST_INCLUDE, "", 1);
TQ_FOR(ot, &(cs->destination[OT_CTABLES].chunks), next) TQ_FOR(ot, &(cs->destination[OT_CTABLES].chunks), next)
fwrite(ot->buf, ot->len, 1, fp_c); fwrite(ot->buf, ot->len, 1, fp_c);
TQ_FOR(ot, &(cs->destination[OT_CODE].chunks), next) TQ_FOR(ot, &(cs->destination[OT_CODE].chunks), next)

View File

@ -1,6 +1,7 @@
#ifndef _ASN1C_SAVE_H_ #ifndef _ASN1C_SAVE_H_
#define _ASN1C_SAVE_H_ #define _ASN1C_SAVE_H_
int asn1c_save_compiled_output(arg_t *arg, const char *datadir); int asn1c_save_compiled_output(arg_t *arg, const char *datadir,
int argc, char **argv);
#endif /* _ASN1C_SAVE_H_ */ #endif /* _ASN1C_SAVE_H_ */

View File

@ -8,7 +8,8 @@ static int asn1c_compile_expr(arg_t *arg);
static int asn1c_attach_streams(asn1p_expr_t *expr); static int asn1c_attach_streams(asn1p_expr_t *expr);
int int
asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags) { asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags,
int argc, char **argv) {
arg_t arg_s; arg_t arg_s;
arg_t *arg = &arg_s; arg_t *arg = &arg_s;
int ret; int ret;
@ -56,7 +57,7 @@ asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags flags) {
/* /*
* Save or print out the compiled result. * Save or print out the compiled result.
*/ */
if(asn1c_save_compiled_output(arg, datadir)) if(asn1c_save_compiled_output(arg, datadir, argc, argv))
return -1; return -1;
return 0; return 0;

View File

@ -52,6 +52,7 @@ enum asn1c_flags {
/* /*
* Compile the ASN.1 specification. * Compile the ASN.1 specification.
*/ */
int asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags); int asn1_compile(asn1p_t *asn, const char *datadir, enum asn1c_flags,
int argc, char **argv);
#endif /* ASN1_COMPILER_H */ #endif /* ASN1_COMPILER_H */