aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZipCPU <dgisselq@ieee.org>2018-06-05 11:39:27 -0400
committerZipCPU <dgisselq@ieee.org>2018-06-05 11:39:27 -0400
commitbd08f9e698269764d9e06052470d4a699f69f951 (patch)
treebdf7bdd53665896e241f1d65682f4f3ad2cc9cfe
parent8b6f8382b8d80147e6528238ae7a7cf642daaa07 (diff)
downloadnextpnr-bd08f9e698269764d9e06052470d4a699f69f951.tar.gz
nextpnr-bd08f9e698269764d9e06052470d4a699f69f951.tar.bz2
nextpnr-bd08f9e698269764d9e06052470d4a699f69f951.zip
Removed the log_ dependencies from json-parser
-rw-r--r--common/log.cc19
-rw-r--r--common/log.h1
-rw-r--r--frontend/json/jsonparse.cc39
3 files changed, 12 insertions, 47 deletions
diff --git a/common/log.cc b/common/log.cc
index 86379186..84150a15 100644
--- a/common/log.cc
+++ b/common/log.cc
@@ -102,17 +102,12 @@ void logv(const char *format, va_list ap)
*f << str;
}
-void logv_header(const char *format, va_list ap)
+void logv_info(const char *format, va_list ap)
{
-/*
- log_spacer();
-
- std::string header_id;
+ std::string message = vstringf(format, ap);
- log("%s. ", header_id.c_str());
- logv(format, ap);
+ log("Info: %s", message.c_str());
log_flush();
-*/
}
void logv_warning(const char *format, va_list ap)
@@ -155,9 +150,9 @@ void logv_error(const char *format, va_list ap)
log_files = backup_log_files;
throw 0;
#elif defined(_MSC_VER)
- _exit(1);
+ _exit(EXIT_FAILURE);
#else
- _Exit(1);
+ _Exit(EXIT_FAILURE);
#endif
}
@@ -169,11 +164,11 @@ void log(const char *format, ...)
va_end(ap);
}
-void log_header(const char *format, ...)
+void log_info(const char *format, ...)
{
va_list ap;
va_start(ap, format);
- logv_header(format, ap);
+ logv_info(format, ap);
va_end(ap);
}
diff --git a/common/log.h b/common/log.h
index c2a4ab0f..259a30a1 100644
--- a/common/log.h
+++ b/common/log.h
@@ -56,6 +56,7 @@ NXP_NORETURN void logv_error(const char *format, va_list ap)
void log(const char *format, ...);
void log_header(const char *format, ...);
+void log_info(const char *format, ...);
void log_warning(const char *format, ...);
void log_warning_noprefix(const char *format, ...);
NXP_NORETURN void log_error(const char *format, ...);
diff --git a/frontend/json/jsonparse.cc b/frontend/json/jsonparse.cc
index 2f5ab602..9e8aecbe 100644
--- a/frontend/json/jsonparse.cc
+++ b/frontend/json/jsonparse.cc
@@ -25,6 +25,7 @@
#include <iostream>
#include <fstream>
#include <assert.h>
+#include <log.h>
#include "common/design.h"
#include "ice40/chip.h"
#warning "CC files shouldnt be included"
@@ -36,41 +37,8 @@
namespace JsonParser {
-void log_error(const char fmt, ...) {
- va_list args;
-
- std::string sfmt = "ERROR: " + fmt;
- va_start(args, fmt);
- vfprintf(stderr, fmt, args);
- va_end(args);
- exit(EXIT_FAILURE);
-}
-
-void log_warning(const char fmt, ...) {
- va_list args;
-
- std::string sfmt = "WARNING: " + fmt;
- va_start(args, fmt);
- vfprintf(stderr, sfmt.c_str(), args);
- va_end(args);
-}
-
-void log_info(const char fmt, ...) {
- va_list args;
-
- std::string sfmt = "INFO: " + fmt;
- va_start(args, fmt);
- vfprintf(stderr, sfmt.c_str(), args);
- va_end(args);
-}
-
typedef std::string string;
-void log_header(Design *d, const char *str) {
- std::cout << str;
- // log_header(design, "Executing JSON frontend.\n");
-}
-
template<typename T> int GetSize(const T &obj) { return obj.size(); }
@@ -487,7 +455,7 @@ struct JsonFrontend {
virtual void execute(std::istream *&f, std::string filename,
Design *design)
{
- log_header(design, "Executing JSON frontend.\n");
+ // log_header(design, "Executing JSON frontend.\n");
JsonNode root(*f);
@@ -501,7 +469,6 @@ struct JsonFrontend {
if (modules->type != 'D')
log_error("JSON modules node is not a dictionary.\n");
-fprintf(stderr, "Looping\n");
for (auto &it : modules->data_dict)
json_import(design, it.first, it.second);
}
@@ -521,6 +488,8 @@ int main(int argc, char **argv) {
std::string fname = "../../ice40/blinky.json";
std::istream *f = new std::ifstream(fname);
parser->execute(f, fname, design);
+
+ printf("Successful exit\n");
}
int num_wires_384 = 0;