summaryrefslogtreecommitdiffstatshomepage
path: root/src/lib/netlist/build
diff options
context:
space:
mode:
Diffstat (limited to 'src/lib/netlist/build')
-rw-r--r--src/lib/netlist/build/create_modules.py83
-rw-r--r--src/lib/netlist/build/makefile15
2 files changed, 95 insertions, 3 deletions
diff --git a/src/lib/netlist/build/create_modules.py b/src/lib/netlist/build/create_modules.py
new file mode 100644
index 00000000000..c3c9e7c19aa
--- /dev/null
+++ b/src/lib/netlist/build/create_modules.py
@@ -0,0 +1,83 @@
+#!/usr/bin/python
+##
+## license:BSD-3-Clause
+## copyright-holders:Couriersud
+
+import os
+import os.path
+import re
+import sys
+import xml.sax
+import xml.sax.saxutils
+import zlib
+import datetime
+
+
+# workaround for version incompatibility
+if sys.version_info > (3, ):
+ long = int
+
+# globals
+
+last_src = ""
+
+def process_entry(srcfile, name, params):
+ global last_src
+ if (last_src != srcfile):
+ last_src = srcfile
+ print("// ---------------------------------------------------------------------")
+ print("// Source: {}".format(srcfile))
+ print("// ---------------------------------------------------------------------")
+ print("")
+ p = re.sub("\+","",params)
+ ps = p.split(",")
+ pusage = ""
+ pauto = ""
+ for x in ps:
+ if x[0:1] == "@":
+ pauto = pauto + ", " + x[1:]
+ else:
+ pusage = pusage + ", " + x
+ print("// usage : {}(name{})".format(name, pusage))
+ if len(pauto) > 0:
+ print("// auto connect: {}".format(pauto[2:]))
+ print("#define {}(...) \\".format(name))
+ print("\tNET_REGISTER_DEVEXT({}, __VA_ARGS__)".format(name))
+ print("")
+
+
+def process_file(srcfile):
+ src = open(srcfile,'r')
+ lines = src.readlines()
+ for line in lines:
+ ls = re.sub("\s+","",line.strip())
+ ls = re.sub("^\s*//.*","",ls)
+ ls = re.sub("\"","",ls)
+ m = re.match(r"NETLIST_START\((\w+)\)", ls)
+ if m != None:
+ print("\tEXTERNAL_LIB_ENTRY("+ m.group(1) + ")")
+ src.close()
+
+if __name__ == '__main__':
+ if (len(sys.argv) == 0):
+ print('Usage:')
+ print(' create_devinc files ...')
+ sys.exit(0)
+ files_sorted = [];
+ for argno in range(1, len(sys.argv)):
+ files_sorted.append(sys.argv[argno])
+ files_sorted.sort();
+ print("// license:CC0")
+ print("// copyright-holders:Couriersud")
+ print("")
+ now = datetime.datetime.now()
+ print("// File programmatically created " + now.strftime("%c"))
+ print("")
+ print("#include \"devices/net_lib.h\"")
+ print("")
+ print("NETLIST_START(modules_lib)")
+ print("")
+ for entry in files_sorted:
+ process_file(entry)
+ print("")
+ print("NETLIST_END()")
diff --git a/src/lib/netlist/build/makefile b/src/lib/netlist/build/makefile
index 543097df807..a324acb463b 100644
--- a/src/lib/netlist/build/makefile
+++ b/src/lib/netlist/build/makefile
@@ -116,7 +116,7 @@ DEPENDCC=$(CC)
ifndef FAST
-FAST=0
+FAST=1
endif
ifeq ($(FAST),1)
@@ -138,15 +138,18 @@ OBJDIRS = $(OBJ) \
$(OBJ)/plib \
$(OBJ)/devices \
$(OBJ)/macro \
+ $(OBJ)/macro/modules \
$(OBJ)/tests \
$(OBJ)/tools \
$(OBJ)/prg \
$(OBJ)/generated \
+MODULESOURCES += $(wildcard $(SRC)/macro/modules/*.cpp)
DEVSOURCES = $(SRC)/solver/nld_solver.cpp
DEVSOURCES += $(wildcard $(SRC)/devices/*.cpp)
DEVSOURCES += $(wildcard $(SRC)/analog/*.cpp)
DEVSOURCES += $(wildcard $(SRC)/macro/*.cpp)
+DEVSOURCES += $(MODULESOURCES)
TESTSOURCES = $(wildcard $(SRC)/tests/*.cpp)
@@ -158,6 +161,7 @@ CORESOURCES := \
$(SRC)/nl_factory.cpp \
$(SRC)/tools/nl_convert.cpp \
$(SRC)/generated/static_solvers.cpp \
+ $(SRC)/generated/nlm_modules_lib.cpp \
MAINSOURCES = $(SRC)/prg/nltool.cpp $(SRC)/prg/nlwav.cpp
@@ -287,7 +291,8 @@ clang-libc:
-Wmissing-variable-declarations -Wno-float-equal -Wconversion \
-Wno-c++98-compat -Wno-c++98-compat-pedantic -Wformat-nonliteral \
-Wno-exit-time-destructors -Winconsistent-missing-destructor-override \
- -Wno-return-std-move-in-c++11 -Wno-unreachable-code" \
+ -Wno-return-std-move-in-c++11 -Wno-unreachable-code \
+ -Wno-missing-prototypes" \
LDEXTRAFLAGS=-stdlib=libc++
clang-5:
@@ -360,8 +365,12 @@ $(SRC)/generated/nld_devinc.h: $(DEVSOURCES)
@echo creating $@
$(PYTHON) create_devinc.py $^ > $@
+$(SRC)/generated/nlm_modules_lib.cpp: $(MODULESOURCES)
+ @echo creating $@
+ $(PYTHON) create_modules.py $^ > $@
+
.PHONY: generated
-generated: ../generated/lib_entries.hxx ../generated/nld_devinc.h
+generated: $(SRC)/generated/lib_entries.hxx $(SRC)/generated/nld_devinc.h $(SRC)/generated/nlm_modules_lib.cpp
#-------------------------------------------------
# clang tidy