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

View File

@ -22,19 +22,41 @@ local function getPath(projName)
return targetBase, basePath
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())
files = os.matchfiles(files)
local compiledFiles = auMap(files, function(file)
local rel = path.getrelative(basePath, file)
return path.join(targetBase, rel:sub(1, #rel - 6)) .. ".pb.cc"
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)
_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
local function includeProtobuf(projName)

View File

@ -28,7 +28,27 @@ end
compiler = escapeBinaryPath(compiler)
local cmd = compiler
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 .. "\""
auForEach(auResourceCompiler.changedFiles, function(file)

View File

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