From d0c20c6e01400567c9db1810d629b1dca6daece9 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Sun, 22 May 2016 11:26:16 +0200 Subject: [PATCH] Changed default compilation method to compile-on-vcom. See README.MD on how to revert to syntax-check-only behavior. --- README.md | 1 + main.c | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3f91162..e024fd1 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ VCOM ### Additional commands * -ghdl *param*: Supply these arguments directly to GHDL (can be used multiple times) +* -no-precompile: Compile the files not until calling vsim. (Faster syntax check, but longer wait time for the simulation to start.) ### Notes * *cwd* is expected to be the compile directory diff --git a/main.c b/main.c index bff3c0e..5ab0215 100644 --- a/main.c +++ b/main.c @@ -247,7 +247,7 @@ int vsim(int argc, char **argv) char *simExt = NULL; char *outFileType = NULL; char vhdlver[16] = ""; - + int precompiled = 1; FILE *fp; append_string(¶ms,""); @@ -271,6 +271,9 @@ int vsim(int argc, char **argv) fp = fopen("/tmp/model-ghdl-vcom","r"); if (fp) { + fgets(workdir, sizeof(workdir), fp); // (ab)use workdir variable as temp + if (!strcmp(workdir,"nopre\n")) + precompiled = 0; fgets(workdir, sizeof(workdir), fp); workdir[strlen(workdir)-1] = 0; fgets(vhdlver, sizeof(vhdlver), fp); @@ -344,7 +347,7 @@ int vsim(int argc, char **argv) } printf("[I] Compiling...\n"); - if (run_ghdl("ghdl -m %s --work=%s --workdir=\"%s\" %s %s", vhdlver, work, workdir, params, toplevel)) { + if (run_ghdl("ghdl -%c %s --work=%s --workdir=\"%s\" %s %s", (precompiled ? 'e' : 'm'), vhdlver, work, workdir, params, toplevel)) { fprintf(stderr, "[E] Compilation failed!"); showMessage(MESSAGE_ERROR, "Error! Compilation failed.", NULL, NULL); } @@ -390,6 +393,7 @@ int vcom(int argc, char **argv) char *files = NULL; char vhdlver[16] = ""; FILE *fp = NULL; + int precompile = 1; printf ("[I] Emulating vcom.\n"); @@ -423,6 +427,9 @@ int vcom(int argc, char **argv) else if (ISOPT("-2008")) { strcpy(vhdlver, "--std=08"); } + else if (ISOPT("-no-precompile")) { + precompile = 0; + } else if (GETOPT("-ghdl")) { append_string(¶ms, " "); append_string(¶ms, argv[i]); @@ -448,7 +455,7 @@ int vcom(int argc, char **argv) // Info for vsim later on fp = fopen("/tmp/model-ghdl-vcom","w"); if (fp) { - fprintf(fp, "%s\n%s", workdir, vhdlver); + fprintf(fp, "%s\n%s\n%s", (precompile ? "pre" : "nopre"), workdir, vhdlver); fclose(fp); } else { @@ -457,9 +464,8 @@ int vcom(int argc, char **argv) run_ghdl("ghdl -i --work=%s --workdir=%s %s %s %s 2>&1", work, workdir, vhdlver, params, files); - run_ghdl("ghdl -s --work=%s --workdir=%s %s %s %s 2>&1", - work, workdir, vhdlver, params, files); - + run_ghdl("ghdl -%c --work=%s --workdir=%s %s %s %s 2>&1", + (precompile ? 'a' : 's'), work, workdir, vhdlver, params, files); free(files);