Skip to content
This repository has been archived by the owner on Sep 10, 2023. It is now read-only.

Commit

Permalink
Implemented build task for zipping artifacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kenneth committed Sep 1, 2019
1 parent f9de365 commit 9b78020
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Assets/Examples/BuildSystem/NestedJobTest.asset
Expand Up @@ -15,4 +15,4 @@ MonoBehaviour:
tasks:
- {fileID: 11400000, guid: 2c2c2ade1e003314da0ed1c94b360728, type: 2}
destination: ./Test/
deleteExistingDestination: 0
deleteExistingDestination: 1
1 change: 1 addition & 0 deletions Assets/Examples/BuildSystem/TestJob.asset
Expand Up @@ -15,5 +15,6 @@ MonoBehaviour:
tasks:
- {fileID: 11400000, guid: d43410207f9c4cf42815d68bbff4b32a, type: 2}
- {fileID: 11400000, guid: b1ed952066200074b9dc73f2cbc24b39, type: 2}
- {fileID: 11400000, guid: befca57add10d7e4bba43ece7e828ce9, type: 2}
destination: ./Builds/
deleteExistingDestination: 1
18 changes: 18 additions & 0 deletions Assets/Examples/BuildSystem/ZipArtifacts.asset
@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ead8d19a849f46459ade8202df21b28, type: 3}
m_Name: ZipArtifacts
m_EditorClassIdentifier:
subfolders:
- Win64
archiveDestination: Win64.zip
backend7ZipExePath: C:/Program Files/7-Zip/7z.exe
8 changes: 8 additions & 0 deletions Assets/Examples/BuildSystem/ZipArtifacts.asset.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -9,7 +9,7 @@ namespace UnityTK.BuildSystem
/// <summary>
/// <see cref="BuildTask"/> which will build all asset bundles specified in the project.
/// </summary>
[CreateAssetMenu(fileName = "Build AssetBundles Task", menuName = "UnityTK/BuildSystem/Build AssetBundles Task")]
[CreateAssetMenu(fileName = "BuildAssetBundlesTask", menuName = "UnityTK/BuildSystem/Build AssetBundles Task")]
public class BuildTask_BuildAssetBundles : BuildTask
{
[Header("Task")]
Expand Down
Expand Up @@ -10,7 +10,7 @@ namespace UnityTK.BuildSystem
/// <summary>
/// Build task that builds a player.
/// </summary>
[CreateAssetMenu(fileName = "Build Player Task", menuName = "UnityTK/BuildSystem/Build Player Task")]
[CreateAssetMenu(fileName = "BuildPlayerTask", menuName = "UnityTK/BuildSystem/Build Player Task")]
public class BuildTask_BuildPlayer : BuildTask
{
[Header("Task")]
Expand Down
38 changes: 38 additions & 0 deletions Assets/UnityTK/Code/EditorCode/BuildSystem/BuildTask_Zip.cs
@@ -0,0 +1,38 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System.IO;
using System.Diagnostics;
using System.Linq;

namespace UnityTK.BuildSystem
{
/// <summary>
/// <see cref="BuildTask"/> which will run a job.
/// </summary>
[CreateAssetMenu(fileName = "CreateZipTask", menuName = "UnityTK/BuildSystem/Create Zip Task")]
public class BuildTask_Zip : BuildTask
{
[Header("Build config")]
public List<string> subfolders;
public string archiveDestination;

[Header("Backend: 7-Zip")]
public string backend7ZipExePath = "C:/Program Files/7-Zip/7z.exe";

public override void Run(BuildJob job, BuildJobParameters parameters)
{
List<string> subfolders = new List<string>(this.subfolders);
if (subfolders.Count == 1)
subfolders[0] += "/*";

if (File.Exists(backend7ZipExePath))
{
// Use 7zip backend
string arguments = "a " + Path.Combine(parameters.destination, archiveDestination) + " " + string.Join(" ", subfolders.Select(s => "\"" + Path.Combine(parameters.destination, s) + "\""));
Process.Start(backend7ZipExePath, arguments).WaitForExit();
}
}
}
}
11 changes: 11 additions & 0 deletions Assets/UnityTK/Code/EditorCode/BuildSystem/BuildTask_Zip.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 9b78020

Please sign in to comment.