Skip to content

Commit 0ce1d54

Browse files
committed
Setup autoinstall
1 parent eb96939 commit 0ce1d54

2 files changed

Lines changed: 25 additions & 4 deletions

File tree

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ TEST_DIR := source/catch
33
EMP_DIR := Empirical/include
44
SGP_DIR := signalgp-lite/include
55
CEREAL_DIR := signalgp-lite/third-party/cereal/include
6+
CONDUIT_DIR := signalgp-lite/third-party/conduit/include
67
TAG_NUM_BITS = 32
78

89
# Flags to use regardless of compiler
910
VENDORIZE_EMP_FLAGS := -DUIT_VENDORIZE_EMP -DUIT_SUPPRESS_MACRO_INSEEP_WARNINGS
1011
COMPILE_TIME_ARGS := -DTAG_NUM_BITS=$(TAG_NUM_BITS)
11-
CFLAGS_all := -Wall -Wno-unused-function -std=c++20 $(COMPILE_TIME_ARGS) -I$(EMP_DIR)/ -I$(SGP_DIR)/ -I$(CEREAL_DIR)/ ${VENDORIZE_EMP_FLAGS}
12+
CFLAGS_all := -Wall -Wno-unused-function -std=c++20 $(COMPILE_TIME_ARGS) -I$(EMP_DIR)/ -I$(SGP_DIR)/ -I$(CEREAL_DIR)/ -I$(CONDUIT_DIR)/ ${VENDORIZE_EMP_FLAGS}
1213

1314
# Native compiler information
1415
CXX_nat := g++
@@ -18,7 +19,8 @@ CFLAGS_nat_coverage := --coverage -pthread $(CFLAGS_all)
1819

1920
# Emscripten compiler information
2021
CXX_web := emcc
21-
OFLAGS_web_all := -s "EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'stringToUTF8', 'UTF8ToString']" -s TOTAL_MEMORY=268435456 --js-library $(EMP_DIR)/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback', '_empDoCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=1 #--embed-file configs
22+
# USE_ZLIB backs uitsl::autoinstall's gzip support
23+
OFLAGS_web_all := -s "EXPORTED_RUNTIME_METHODS=['ccall', 'cwrap', 'stringToUTF8', 'UTF8ToString']" -s TOTAL_MEMORY=268435456 --js-library $(EMP_DIR)/emp/web/library_emp.js -s EXPORTED_FUNCTIONS="['_main', '_empCppCallback', '_empDoCppCallback']" -s DISABLE_EXCEPTION_CATCHING=1 -s NO_EXIT_RUNTIME=1 -s ASSERTIONS=1 -s USE_ZLIB=1 #--embed-file configs
2224
OFLAGS_web := -Oz -DNDEBUG
2325
OFLAGS_web_debug := -g4 -Oz -pedantic -Wno-dollar-in-identifier-extension
2426

source/SymAnimate.h

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#define SYM_ANIMATE_H
44

55
#include <iostream>
6+
#include <string>
7+
#include "uitsl/fetch/autoinstall.hpp"
68
#include "default_mode/SymWorld.h"
79
#include "default_mode/DataNodes.h"
810
#include "ConfigSetup.h"
@@ -22,6 +24,24 @@
2224
namespace UI = emp::web;
2325
SymConfigBase config; // load the default configuration
2426

27+
/// Configure accepted URL query params: config keys and autoinstall...
28+
/// e.g., symbulation.html?autoinstall=foo.com/file.json&VERTICAL_TRANSMISSION=0.9
29+
emp::ArgManager::spec_map_t arg_specs = [](){
30+
auto specs = emp::ArgManager::make_builtin_specs(&config);
31+
specs["autoinstall"] = emp::ArgSpec(
32+
1, // one value expected
33+
"URL of a file to download into the virtual filesystem at startup",
34+
{}, // no aliases
35+
[](const emp::optional<emp::vector<std::string>>& urls) {
36+
if (!urls) return;
37+
for (const std::string& url : *urls) {
38+
std::cout << "autoinstalled " << url << " as "
39+
<< uitsl::autoinstall(url) << std::endl;
40+
}
41+
}
42+
);
43+
return specs;
44+
}();
2545

2646

2747
class SymAnimate : public UI::Animate {
@@ -103,8 +123,7 @@ class SymAnimate : public UI::Animate {
103123
config_panel_ex.AddHeaderContent("<h3>Settings</h3>");
104124

105125
// apply configuration query params and config files to config
106-
auto specs = emp::ArgManager::make_builtin_specs(&config);
107-
emp::ArgManager am(emp::web::GetUrlParams(), specs);
126+
emp::ArgManager am(emp::web::GetUrlParams(), arg_specs);
108127
// cfg.Read("config.cfg");
109128
am.UseCallbacks();
110129
if (am.HasUnused()) {

0 commit comments

Comments
 (0)