Commit 866cff1a authored by Lev Walkin's avatar Lev Walkin

support for regen target

parent b9b8b959
......@@ -277,7 +277,8 @@ main(int ac, char **av) {
* Compile the ASN.1 tree into a set of source files
* 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);
}
......
......@@ -13,10 +13,12 @@ static int asn1c_copy_over(arg_t *arg, char *path);
static int identical_files(const char *fname1, const char *fname2);
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;
FILE *mkf;
asn1c_fdeps_t *dlist;
FILE *mkf;
int i;
deps = asn1c_read_file_dependencies(arg, datadir);
if(!deps && datadir) {
......@@ -78,7 +80,6 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
char buf[8129];
char *dir_end;
size_t dlen = strlen(datadir);
int i;
assert(dlen < (sizeof(buf) / 2 - 2));
memcpy(buf, datadir, dlen);
......@@ -126,8 +127,14 @@ asn1c_save_compiled_output(arg_t *arg, const char *datadir) {
"\nclean:"
"\n\trm -f $(TARGET)"
"\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);
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");
#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); \
TQ_FOR(ot, &(cs->destination[idx].chunks), next) { \
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 <%s.h>\n\n", expr->Identifier); /* Myself */
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)
fwrite(ot->buf, ot->len, 1, fp_c);
TQ_FOR(ot, &(cs->destination[OT_CODE].chunks), next)
......
#ifndef _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_ */
......@@ -8,7 +8,8 @@ static int asn1c_compile_expr(arg_t *arg);
static int asn1c_attach_streams(asn1p_expr_t *expr);
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 = &arg_s;
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.
*/
if(asn1c_save_compiled_output(arg, datadir))
if(asn1c_save_compiled_output(arg, datadir, argc, argv))
return -1;
return 0;
......
......@@ -52,6 +52,7 @@ enum asn1c_flags {
/*
* 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 */
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