From: Clifford Wolf Date: Sun, 15 Feb 2015 11:09:30 +0000 (+0100) Subject: More emscripten stuff, Added example app X-Git-Tag: yosys-0.6~432 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=3216f9420e2f5aed0aa3e38ff89ab616db9b0849;p=yosys.git More emscripten stuff, Added example app --- diff --git a/.gitignore b/.gitignore index 841b0ffa2..f48aeac5f 100644 --- a/.gitignore +++ b/.gitignore @@ -13,13 +13,13 @@ /abc /yosys /yosys.exe +/yosys.js /yosys.html /yosys-abc /yosys-abc.exe /yosys-config /yosys-filterlib /yosys-filterlib.exe -/yosys-filterlib.html /kernel/version_*.cc /share /libyosys diff --git a/Makefile b/Makefile index 502d2c205..775fce1ad 100644 --- a/Makefile +++ b/Makefile @@ -95,9 +95,10 @@ CXXFLAGS += -std=gnu++0x -Os else ifeq ($(CONFIG),emcc) CXX = emcc -CXXFLAGS := -std=c++11 $(filter-out -ggdb,$(CXXFLAGS)) +CXXFLAGS := -std=c++11 $(filter-out -fPIC,$(filter-out -ggdb,$(CXXFLAGS))) EMCCFLAGS := -Os -Wno-warn-absolute-paths -EMCCFLAGS += --memory-init-file 0 +EMCCFLAGS += --memory-init-file 0 -s NO_EXIT_RUNTIME=1 +EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt']" # https://github.com/kripken/emscripten/blob/master/src/settings.js # EMCCFLAGS += -s ALLOW_MEMORY_GROWTH=1 # EMCCFLAGS += -s DISABLE_EXCEPTION_CATCHING=0 @@ -108,7 +109,11 @@ EMCCFLAGS += --memory-init-file 0 CXXFLAGS += $(EMCCFLAGS) LDFLAGS += $(EMCCFLAGS) LDLIBS = -EXE = .html +EXE = .js + +EXTRA_TARGETS += yosys.html +yosys.html: misc/yosys.html + $(P) cp misc/yosys.html yosys.html else ifeq ($(CONFIG),mxe) CXX = /usr/local/src/mxe/usr/bin/i686-pc-mingw32-gcc diff --git a/kernel/driver.cc b/kernel/driver.cc index 116df542c..6df7cf2e8 100644 --- a/kernel/driver.cc +++ b/kernel/driver.cc @@ -72,6 +72,32 @@ int getopt(int argc, char **argv, const char *optstring) USING_YOSYS_NAMESPACE +#ifdef EMSCRIPTEN + +extern "C" int main(int, char**); +extern "C" void run(const char*); +extern "C" const char *prompt(); + +int main(int, char**) +{ + log_files.push_back(stdout); + log_error_stderr = true; + yosys_banner(); + yosys_setup(); +} + +void run(const char *command) +{ + run_pass(command); +} + +const char *prompt() +{ + return create_prompt(yosys_get_design(), 0); +} + +#else /* EMSCRIPTEN */ + int main(int argc, char **argv) { std::string frontend_command = "auto"; @@ -440,3 +466,5 @@ int main(int argc, char **argv) return 0; } +#endif /* EMSCRIPTEN */ + diff --git a/misc/yosys.html b/misc/yosys.html new file mode 100644 index 000000000..c82bc1871 --- /dev/null +++ b/misc/yosys.html @@ -0,0 +1,60 @@ + + + yosys.js example application + + +

yosys.js example application

+
+

yosys>
+ + + + diff --git a/passes/techmap/Makefile.inc b/passes/techmap/Makefile.inc index d8a433164..6b6846e20 100644 --- a/passes/techmap/Makefile.inc +++ b/passes/techmap/Makefile.inc @@ -24,9 +24,11 @@ passes/techmap/techmap.inc: techlibs/common/techmap.v passes/techmap/techmap.o: passes/techmap/techmap.inc +ifneq ($(CONFIG),emcc) TARGETS += yosys-filterlib$(EXE) EXTRA_OBJS += passes/techmap/filterlib.o yosys-filterlib$(EXE): passes/techmap/filterlib.o $(P) $(CXX) -o yosys-filterlib$(EXE) $(LDFLAGS) $^ $(LDLIBS) +endif