mirror of https://github.com/YosysHQ/yosys.git
More emcc stuff
This commit is contained in:
parent
c2cc342e1a
commit
8d45f81046
5
Makefile
5
Makefile
|
@ -95,10 +95,11 @@ CXXFLAGS += -std=gnu++0x -Os
|
||||||
|
|
||||||
else ifeq ($(CONFIG),emcc)
|
else ifeq ($(CONFIG),emcc)
|
||||||
CXX = emcc
|
CXX = emcc
|
||||||
CXXFLAGS := -std=c++11 $(filter-out -fPIC,$(filter-out -ggdb,$(CXXFLAGS)))
|
CXXFLAGS := -std=c++11 $(filter-out -fPIC -ggdb,$(CXXFLAGS))
|
||||||
EMCCFLAGS := -Os -Wno-warn-absolute-paths
|
EMCCFLAGS := -Os -Wno-warn-absolute-paths
|
||||||
EMCCFLAGS += --memory-init-file 0 -s NO_EXIT_RUNTIME=1
|
EMCCFLAGS += --memory-init-file 0 -s NO_EXIT_RUNTIME=1
|
||||||
EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt']"
|
EMCCFLAGS += -s EXPORTED_FUNCTIONS="['_main','_run','_prompt']"
|
||||||
|
EMCCFLAGS += --embed-file share
|
||||||
# https://github.com/kripken/emscripten/blob/master/src/settings.js
|
# https://github.com/kripken/emscripten/blob/master/src/settings.js
|
||||||
# EMCCFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
# EMCCFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
||||||
# EMCCFLAGS += -s DISABLE_EXCEPTION_CATCHING=0
|
# EMCCFLAGS += -s DISABLE_EXCEPTION_CATCHING=0
|
||||||
|
@ -111,7 +112,9 @@ LDFLAGS += $(EMCCFLAGS)
|
||||||
LDLIBS =
|
LDLIBS =
|
||||||
EXE = .js
|
EXE = .js
|
||||||
|
|
||||||
|
TARGETS := $(filter-out yosys-config,$(TARGETS))
|
||||||
EXTRA_TARGETS += yosys.html
|
EXTRA_TARGETS += yosys.html
|
||||||
|
|
||||||
yosys.html: misc/yosys.html
|
yosys.html: misc/yosys.html
|
||||||
$(P) cp misc/yosys.html yosys.html
|
$(P) cp misc/yosys.html yosys.html
|
||||||
|
|
||||||
|
|
|
@ -619,26 +619,33 @@ std::string proc_self_dirname()
|
||||||
#error Dont know how to determine process executable base path!
|
#error Dont know how to determine process executable base path!
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef EMSCRIPTEN
|
||||||
|
std::string proc_share_dirname()
|
||||||
|
{
|
||||||
|
return "/share";
|
||||||
|
}
|
||||||
|
#else
|
||||||
std::string proc_share_dirname()
|
std::string proc_share_dirname()
|
||||||
{
|
{
|
||||||
std::string proc_self_path = proc_self_dirname();
|
std::string proc_self_path = proc_self_dirname();
|
||||||
#ifdef _WIN32
|
# ifdef _WIN32
|
||||||
std::string proc_share_path = proc_self_path + "share\\";
|
std::string proc_share_path = proc_self_path + "share\\";
|
||||||
if (check_file_exists(proc_share_path, true))
|
if (check_file_exists(proc_share_path, true))
|
||||||
return proc_share_path;
|
return proc_share_path;
|
||||||
proc_share_path = proc_self_path + "..\\share\\";
|
proc_share_path = proc_self_path + "..\\share\\";
|
||||||
if (check_file_exists(proc_share_path, true))
|
if (check_file_exists(proc_share_path, true))
|
||||||
return proc_share_path;
|
return proc_share_path;
|
||||||
#else
|
# else
|
||||||
std::string proc_share_path = proc_self_path + "share/";
|
std::string proc_share_path = proc_self_path + "share/";
|
||||||
if (check_file_exists(proc_share_path, true))
|
if (check_file_exists(proc_share_path, true))
|
||||||
return proc_share_path;
|
return proc_share_path;
|
||||||
proc_share_path = proc_self_path + "../share/yosys/";
|
proc_share_path = proc_self_path + "../share/yosys/";
|
||||||
if (check_file_exists(proc_share_path, true))
|
if (check_file_exists(proc_share_path, true))
|
||||||
return proc_share_path;
|
return proc_share_path;
|
||||||
#endif
|
# endif
|
||||||
log_error("proc_share_dirname: unable to determine share/ directory!\n");
|
log_error("proc_share_dirname: unable to determine share/ directory!\n");
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool fgetline(FILE *f, std::string &buffer)
|
bool fgetline(FILE *f, std::string &buffer)
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,18 +4,18 @@
|
||||||
<h1>yosys.js example application</h1>
|
<h1>yosys.js example application</h1>
|
||||||
<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div>
|
<div><textarea id="output" style="width: 100%" rows="30" cols="100"></textarea></div>
|
||||||
<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div>
|
<div id="wait" style="display: block"><br/><b><span id="waitmsg">Loading...</span></b></div>
|
||||||
<div id="input" style="display: none"><form onsubmit="return run_command()"><tt><span id="prompt"><br/>yosys> </span></tt><input id="command" type="text" size="100"></form></div>
|
<div id="input" style="display: none"><form onsubmit="window.setTimeout(run_command); return false"><tt><span id="prompt">
|
||||||
|
</span></tt><input id="command" type="text" style="font-family: monospace; font-weight: bold;" size="100"></form></div>
|
||||||
<script type='text/javascript'>
|
<script type='text/javascript'>
|
||||||
var got_log_messages = false;
|
var got_log_messages = false;
|
||||||
|
|
||||||
var Module = {
|
var Module = {
|
||||||
print: (function() {
|
print: (function() {
|
||||||
var element = document.getElementById('output');
|
var element = document.getElementById('output');
|
||||||
if (element) element.value = ''; // clear browser cache
|
if (element) element.value = ''; // clear browser cache
|
||||||
return function(text) {
|
return function(text) {
|
||||||
if (!got_log_messages) {
|
if (!got_log_messages) {
|
||||||
document.getElementById('wait').style.display = 'none';
|
window.setTimeout(startup, 50);
|
||||||
document.getElementById('input').style.display = 'block';
|
|
||||||
document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...';
|
|
||||||
got_log_messages = true;
|
got_log_messages = true;
|
||||||
}
|
}
|
||||||
if (element && typeof(text) != "number") {
|
if (element && typeof(text) != "number") {
|
||||||
|
@ -37,30 +37,42 @@
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})(),
|
})(),
|
||||||
command: (function(cmd) {
|
|
||||||
Module.ccall('run', '', ['string'], [cmd])
|
|
||||||
}),
|
|
||||||
prompt: (function(cmd) {
|
|
||||||
return Module.ccall('prompt', 'string', [], [])
|
|
||||||
})
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function startup() {
|
||||||
|
document.getElementById('wait').style.display = 'none';
|
||||||
|
document.getElementById('input').style.display = 'block';
|
||||||
|
document.getElementById('waitmsg').innerText = 'Waiting for yosys.js...';
|
||||||
|
document.getElementById('prompt').innerText = yosys_prompt();
|
||||||
|
document.getElementById('command').focus();
|
||||||
|
console.log('yosys.js loaded.');
|
||||||
|
}
|
||||||
|
|
||||||
|
function yosys_command(cmd) {
|
||||||
|
Module.ccall('run', '', ['string'], [cmd])
|
||||||
|
}
|
||||||
|
|
||||||
|
function yosys_prompt() {
|
||||||
|
return Module.ccall('prompt', 'string', [], [])
|
||||||
|
}
|
||||||
|
|
||||||
function run_command() {
|
function run_command() {
|
||||||
var cmd = document.getElementById('command').value;
|
var cmd = document.getElementById('command').value;
|
||||||
document.getElementById('command').value = '';
|
document.getElementById('command').value = '';
|
||||||
Module.print(Module.prompt() + cmd);
|
Module.print(yosys_prompt() + cmd);
|
||||||
document.getElementById('wait').style.display = 'block';
|
document.getElementById('wait').style.display = 'block';
|
||||||
document.getElementById('input').style.display = 'none';
|
document.getElementById('input').style.display = 'none';
|
||||||
|
|
||||||
function run_command_bh() {
|
function run_command_bh() {
|
||||||
try {
|
try {
|
||||||
Module.command(cmd);
|
yosys_command(cmd);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
|
Module.print('Caught JavaScript exception. (see JavaScript console for details.)');
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
document.getElementById('wait').style.display = 'none';
|
document.getElementById('wait').style.display = 'none';
|
||||||
document.getElementById('input').style.display = 'block';
|
document.getElementById('input').style.display = 'block';
|
||||||
document.getElementById('prompt').innerText = Module.prompt();
|
document.getElementById('prompt').innerText = yosys_prompt();
|
||||||
document.getElementById('command').focus();
|
document.getElementById('command').focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue