33 lines
808 B
C++
33 lines
808 B
C++
#include "DeerCore/Scripting.h"
|
|
#include "DeerCore/Tools/Path.h"
|
|
|
|
#include "angelscript.h"
|
|
#include "scriptbuilder.h"
|
|
#include <filesystem>
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
namespace Deer {
|
|
namespace Scripting {
|
|
extern asIScriptEngine* scriptEngine;
|
|
void generatePredefined(const Path&);
|
|
} // namespace Scripting
|
|
|
|
void Scripting::compileFiles(const Path& path, const char* moduleName) {
|
|
CScriptBuilder scriptBuilder;
|
|
|
|
generatePredefined(path);
|
|
scriptBuilder.StartNewModule(scriptEngine, moduleName);
|
|
|
|
for (const auto& entry : fs::recursive_directory_iterator(path)) {
|
|
if (!entry.is_regular_file())
|
|
continue;
|
|
|
|
if (entry.path().extension() == ".as") {
|
|
scriptBuilder.AddSectionFromFile(entry.path().string().c_str());
|
|
}
|
|
}
|
|
|
|
scriptBuilder.BuildModule();
|
|
}
|
|
} // namespace Deer
|