Commit 42fd1bb6 authored by Claes Sjofors's avatar Claes Sjofors

msg2cmsg also generates python msg files

parent ec6c4107
...@@ -16,11 +16,11 @@ endif ...@@ -16,11 +16,11 @@ endif
$(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg $(bld_dir)/%.cmsg $(inc_dir)/%.h: %.msg
@ $(log_msg_h) @ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h @ $(tools_msg2cmsg) $(source) $(bld_dir)/$(tname).cmsg $(inc_dir)/$(tname).h $(exe_dir)/$(tname).py
$(obj_dir)/%.cmsg $(inc_dir)/%.h : %.msg $(obj_dir)/%.cmsg $(inc_dir)/%.h : %.msg
@ $(log_msg_h) @ $(log_msg_h)
@ $(tools_msg2cmsg) $(source) $(obj_dir)/$(tname).cmsg $(inc_dir)/$(tname).h @ $(tools_msg2cmsg) $(source) $(obj_dir)/$(tname).cmsg $(inc_dir)/$(tname).h $(exe_dir)/$(tname).py
$(obj_dir)/%.o : $(obj_dir)/%.cmsg $(obj_dir)/%.o : $(obj_dir)/%.cmsg
@ $(log_cmsg_obj) @ $(log_cmsg_obj)
......
...@@ -219,7 +219,7 @@ static void lex(FILE* fp) { ...@@ -219,7 +219,7 @@ static void lex(FILE* fp) {
} }
} }
static void WriteFiles(char* fname, FILE* cfp, FILE* hfp) static void WriteFiles(char* fname, FILE* cfp, FILE* hfp, FILE *pfp)
{ {
struct LstHead * fl; struct LstHead * fl;
struct LstHead * ml; struct LstHead * ml;
...@@ -255,6 +255,8 @@ static void WriteFiles(char* fname, FILE* cfp, FILE* hfp) ...@@ -255,6 +255,8 @@ static void WriteFiles(char* fname, FILE* cfp, FILE* hfp)
msg = facid + 0x8000 + (idx << 3) + LstEntry(ml, sMsgCB, MsgL)->Severity; msg = facid + 0x8000 + (idx << 3) + LstEntry(ml, sMsgCB, MsgL)->Severity;
snprintf(name, sizeof(name), "%s%s", prefix, LstEntry(ml, sMsgCB, MsgL)->m.MsgName); snprintf(name, sizeof(name), "%s%s", prefix, LstEntry(ml, sMsgCB, MsgL)->m.MsgName);
fprintf(hfp, "#define %-29s %9.9d /* x%08x */\n", name, msg, msg); fprintf(hfp, "#define %-29s %9.9d /* x%08x */\n", name, msg, msg);
if (pfp)
fprintf(pfp, "%s = %d\n", name, msg);
fprintf(cfp, "\t{\"%s\", \"%s\"}", LstEntry(ml, sMsgCB, MsgL)->m.MsgName, fprintf(cfp, "\t{\"%s\", \"%s\"}", LstEntry(ml, sMsgCB, MsgL)->m.MsgName,
LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt); LstEntry(ml, sMsgCB, MsgL)->m.MsgTxt);
idx++; idx++;
...@@ -275,10 +277,11 @@ int main(int argc, char** argv) ...@@ -275,10 +277,11 @@ int main(int argc, char** argv)
{ {
FILE* cfp = NULL; FILE* cfp = NULL;
FILE* hfp = NULL; FILE* hfp = NULL;
FILE* pfp = NULL;
FILE* in = NULL; FILE* in = NULL;
if (argc != 4) { if (!(argc == 4 || argc == 5)) {
printf("Usage: co_msg2cmsg msg-file c_msg-file h_file\n"); printf("Usage: co_msg2cmsg msg-file c_msg-file h-file [py-file]\n");
exit(2); exit(2);
} }
...@@ -301,6 +304,16 @@ int main(int argc, char** argv) ...@@ -301,6 +304,16 @@ int main(int argc, char** argv)
exit(2); exit(2);
} }
if (argc >= 5) {
if (!(pfp = fopen(argv[4], "w"))) {
printf("Can't open python-output file: %s\n", argv[4]);
fclose(in);
fclose(cfp);
fclose(hfp);
exit(2);
}
}
LstInit(&lFacH); LstInit(&lFacH);
lex(in); lex(in);
...@@ -314,11 +327,13 @@ int main(int argc, char** argv) ...@@ -314,11 +327,13 @@ int main(int argc, char** argv)
if ((p = strchr(fname, '.'))) if ((p = strchr(fname, '.')))
*p = '\0'; *p = '\0';
WriteFiles(fname, cfp, hfp); WriteFiles(fname, cfp, hfp, pfp);
fclose(in); fclose(in);
fclose(cfp); fclose(cfp);
fclose(hfp); fclose(hfp);
if (pfp)
fclose(pfp);
return 0; return 0;
} }
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