mirror of
https://github.com/cocos/cocos-engine.git
synced 2026-09-07 00:02:53 +08:00
37 lines
908 B
C++
37 lines
908 B
C++
|
|
#include "cocos/bindings/jswrapper/SeApi.h"
|
|
#include "cocos/platform/FileUtils.h"
|
|
#include <string>
|
|
#include <sstream>
|
|
#include <cstdlib>
|
|
#include "cocos/bindings/manual/jsb_global_init.h"
|
|
|
|
int main(int argc, char **argv) {
|
|
|
|
std::string scriptPath = "index.js";
|
|
|
|
if(argc > 1) {
|
|
scriptPath = argv[1];
|
|
}
|
|
|
|
auto *engine = se::ScriptEngine::getInstance();
|
|
auto *fu = cc::FileUtils::getInstance();
|
|
|
|
// TODO: replace search path
|
|
auto *currentDir = getenv("PWD");
|
|
fu->addSearchPath(currentDir);
|
|
|
|
jsb_set_xxtea_key("");
|
|
jsb_init_file_operation_delegate();
|
|
|
|
engine->start();
|
|
engine->evalString("console.log('begin execute')");
|
|
auto ret = engine->runScript(scriptPath);
|
|
engine->evalString("console.log('end')");
|
|
if(!ret) return EXIT_FAILURE;
|
|
|
|
|
|
se::ScriptEngine::destroyInstance();
|
|
cc::FileUtils::destroyInstance();
|
|
return 0;
|
|
} |