代码拉取完成,页面将自动刷新
同步操作将从 Plato/rpc-repo 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import os
import util
import shutil
import platform
import sys
class Initializer:
def __init__(self, options, version, proj_root):
self.options = options
self.version = version
self.proj_root = proj_root
self.pyexec = sys.executable
self.proxy_only = False
def check(self):
return False
# frontend 是用于多语言的idl生成这里的构建应该放在基础类里面
def build_frontend(self):
os.chdir("rpc-frontend")
file = open("CMakeLists.txt", "w")
file.write("cmake_minimum_required(VERSION 3.5)\n")
if platform.system() == "Windows":
file.write("set(CMAKE_CXX_STANDARD 17)\n")
file.write("project (rpc-frontend)\n")
file.write('INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src/thirdparty)\n')
file.write('add_executable(rpc-frontend src/frontend.cpp src/json_builder.cpp src/parser.cpp '
'src/tokenizer.cpp src/md5.cpp src/main.cpp src/thirdparty/jsoncpp/json_writer.cpp '
'src/thirdparty/jsoncpp/json_value.cpp)\n')
file.write("SET(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/../../bin)\n")
file.write("IF (MSVC)\n")
file.write(' set_target_properties(rpc-frontend PROPERTIES COMPILE_FLAGS "/EHa /wd4819 /wd4996")\n')
file.write("ELSEIF(UNIX)\n")
file.write(' if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")\n')
file.write(' SET(CMAKE_CXX_FLAGS "' + self.options.get_option("cpp",
"machine") + ' -g -O2 -std=c++17 -Wall -fPIC")\n')
file.write(' set(CMAKE_CXX_COMPILER "clang++")\n')
file.write(' elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")\n')
file.write(' SET(CMAKE_CXX_FLAGS "' + self.options.get_option("cpp",
"machine") + ' -g -O2 -std=c++17 -Wall -fPIC")\n')
file.write(' set(CMAKE_CXX_COMPILER "g++")\n')
file.write(' endif()\n')
file.write("ENDIF ()\n")
file.close()
if platform.system() == "Windows":
os.system('cmake -G "Visual Studio 16 2019" -A x64')
os.system('cmake --build . --config "Release"')
shutil.copyfile("../../bin/Release/rpc-frontend.exe", "../../bin/rpc-frontend.exe")
shutil.rmtree("../../bin/Release/")
else:
os.system("cmake -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ .")
os.system("make -j4")
os.chdir("..")
# 建立不同语言的编译环境及相关文件
def build_backend(self):
pass
# 因为要编译frontend 所以需要检查c++的编译器
# 所有的环境准备都放到python里面
# 准备protobuf的环境
def checkPrecondition(self):
if not util.check_git_env():
return False
if not util.check_compiler_env():
return False
# pb 没有初始话成功 直接退出
if not util.check_pb_env():
return False
return True
def init(self):
return self.checkPrecondition()
def checkEnv(self):
pass
# 安装对应的service box framework
def installFramework(self):
pass
def get_version(self):
return self.version
class Builder:
def __init__(self, options, version, proj_root):
self.options = options
self.version = version
self.proj_root = proj_root
self.pyexec = sys.executable
self.proxy_only = False
def get_version(self):
return self.version
def check_idl_name(self, idl_name):
if idl_name.endswith(".idl"):
return idl_name
else:
return idl_name + ".idl"
def deleteIdl(self, name):
idl_name = self.check_idl_name(name)
(base_name, _) = os.path.splitext(os.path.basename(idl_name))
if os.path.exists("src/include/" + base_name):
shutil.rmtree("src/include/" + base_name)
if os.path.exists("src/proxy/" + base_name):
shutil.rmtree("src/proxy/" + base_name)
if os.path.exists("src/stub/" + base_name):
shutil.rmtree("src/stub/" + base_name)
if os.path.exists("src/idl/" + base_name + ".idl"):
os.remove("src/idl/" + base_name + ".idl")
if os.path.exists("src/" + base_name):
shutil.rmtree("src/" + base_name)
if os.path.exists("lib/" + base_name):
shutil.rmtree("lib/" + base_name)
if os.path.exists("lib/proxy/" + base_name):
shutil.rmtree("lib/proxy/" + base_name)
if os.path.exists("lib/stub/" + base_name):
shutil.rmtree("lib/stub/" + base_name)
if os.path.exists("tmp/" + base_name):
shutil.rmtree("tmp/" + base_name)
if os.path.exists("usr/" + base_name):
shutil.rmtree("usr/" + base_name)
if os.path.exists("src/idl/" + base_name + ".idl.cpp.json"):
os.remove("src/idl/" + base_name + ".idl.cpp.json")
if os.path.exists("src/idl/" + base_name + ".idl.protobuf.json"):
os.remove("src/idl/" + base_name + ".idl.protobuf.json")
if os.path.exists("src/idl/" + base_name + ".service.list"):
os.remove("src/idl/" + base_name + ".service.list")
if os.path.exists("src/idl/" + base_name + ".service.proto"):
os.remove("src/idl/" + base_name + ".service.proto")
def updateIdl(self, name, service_name=None):
idl_name = self.check_idl_name(name)
if not os.path.exists("src/idl/" + idl_name):
print (name + " not found in repo.")
return
if not os.path.exists("src/idl/" + idl_name):
return
else:
self.addIdl2Repo(idl_name, service_name, False)
def build_idl(self, name, sname=None, build_type="all", make_service_type="all", version=""):
pass
# @title 构建测试server
def build_beta_server(self, file_name, sname=None):
pass
def addIdl2Repo(self, file_name, sname=None, add=True):
pass
def build_sdk(self, name, sname=None, build_type="all"):
pass
def updateRoot(self):
pass
def build_apitest(self, out_dir, file_name, service_name=None):
pass
def run_apitest(self, file_name, service_name=None):
pass
def do_clean(self, file_name, service_name=None):
pass
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。