def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--stage", help="Copies built spatializer binaries from passed artifacts directory to Unity project locations", type=str.lower)
    parser.add_argument("-o", "--output", help="Output location, will use default build/unity location if unspecified", type=str.lower)
    parser.add_argument("-v", "--version", help="Version number", type=str.lower)
    args = parser.parse_args()

    # Copy plugin binaries to project location
    if not args.stage:
        stage.stage_binaries()
    else:
        stage.stage_binaries(args.stage)

    git_root = githelpers.get_root()

    # Default output path is under build/unity
    nuget_package_location = oshelpers.fixpath(git_root, constants.build_root, "nuget")
    if args.output:
        nuget_package_location = args.output

    if not os.path.isdir(nuget_package_location):
        os.mkdir(nuget_package_location)

    unity_project_full_path = oshelpers.fixpath(git_root, constants.unity_project_dir)
    nuspec_path = oshelpers.fixpath(unity_project_full_path, "Assets", constants.spatializer_plugin_name, constants.spatializer_plugin_name + ".nuspec")
    print(nuspec_path)
    print(nuget_package_location)
    print(args.version)
    nuget_package_creation_command = "nuget pack " + nuspec_path + " -outputdir " + nuget_package_location + " -exclude " + "*.nuspec.meta" + " -Version " + args.version
    print(nuget_package_creation_command)
    result = subprocess.run(nuget_package_creation_command)
    if (result.returncode != 0):
        print("Package generation failed!")
        print(result.stdout)
        print(result.stderr)
Esempio n. 2
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("--windows", help="Generate Windows desktop configurations", action='store_true')
    parser.add_argument("--windowsstore", help="Generate WindowsStore (UWP) configurations", action='store_true')
    parser.add_argument("--notest", help="Skip generation of test configurations", action='store_true')
    parser.add_argument("-v", "--version", help="Semantic version string", type=str.lower)
    args = parser.parse_args()

    cmake_windows = False
    cmake_windowsstore = False
    cmake_tests = True

    # No args provides, generate all configs
    if len(sys.argv) == 1:
        cmake_windows = True
        cmake_windowsstore = True
        cmake_tests = True
    # Generate Windows desktop configs
    if args.windows:
        cmake_windows = True
    # Generate UWP configs
    if args.windowsstore:
        cmake_windowsstore = True
    # Turn off test config generation
    if args.notest:
        cmake_tests = False

    git_root = oshelpers.fixpath(githelpers.get_root())
    build_dir = oshelpers.fixpath(git_root, constants.build_root)
    print("Creating build dirs under '%s'" %build_dir)

    # Pass version (if specified) to CMake
    product_version_cmake = ''
    if args.version:
        product_version_cmake = "-DPRODUCT_VERSION=" + args.version

    if (cmake_windows):
        cmake_options = [generator_vs2019, product_version_cmake]
        cmake_x64_options = [generator_vs2019, "-A x64", product_version_cmake]
        windows_arm_cmake[:0] = cmake_options
        windows_arm64_cmake[:0] = cmake_options
        create_build_folder_for_platform_architecture(build_dir, "Windows", "x86", cmake_options, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "Windows", "x64", cmake_x64_options, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "Windows", "arm", windows_arm_cmake, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "Windows", "arm64", windows_arm64_cmake, cmake_tests, git_root)
    if (cmake_windowsstore):
        cmake_options = [generator_vs2019, product_version_cmake]
        cmake_x64_options = [generator_vs2019, "-A x64", product_version_cmake]
        windowsstore_x86_cmake[:0] = cmake_options
        windowsstore_x64_cmake[:0] = cmake_x64_options
        windowsstore_arm_cmake[:0] = cmake_options
        windowsstore_arm64_cmake[:0] = cmake_options
        create_build_folder_for_platform_architecture(build_dir, "WindowsStore", "x86", windowsstore_x86_cmake, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "WindowsStore", "x64", windowsstore_x64_cmake, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "WindowsStore", "ARM", windowsstore_arm_cmake, cmake_tests, git_root)
        create_build_folder_for_platform_architecture(build_dir, "WindowsStore", "ARM64", windowsstore_arm64_cmake, cmake_tests, git_root)
Esempio n. 3
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-s", "--stage", help="Copies built spatializer binaries from passed artifacts directory to Unity project locations", type=str.lower)
    parser.add_argument("-o", "--output", help="Output location, will use default build/npm location if unspecified", type=str.lower)
    parser.add_argument("-v", "--version", help="Semantic version string for the package", type=str.lower)
    parser.add_argument("-p", "--publish", help="Publish the package to NPM feed", action='store_true')
    args = parser.parse_args()

    # Copy plugin binaries to project location
    if not args.stage:
        stage.stage_binaries()
    else:
        stage.stage_binaries(args.stage)

    git_root = oshelpers.fixpath(githelpers.get_root())

    # Default output path is under build/unity
    npm_package_location = oshelpers.fixpath(git_root, constants.build_root, "npm")
    if args.output:
        npm_package_location = args.output

    if not os.path.isdir(npm_package_location):
        os.mkdir(npm_package_location)

    unity_project_full_path = oshelpers.fixpath(git_root, constants.unity_project_dir, "Assets", constants.spatializer_plugin_name)
    npm_package_full_path = oshelpers.fixpath(npm_package_location, constants.spatializer_plugin_name + "." + args.version)
    # Specify the package version before packing
    result = subprocess.run(["cmd", "/c", "npm version", args.version, "--allow-same-version"], cwd=unity_project_full_path)
    local_copy = False
    if args.publish:
        npm_command = ["cmd", "/c", "npm publish"]
    else:
        local_copy = True
        npm_command = ["cmd", "/c", "npm pack"]
    result = subprocess.run(npm_command, cwd=unity_project_full_path)
    if (result.returncode != 0):
        print("Package generation failed!")
        print(result.stdout)
        print(result.stderr)
    else:
        if local_copy:
            shutil.move(oshelpers.fixpath(unity_project_full_path, constants.spatializer_npm_package_name + "-" + args.version + ".tgz"), npm_package_location)
            print("Package successfully generated: " + npm_package_full_path)
        else:
            print("Package successfully published")
Esempio n. 4
0
def create_build_folder_for_platform_architecture(build_dir, system, arch, cmake_options, cmake_tests, git_root):
    folder = oshelpers.fixpath(build_dir, system, arch)

    # Create the folder if it doesn't exist
    if not os.path.exists(folder):
        print("Creating dir %s" %folder)
        os.makedirs(folder)

    cmake_test_options = " -DCMAKE_TEST=TRUE"
    if (cmake_tests == False):
        cmake_test_options = " -DCMAKE_TEST=FALSE"

    # Run cmake with the build directory as the working dir and git root as the cmake root
    cmake_command = call_cmake() + " ".join(cmake_options) + cmake_test_options + " " + git_root

    print("Executing command: %s" %cmake_command)
    print("Executing CMake in %s" %folder)
    subprocess.run(cmake_command, cwd = folder, check = True, shell = True)
Esempio n. 5
0
def stage_binaries(artifacts_path=""):
    git_root = oshelpers.fixpath(githelpers.get_root())
    plugin_path_under_project = oshelpers.fixpath(
        os.path.join(constants.unity_project_dir, "Assets",
                     constants.spatializer_plugin_name, "Plugins"))

    if not artifacts_path:
        source_dir_x64_desktop = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windows", "x64",
                         "bin", "relwithdebinfo"))
        source_dir_x86_desktop = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windows", "x86",
                         "bin", "relwithdebinfo"))
        source_dir_x64_uwp = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windowsstore", "x64",
                         "bin", "relwithdebinfo"))
        source_dir_x86_uwp = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windowsstore", "x86",
                         "bin", "relwithdebinfo"))
        source_dir_ARM_uwp = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windowsstore", "arm",
                         "bin", "relwithdebinfo"))
        source_dir_ARM64_uwp = oshelpers.fixpath(
            os.path.join(git_root, constants.build_root, "windowsstore",
                         "arm64", "bin", "relwithdebinfo"))
    else:
        source_dir_x64_desktop = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_x64_desktop"))
        source_dir_x86_desktop = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_x86_desktop"))
        source_dir_x64_uwp = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_x64_uwp"))
        source_dir_x86_uwp = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_x86_uwp"))
        source_dir_ARM_uwp = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_arm_uwp"))
        source_dir_ARM64_uwp = oshelpers.fixpath(
            os.path.join(artifacts_path, "windows_arm64_uwp"))

    target_path_x64_desktop = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "x86_64"))
    target_path_x86_desktop = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "x86"))
    target_path_x64_uwp = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "WSA", "x86_64"))
    target_path_x86_uwp = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "WSA", "x86"))
    target_path_ARM_uwp = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "WSA", "arm"))
    target_path_ARM64_uwp = oshelpers.fixpath(
        os.path.join(git_root, plugin_path_under_project, "WSA", "arm64"))

    copy_spatializer(source_dir_x64_desktop, target_path_x64_desktop)
    copy_spatializer(source_dir_x86_desktop, target_path_x86_desktop)
    copy_spatializer(source_dir_x64_uwp, target_path_x64_uwp)
    copy_spatializer(source_dir_x86_uwp, target_path_x86_uwp)
    copy_spatializer(source_dir_ARM_uwp, target_path_ARM_uwp)
    copy_spatializer(source_dir_ARM64_uwp, target_path_ARM64_uwp)
Esempio n. 6
0
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument("-u",
                        "--unitydir",
                        help="Directory where Unity.exe is located")
    parser.add_argument(
        "-s",
        "--stage",
        help=
        "Copies built spatializer binaries from passed artifacts directory to Unity project locations",
        type=str.lower)
    parser.add_argument(
        "-o",
        "--output",
        help=
        "Output location, will use default build/unity location if unspecified",
        type=str.lower)
    parser.add_argument("-v",
                        "--version",
                        help="Semantic version string for the package",
                        type=str.lower)
    args = parser.parse_args()

    # Copy plugin binaries to project location
    if not args.stage:
        stage.stage_binaries()
    else:
        stage.stage_binaries(args.stage)

    git_root = oshelpers.fixpath(githelpers.get_root())

    # Default output path is under build/unity
    unity_package_location = oshelpers.fixpath(git_root, constants.build_root,
                                               "unity")
    if args.output:
        unity_package_location = args.output

    if not args.unitydir:
        sys.exit("Must specify Unity location")

    unity_exe_path = oshelpers.fixpath(os.path.join(args.unitydir,
                                                    "unity.exe"))
    if not os.path.isfile(unity_exe_path):
        sys.exit("Invalid Unity path")

    if not os.path.isdir(unity_package_location):
        os.mkdir(unity_package_location)

    unity_project_full_path = oshelpers.fixpath(git_root,
                                                constants.unity_project_dir)
    unity_package_full_path = oshelpers.fixpath(
        unity_package_location, constants.spatializer_plugin_name + "." +
        args.version + ".unitypackage")
    unity_package_creation_command = unity_exe_path + " -BatchMode -Quit " + "-ProjectPath " + unity_project_full_path + " -ExportPackage Assets " + unity_package_full_path
    result = subprocess.run(unity_package_creation_command)
    print(">>>> Unity LOG <<<<")
    editorLog = os.path.join(os.environ['userprofile'], "AppData", "Local",
                             "Unity", "Editor", "Editor.Log")
    with open(editorLog, 'r') as myfile:
        data = myfile.read()
    print(data)
    print(editorLog)
    if (result.returncode != 0):
        print("Package generation failed!")
        print(result.stdout)
        print(result.stderr)
    else:
        print("Package successfully generated: " + unity_package_full_path)
Esempio n. 7
0
def get_root():
    rev_parse = subprocess.Popen([git, 'rev-parse', '--show-toplevel'],
                                 stdout=subprocess.PIPE,
                                 stderr=subprocess.PIPE)
    return oshelpers.fixpath(rev_parse.stdout.read().decode().strip())