Example #1
0
def BuildMockICD(args):
    if not os.path.exists(
            common_ci.repo_relative("%s/Vulkan-Tools" % EXTERNAL_DIR_NAME)):
        print("Clone Vulkan-Tools Repository")
        clone_tools_cmd = 'git clone https://github.com/KhronosGroup/Vulkan-Tools.git'
        common_ci.RunShellCmd(clone_tools_cmd, EXTERNAL_DIR)

    print("Run CMake for ICD")
    ICD_BUILD_DIR = common_ci.repo_relative(
        "%s/Vulkan-Tools/%s" % (EXTERNAL_DIR_NAME, BUILD_DIR_NAME))
    CreateBuildDirectory(ICD_BUILD_DIR)
    cmake_args = [
        'cmake',
        '-DCMAKE_BUILD_TYPE=%s' % args.configuration.capitalize(),
        '-DBUILD_CUBE=NO', '-DBUILD_VULKANINFO=NO', '-DINSTALL_ICD=OFF',
        '-DVULKAN_HEADERS_INSTALL_DIR=%s/Vulkan-Headers/%s/install' %
        (EXTERNAL_DIR, BUILD_DIR_NAME), '..'
    ]
    cmake_cmd = \
        'cmake -DCMAKE_BUILD_TYPE=%s -DBUILD_CUBE=NO -DBUILD_VULKANINFO=NO -DINSTALL_ICD=OFF -DVULKAN_HEADERS_INSTALL_DIR=%s/Vulkan-Headers/%s/install ..' \
        % (args.configuration.capitalize(), EXTERNAL_DIR, BUILD_DIR_NAME)
    common_ci.RunShellCmd(cmake_cmd, ICD_BUILD_DIR)

    VVL_REG_DIR = "%s/Vulkan-Headers/registry" % EXTERNAL_DIR
    VT_SCRIPTS_DIR = "%s/Vulkan-Tools/scripts" % EXTERNAL_DIR

    print("Geneating ICD Source Code")
    VT_ICD_DIR = "%s/Vulkan-Tools/icd/generated" % EXTERNAL_DIR
    LVL_GEN_SCRIPT = common_ci.repo_relative("scripts/lvl_genvk.py")
    typemap_cmd = 'python3 %s -registry %s/vk.xml vk_typemap_helper.h' % (
        LVL_GEN_SCRIPT, VVL_REG_DIR)
    common_ci.RunShellCmd(typemap_cmd, VT_ICD_DIR)

    KVT_GEN_SCRIPT = "%s/Vulkan-Tools/scripts/kvt_genvk.py" % EXTERNAL_DIR
    icd_cpp_cmd = 'python3 %s -registry %s/vk.xml mock_icd.cpp' % (
        KVT_GEN_SCRIPT, VVL_REG_DIR)
    common_ci.RunShellCmd(icd_cpp_cmd, VT_ICD_DIR)

    icd_h_cmd = 'python3 %s -registry %s/vk.xml mock_icd.h' % (KVT_GEN_SCRIPT,
                                                               VVL_REG_DIR)
    common_ci.RunShellCmd(icd_h_cmd, VT_ICD_DIR)

    print("Build Mock ICD")
    build_cmd = 'cmake --build . --target VkICD_mock_icd -- -j%s' % os.cpu_count(
    )
    common_ci.RunShellCmd(build_cmd, ICD_BUILD_DIR)

    # Copy json file into dir with ICD executable
    src_filename = common_ci.repo_relative(
        "%s/Vulkan-Tools/icd/linux/VkICD_mock_icd.json" % EXTERNAL_DIR_NAME)
    dst_filename = common_ci.repo_relative(
        "%s/Vulkan-Tools/%s/icd/VkICD_mock_icd.json" %
        (EXTERNAL_DIR_NAME, BUILD_DIR_NAME))
    shutil.copyfile(src_filename, dst_filename)
def BuildVVL(args):

    print("Log CMake version")
    cmake_ver_cmd = 'cmake --version'
    common_ci.RunShellCmd(cmake_ver_cmd)

    print("Run update_deps.py for VVL Repository")
    update_cmd = 'python3 scripts/update_deps.py --dir %s --config %s --arch x64' % (EXTERNAL_DIR_NAME, args.configuration)
    common_ci.RunShellCmd(update_cmd)

    GTEST_DIR = common_ci.repo_relative("external/googletest")
    if not os.path.exists(GTEST_DIR):
        print("Clone Testing Framework Source Code")
        clone_gtest_cmd = 'git clone https://github.com/google/googletest.git %s' % GTEST_DIR
        common_ci.RunShellCmd(clone_gtest_cmd)

        print("Get Specified Testing Source")
        gtest_checkout_cmd = 'git checkout tags/release-1.8.1'
        common_ci.RunShellCmd(gtest_checkout_cmd, GTEST_DIR)

    CreateBuildDirectory(VVL_BUILD_DIR)
    print("Run CMake for Validation Layers")
    cmake_cmd = 'cmake -C ../%s/helper.cmake -DCMAKE_BUILD_TYPE=%s -DUSE_CCACHE=ON ..' \
        % (EXTERNAL_DIR_NAME, args.configuration.capitalize())
    common_ci.RunShellCmd(cmake_cmd, VVL_BUILD_DIR)

    print("Build Validation Layers and Tests")
    os.chdir(VVL_BUILD_DIR)
    build_cmd = 'cmake --build . -- -j%s' % os.cpu_count()
    common_ci.RunShellCmd(build_cmd, VVL_BUILD_DIR)
Example #3
0
def BuildGn():
    if not os.path.exists(common_ci.repo_relative("depot_tools")):
        print("Cloning Chromium depot_tools\n")
        clone_cmd = 'git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git depot_tools'
        common_ci.RunShellCmd(clone_cmd)
    os.environ['PATH'] = os.environ.get(
        'PATH') + ":" + common_ci.repo_relative("depot_tools")

    print("Updating Repo Dependencies and GN Toolchain\n")
    update_cmd = './build-gn/update_deps.sh'
    common_ci.RunShellCmd(update_cmd)

    print("Generating Ninja Files\n")
    gn_gen_cmd = 'gn gen out/Debug'
    common_ci.RunShellCmd(gn_gen_cmd)

    print("Running Ninja Build\n")
    ninja_build_cmd = 'ninja -C out/Debug'
    common_ci.RunShellCmd(ninja_build_cmd)
def BuildLoader(args):
    LOADER_DIR = common_ci.repo_relative("%s/Vulkan-Loader" % EXTERNAL_DIR_NAME)
    # Clone Loader repo
    if not os.path.exists(LOADER_DIR):
        print("Clone Loader Source Code")
        clone_loader_cmd = 'git clone https://github.com/KhronosGroup/Vulkan-Loader.git'
        common_ci.RunShellCmd(clone_loader_cmd, EXTERNAL_DIR)

    print("Run update_deps.py for Loader Repository")
    update_cmd = 'python3 scripts/update_deps.py --dir external'
    common_ci.RunShellCmd(update_cmd, LOADER_DIR)

    print("Run CMake for Loader")
    LOADER_BUILD_DIR = common_ci.repo_relative("%s/Vulkan-Loader/%s" % (EXTERNAL_DIR_NAME, BUILD_DIR_NAME))
    CreateBuildDirectory(LOADER_BUILD_DIR)
    cmake_cmd = 'cmake -C ../external/helper.cmake -DCMAKE_BUILD_TYPE=%s ..' % args.configuration.capitalize()
    common_ci.RunShellCmd(cmake_cmd, LOADER_BUILD_DIR)

    print("Build Loader")
    build_cmd = 'cmake --build . -- -j%s' % os.cpu_count()
    common_ci.RunShellCmd(build_cmd, LOADER_BUILD_DIR)
def BuildAndroid(target_abi):
    print("Fetching NDK\n")
    wget_cmd = 'wget http://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip'
    common_ci.RunShellCmd(wget_cmd)

    print("Extracting NDK components\n")
    unzip_cmd = 'unzip -u -q android-ndk-r21d-linux-x86_64.zip'
    common_ci.RunShellCmd(unzip_cmd)
    # Add NDK to path
    os.environ['ANDROID_NDK_HOME'] = common_ci.repo_relative(
        'android-ndk-r21d')
    os.environ['PATH'] = os.environ.get(
        'ANDROID_NDK_HOME') + os.pathsep + os.environ.get('PATH')

    print("Preparing Android Dependencies\n")
    update_sources_cmd = './update_external_sources_android.sh --abi %s --no-build' % target_abi
    common_ci.RunShellCmd(update_sources_cmd, "build-android")

    print("Building Android Layers and Tests\n")
    ndk_build_cmd = 'ndk-build APP_ABI=%s -j%s' % (target_abi, os.cpu_count())
    common_ci.RunShellCmd(ndk_build_cmd, "build-android")
# Author: Mark Lobodzinski <*****@*****.**>

import os
import argparse
import shutil
import subprocess
import sys
import platform

import common_ci
from argparse import RawDescriptionHelpFormatter

# TODO: Pass this in as arg, may be useful for running locally
EXTERNAL_DIR_NAME = "external"
BUILD_DIR_NAME = "build"
EXTERNAL_DIR = common_ci.repo_relative(EXTERNAL_DIR_NAME)
VVL_BUILD_DIR = common_ci.repo_relative(BUILD_DIR_NAME)
CONFIGURATIONS = ['release', 'debug']
DEFAULT_CONFIGURATION = CONFIGURATIONS[0]

#
# Check if the system is Windows
def is_windows():
    return 'windows' == platform.system().lower()

#
# Create build directory if it does not already exist
def CreateBuildDirectory(dir_path):
    if not os.path.exists(dir_path):
        os.makedirs(dir_path)