diff --git a/compiler/compiler.cpp b/compiler/compiler.cpp index 7a4c444..8efc2e7 100644 --- a/compiler/compiler.cpp +++ b/compiler/compiler.cpp @@ -5,7 +5,7 @@ using namespace BytecodeCompiler; -bool Compiler::CompileModule(const std::string& fileName, bool compileDependencies) +bool Compiler::CompileModule(const std::string& fileName, bool compileDependencies, bool verbose) { // Read the file if(!package->FileExists(fileName)) @@ -61,7 +61,11 @@ bool Compiler::CompileModule(const std::string& fileName, bool compileDependenci cache->buffer_policy = v8::ScriptCompiler::CachedData::BufferPolicy::BufferOwned; delete cache; - logger->Log("Converted file to bytecode: " + logger->GetHighlightColor() + fileName); + if (verbose) + { + logger->Log("Converted file to bytecode: " + logger->GetHighlightColor() + fileName); + } + compiledFiles.push_back(fileName); // Compile all dependencies diff --git a/compiler/compiler.h b/compiler/compiler.h index 69ddd90..6961ac1 100644 --- a/compiler/compiler.h +++ b/compiler/compiler.h @@ -68,7 +68,7 @@ namespace BytecodeCompiler return magicBytes; } - bool CompileModule(const std::string& fileName, bool compileDependencies = true); + bool CompileModule(const std::string& fileName, bool compileDependencies = true, bool verbose = false); bool IsBytecodeFile(void* buffer, size_t size); diff --git a/module/src/runtime.cpp b/module/src/runtime.cpp index 189cc52..4e9b24e 100644 --- a/module/src/runtime.cpp +++ b/module/src/runtime.cpp @@ -21,6 +21,8 @@ void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackag // Get ignored files std::vector ignoredModules = { "alt", "alt-client", "natives", "alt-worker", "alt-shared" }; Config::Value::ValuePtr ignoredFiles = config->Get("ignored-files"); + Config::Value::Bool verboseLogging = config->Get("verbose")->AsBool(false); + if(ignoredFiles->IsList()) { Config::Value::List list = ignoredFiles->As(); @@ -33,7 +35,7 @@ void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackag compiler.SetIgnoredModules(ignoredModules); // Compile client main file - bool result = compiler.CompileModule(resource->GetClientMain()); + bool result = compiler.CompileModule(resource->GetClientMain(), true, verboseLogging); if(!result) return; // Compile the extra files @@ -51,7 +53,7 @@ void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackag std::set files = resource->GetMatchedFiles(extraFilePatterns); for(const std::string& file : files) { - bool result = compiler.CompileModule(file, false); + bool result = compiler.CompileModule(file, false, verboseLogging); if(!result) return; } } @@ -77,6 +79,8 @@ void JSBytecodeRuntime::ProcessClientFile(alt::IResource* resource, alt::IPackag package->WriteFile(clientPkgFile, buffer.data(), buffer.size()); package->CloseFile(clientPkgFile); } + + compilerLogger.Log("Converted " + std::to_string(compiledFiles.size()) + " script files to bytecode"); } bool JSBytecodeRuntime::GetProcessClientType(std::string& clientType) diff --git a/module/src/runtimev2.cpp b/module/src/runtimev2.cpp index 2742e94..66e1e80 100644 --- a/module/src/runtimev2.cpp +++ b/module/src/runtimev2.cpp @@ -21,6 +21,8 @@ void JSBytecodeRuntimeV2::ProcessClientFile(alt::IResource* resource, alt::IPack // Get ignored files std::vector ignoredModules = { "alt", "alt-client", "natives", "alt-worker", "alt-shared", "@altv/client", "@altv/server", "@altv/shared", "@altv/natives" }; Config::Value::ValuePtr ignoredFiles = config->Get("ignored-files"); + Config::Value::Bool verboseLogging = config->Get("verbose")->AsBool(false); + if(ignoredFiles->IsList()) { Config::Value::List list = ignoredFiles->As(); @@ -33,7 +35,7 @@ void JSBytecodeRuntimeV2::ProcessClientFile(alt::IResource* resource, alt::IPack compiler.SetIgnoredModules(ignoredModules); // Compile client main file - bool result = compiler.CompileModule(resource->GetClientMain()); + bool result = compiler.CompileModule(resource->GetClientMain(), true, verboseLogging); if(!result) return; // Compile the extra files @@ -51,7 +53,7 @@ void JSBytecodeRuntimeV2::ProcessClientFile(alt::IResource* resource, alt::IPack std::set files = resource->GetMatchedFiles(extraFilePatterns); for(const std::string& file : files) { - bool result = compiler.CompileModule(file, false); + bool result = compiler.CompileModule(file, false, verboseLogging); if(!result) return; } } @@ -77,6 +79,8 @@ void JSBytecodeRuntimeV2::ProcessClientFile(alt::IResource* resource, alt::IPack package->WriteFile(clientPkgFile, buffer.data(), buffer.size()); package->CloseFile(clientPkgFile); } + + compilerLogger.Log("Converted " + std::to_string(compiledFiles.size()) + " script files to bytecode"); } bool JSBytecodeRuntimeV2::GetProcessClientType(std::string& clientType)