local function getPath(projName) local proj = auGetProjectMeta(projName) local basePath = Aurora.Settings.sAbsRoot if (proj and proj.path) then basePath = proj.path end local baseProto = path.join(Aurora.Settings.sAbsCompilerWd, "ProtobufTemp") local targetBase = nil if (projName) then targetBase = path.join(Aurora.Settings.sAbsCompilerWd, "ProtobufTemp", projName) else targetBase = path.join(Aurora.Settings.sAbsCompilerWd, "ProtobufTemp") end os.mkdir(baseProto) os.mkdir(targetBase) return targetBase, basePath end 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) 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) local targetBase, basePath = getPath(projName) includedirs(targetBase) end return { addProtobufFiles = addProtobufFiles, linkProject = includeProtobuf }