[+] auRPC and grpc support

This commit is contained in:
Reece Wilson 2022-06-24 20:12:03 +01:00
parent c755a236cd
commit f5ddd1d3d1
4 changed files with 51 additions and 7 deletions

View File

@ -313,8 +313,10 @@ local function auBlockProjectKeyResourceScript(processor, value, map, tasks)
end, processor) end, processor)
end end
local function auBlockProjectKeyProtobuf(processor, value) local function auBlockProjectKeyProtobuf(processor, value, map, tasks, inc, resolve, object)
filterForKey(value, "files", auProtobufFiles, true) filterForKey(value, "files", function(value)
auProtobufFiles(value, {grpc = object.grpc, auRPC = object.auRPC})
end, true)
end end
local function auBlockProjectKeyVala(processor, value) local function auBlockProjectKeyVala(processor, value)
@ -521,7 +523,7 @@ __pRunTasks = function(processor, object, map, tasks, inc, resolve)
if (not value) then if (not value) then
return return
end end
map[key](processor, value, map, tasks, inc, resolve) map[key](processor, value, map, tasks, inc, resolve, object)
end) end)
end end

View File

@ -22,19 +22,41 @@ local function getPath(projName)
return targetBase, basePath return targetBase, basePath
end end
local function addProtobufFiles(files) local function addProtobufFiles(files, extended)
local grpc = (extended or {}).grpc
local auRPC = (extended or {}).auRPC
local targetBase, basePath = getPath(auGetCurrentProject()) local targetBase, basePath = getPath(auGetCurrentProject())
files = os.matchfiles(files) files = os.matchfiles(files)
local compiledFiles = auMap(files, function(file) local compiledFiles = auMap(files, function(file)
local rel = path.getrelative(basePath, file) local rel = path.getrelative(basePath, file)
return path.join(targetBase, rel:sub(1, #rel - 6)) .. ".pb.cc" return path.join(targetBase, rel:sub(1, #rel - 6)) .. ".pb.cc"
end) end)
local grpcFiles = auMap(files, function(file)
local rel = path.getrelative(basePath, file)
return path.join(targetBase, rel:sub(1, #rel - 6)) .. ".grpc.pb.cc"
end)
local auRpcFiles = auMap(files, function(file)
local rel = path.getrelative(basePath, file)
return path.join(targetBase, rel:sub(1, #rel - 6)) .. ".aurpc.pb.cc"
end)
includedirs(targetBase) includedirs(targetBase)
_G.files(compiledFiles) _G.files(compiledFiles)
auAddResource(files, {targetBase = targetBase, basePath = basePath}, path.join(Aurora.Settings.sAbsScripts, "Core", "Protobuf", "run.lua")) if (grpc) then
_G.files(grpcFiles)
end
if (auRPC) then
_G.files(auRpcFiles)
end
auAddResource(files, {targetBase = targetBase, basePath = basePath, grpc = grpc, auRPC = auRPC}, path.join(Aurora.Settings.sAbsScripts, "Core", "Protobuf", "run.lua"))
end end
local function includeProtobuf(projName) local function includeProtobuf(projName)

View File

@ -28,7 +28,27 @@ end
compiler = escapeBinaryPath(compiler) compiler = escapeBinaryPath(compiler)
local cmd = compiler local cmd = compiler
cmd = cmd .. " --cpp_out=\"" .. auResourceCompiler.arguments.targetBase .. "\"" cmd = cmd .. " --cpp_out=\"" .. auResourceCompiler.arguments.targetBase .. "\""
if (auResourceCompiler.arguments.grpc) then
cmd = cmd .. " --grpc_out=\"" .. auResourceCompiler.arguments.targetBase .. "\""
if (os.host() == "windows") then
local plugin = os.realpath(path.join(Aurora.Settings.sAbsWin32, "grpc_cpp_plugin.exe"))
cmd = cmd .. " --plugin=protoc-gen-grpc=\"" .. plugin .."\""
end
end
if (auResourceCompiler.arguments.auRPC) then
cmd = cmd .. " --aurpc_out=\"" .. auResourceCompiler.arguments.targetBase .. "\""
if (os.host() == "windows") then
local plugin = os.realpath(path.join(Aurora.Settings.sAbsWin32, "aurpc_cpp_plugin.exe"))
cmd = cmd .. " --plugin=protoc-gen-aurpc=\"" .. plugin .."\""
end
end
cmd = cmd .. " --proto_path=\"" .. auResourceCompiler.arguments.basePath .. "\"" cmd = cmd .. " --proto_path=\"" .. auResourceCompiler.arguments.basePath .. "\""
auForEach(auResourceCompiler.changedFiles, function(file) auForEach(auResourceCompiler.changedFiles, function(file)

View File

@ -158,8 +158,8 @@ function auAddResource(...)
resourceCompiler(...) resourceCompiler(...)
end end
function auProtobufFiles(files) function auProtobufFiles(files, extended)
protobuf.addProtobufFiles(files) protobuf.addProtobufFiles(files, extended)
end end
function auProtobufIncludeProject(projectName) function auProtobufIncludeProject(projectName)