just a bit of tinkering around
This commit is contained in:
parent
70424c8819
commit
a9626cc33f
8 changed files with 12 additions and 12 deletions
30
src/runtime/CMakeLists.txt
Normal file
30
src/runtime/CMakeLists.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
|
||||
set(scripts_demo
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/demos/simple_000.lua
|
||||
)
|
||||
|
||||
set(scripts_test
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/tests/test_core.lua
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/tests/test_system.lua
|
||||
${CMAKE_SOURCE_DIR}/src/scripts/tests/test_io.lua
|
||||
)
|
||||
|
||||
add_executable(pixwerx WIN32 MACOSX_BUNDLE
|
||||
pixwerx.cpp
|
||||
${scripts_demo}
|
||||
${scripts_test}
|
||||
)
|
||||
|
||||
target_include_directories(pixwerx
|
||||
PRIVATE
|
||||
${CMAKE_SOURCE_DIR}/src/deps
|
||||
${CMAKE_SOURCE_DIR}/src/core/include
|
||||
${CMAKE_SOURCE_DIR}/src/ui/include
|
||||
${CMAKE_SOURCE_DIR}/src/scripting/include
|
||||
)
|
||||
|
||||
target_link_libraries(pixwerx
|
||||
pwscripting
|
||||
# -Wl,--whole-archive -lpwscripting -Wl,--no-whole-archive
|
||||
pwcore
|
||||
pwsystem)
|
65
src/runtime/pixwerx.cpp
Normal file
65
src/runtime/pixwerx.cpp
Normal file
|
@ -0,0 +1,65 @@
|
|||
/**
|
||||
* pixwerx - a miniature 3D engine
|
||||
*
|
||||
* (c) Hartmut Seichter 2017-2018
|
||||
*
|
||||
*/
|
||||
#include <pw/core/core.hpp>
|
||||
#include <pw/scripting/script.hpp>
|
||||
|
||||
|
||||
#include <string>
|
||||
|
||||
#include <argagg/include/argagg/argagg.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
|
||||
//PW_RUNTIME_LUA_USE(core)
|
||||
|
||||
|
||||
int main(int argc,const char** argv) {
|
||||
|
||||
argagg::parser argparser {{
|
||||
{ "help", {"-h", "--help"},
|
||||
"shows this help message", 0},
|
||||
{ "file", {"-f", "--file"},
|
||||
"load file to run", 1}
|
||||
}
|
||||
};
|
||||
|
||||
argagg::parser_results args;
|
||||
|
||||
try {
|
||||
|
||||
args = argparser.parse(argc,argv);
|
||||
|
||||
} catch (std::exception &e) {
|
||||
|
||||
std::cerr << e.what() << std::endl;
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
std::ifstream input;
|
||||
|
||||
input.open(args["file"].as<std::string>(),std::ifstream::in);
|
||||
|
||||
if (!input.is_open()) {
|
||||
std::cerr << "cannot open '" << args["file"].as<std::string>() << "'" << std::endl;
|
||||
}
|
||||
|
||||
std::ostringstream sout;
|
||||
std::copy(std::istreambuf_iterator<char>(input),
|
||||
std::istreambuf_iterator<char>(),
|
||||
std::ostreambuf_iterator<char>(sout));
|
||||
|
||||
input.close();
|
||||
|
||||
pw::script::initialize();
|
||||
|
||||
pw::script s;
|
||||
|
||||
return s.eval(sout.str().c_str());
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue