def build_android_impl(buildtype): pro_file = os.path.join(os.getcwd(), "SensorServer.pro") ndk_make = os.path.join(os.environ["ANDROID_NDK_HOME"], "prebuilt", "windows-x86_64", "bin", "make.exe") utils.check_path(ndk_make) os.environ["ANDROID_NDK_ROOT"] = os.environ["ANDROID_NDK_HOME"] os.environ["ANDROID_SDK_ROOT"] = os.environ["ANDROID_SDK_HOME"] os.environ["ANDROID_NDK_HOST"] = "windows-x86_64" qmake_path = os.path.join(os.environ["QTKITS"], "android_armv7", "bin", "qmake.exe") output_dir = f"armeabi-v7a-android-{buildtype}" build_dir = os.path.join(os.getcwd(), "build", output_dir) install_dir = os.path.join(os.getcwd(), "installed", output_dir) utils.mkdir_p(build_dir) utils.mkdir_p(install_dir) qmake_generate = f"{qmake_path} {pro_file} -spec android-g++ CONFIG+={buildtype} CONFIG+=qtquickcompiler" qmake_all = f"{ndk_make} qmake_all" make_cmd = f"{ndk_make} -j{multiprocessing.cpu_count()}" make_install = f"{ndk_make} INSTALL_ROOT={install_dir} install" with utils.pushd(build_dir): utils.execute(qmake_generate.split()) utils.execute(qmake_all.split()) utils.execute(make_cmd.split()) utils.execute(make_install.split()) android_deploy(build_dir, install_dir)
def build_flatbuffer_windows(buildtype): project_dir = os.getcwd() flb_dir = os.path.join(".vendor", "downloads", "flatbuffers") flb_dir = os.path.join(project_dir, flb_dir) output_dir = f"msvc-2017-x64-windows-{buildtype}" install_dir = os.path.join(project_dir, ".vendor", "installed", output_dir) build_dir = os.path.join(project_dir, ".vendor", "buildtrees", "flatbuffers", output_dir) utils.mkdir_p(install_dir) utils.mkdir_p(build_dir) cmake_generate = [ "cmake", "-G", "Visual Studio 15 2017 Win64", f"-DCMAKE_BUILD_TYPE={buildtype}", f"-DCMAKE_INSTALL_PREFIX={install_dir}", "-DFLATBUFFERS_BUILD_TESTS=OFF", "-DFLATBUFFERS_BUILD_FLATC=ON", "-DFLATBUFFERS_BUILD_FLATHASH=OFF", flb_dir ] cmake_build = [ "cmake", "--build", build_dir, "--config", buildtype, "--target", "install" ] with utils.pushd(build_dir): utils.execute(cmake_generate) utils.execute(cmake_build)
def build_windows_impl(buildtype): msvc_env = R"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvars64.bat" utils.check_path(msvc_env) pro_file = os.path.join(os.getcwd(), "SensorServer.pro") utils.check_path(pro_file) nmake_cmd = f"nmake {buildtype}" qmake_path = os.path.join(os.environ["QTKITS"], "msvc2017_64", "bin", "qmake.exe") utils.check_path(qmake_path) output_dir = f"msvc-2017-x64-{buildtype}" build_dir = os.path.join(os.getcwd(), "build", output_dir) utils.mkdir_p(build_dir) qmake_generate_ = f"{qmake_path} {pro_file} -spec win32-msvc CONFIG+={buildtype} CONFIG+=qtquickcompiler" os.environ["CL"] = "/MP" with utils.pushd(build_dir): msvc_env = f"\"{msvc_env}\"" build_cmd = msvc_env + " && " + qmake_generate_ + " && " + nmake_cmd build_cmd = build_cmd.replace("\r", "") build_cmd = build_cmd.replace("\n", "") utils.execute(build_cmd)
def build_flatbuffer_android(buildtype): project_dir = os.getcwd() flb_dir = os.path.join(".vendor", "downloads", "flatbuffers") flb_dir = os.path.join(project_dir, flb_dir) output_dir = f"armeabi-v7a-android-{buildtype}" install_dir = os.path.join(project_dir, ".vendor", "installed", output_dir) build_dir = os.path.join(project_dir, ".vendor", "buildtrees", "flatbuffers", output_dir) utils.mkdir_p(install_dir) utils.mkdir_p(build_dir) android_toolchain = os.path.join(os.environ["ANDROID_NDK_HOME"], "build", "cmake", "android.toolchain.cmake") android_make = os.path.join(os.environ["ANDROID_NDK_HOME"], "prebuilt", "windows-x86_64", "bin", "make.exe") cmake_generate = [ "cmake", "-G", "MinGW Makefiles", "-DANDROID_ABI=armeabi-v7a", "-DANDROID_NATIVE_API_LEVEL=android-16", "-DANDROID_PLATFORM=android-16", f"-DCMAKE_BUILD_TYPE={buildtype}", f"-DCMAKE_INSTALL_PREFIX={install_dir}", f"-DCMAKE_MAKE_PROGRAM={android_make}", f"-DCMAKE_TOOLCHAIN_FILE={android_toolchain}", "-DFLATBUFFERS_BUILD_TESTS=OFF", "-DFLATBUFFERS_BUILD_FLATC=OFF", "-DFLATBUFFERS_BUILD_FLATHASH=OFF", flb_dir ] cores = multiprocessing.cpu_count() cmake_build = [ "cmake", "--build", build_dir, "--config", buildtype, "--target", "install", "--", f"-j{cores}" ] with utils.pushd(build_dir): utils.execute(cmake_generate) utils.execute(cmake_build)
def build_android(args): project_dir = get_project_dir() with (utils.pushd(project_dir)): generate() build_android_impl("release") build_android_impl("debug")
def download_packages(): dwld_dir = os.path.join(".vendor", "downloads") with utils.pushd(dwld_dir): if not os.path.exists("flatbuffers"): cmd = "git clone --recursive https://github.com/google/flatbuffers.git" utils.execute(cmd.split())
def bootstrap_windows(args): project_dir = get_project_dir() with (utils.pushd(project_dir)): create_vendor_dirs() download_packages() build_packages_for_windows()