mirror of
https://github.com/game-ci/unity-builder.git
synced 2025-07-04 12:25:19 -04:00
Rider-project for Builder folder
This commit is contained in:
parent
5d0c1ba5c1
commit
abf39fb044
56
Builder/.gitignore
vendored
Normal file
56
Builder/.gitignore
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#
|
||||||
|
# Note: Non default ignore file, as this only tests Builder script.
|
||||||
|
#
|
||||||
|
|
||||||
|
[Ll]ibrary/
|
||||||
|
[Tt]emp/
|
||||||
|
[Oo]bj/
|
||||||
|
[Bb]uild/
|
||||||
|
[Bb]uilds/
|
||||||
|
[Ll]ogs/
|
||||||
|
|
||||||
|
# Additional ignores
|
||||||
|
[Bb]in/
|
||||||
|
|
||||||
|
# Uncomment this line if you wish to ignore the asset store tools plugin
|
||||||
|
# [Aa]ssets/AssetStoreTools*
|
||||||
|
|
||||||
|
# IDEs
|
||||||
|
.vs/
|
||||||
|
.idea/
|
||||||
|
|
||||||
|
# Gradle cache directory
|
||||||
|
.gradle/
|
||||||
|
|
||||||
|
# Autogenerated VS/MD/Consulo solution and project files
|
||||||
|
ExportedObj/
|
||||||
|
.consulo/
|
||||||
|
#*.csproj
|
||||||
|
*.unityproj
|
||||||
|
*.sln
|
||||||
|
*.suo
|
||||||
|
*.tmp
|
||||||
|
*.user
|
||||||
|
*.userprefs
|
||||||
|
*.pidb
|
||||||
|
*.booproj
|
||||||
|
*.svd
|
||||||
|
*.pdb
|
||||||
|
*.mdb
|
||||||
|
*.opendb
|
||||||
|
*.VC.db
|
||||||
|
|
||||||
|
# Unity3D generated meta files
|
||||||
|
*.pidb.meta
|
||||||
|
*.pdb.meta
|
||||||
|
*.mdb.meta
|
||||||
|
|
||||||
|
# Unity3D generated file on crash reports
|
||||||
|
sysinfo.txt
|
||||||
|
|
||||||
|
# Builds
|
||||||
|
*.apk
|
||||||
|
*.unitypackage
|
||||||
|
|
||||||
|
# Crashlytics generated file
|
||||||
|
crashlytics-build.properties
|
@ -6,139 +6,142 @@ using UnityEditor;
|
|||||||
using UnityEditor.Build.Reporting;
|
using UnityEditor.Build.Reporting;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
static class Builder
|
namespace UnityBuilderAction
|
||||||
{
|
{
|
||||||
private static string EOL = Environment.NewLine;
|
static class Builder
|
||||||
|
|
||||||
private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
|
|
||||||
{
|
{
|
||||||
providedArguments = new Dictionary<string, string>();
|
private static string EOL = Environment.NewLine;
|
||||||
string[] args = Environment.GetCommandLineArgs();
|
|
||||||
|
|
||||||
Console.WriteLine(
|
private static void ParseCommandLineArguments(out Dictionary<string, string> providedArguments)
|
||||||
$"{EOL}" +
|
{
|
||||||
$"###########################{EOL}" +
|
providedArguments = new Dictionary<string, string>();
|
||||||
$"# Parsing settings #{EOL}" +
|
string[] args = Environment.GetCommandLineArgs();
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"{EOL}"
|
|
||||||
);
|
|
||||||
|
|
||||||
// Extract flags with optional values
|
Console.WriteLine(
|
||||||
for (int current = 0, next = 1; current < args.Length; current++, next++) {
|
$"{EOL}" +
|
||||||
// Parse flag
|
$"###########################{EOL}" +
|
||||||
bool isFlag = args[current].StartsWith("-");
|
$"# Parsing settings #{EOL}" +
|
||||||
if (!isFlag) continue;
|
$"###########################{EOL}" +
|
||||||
string flag = args[current].TrimStart('-');
|
$"{EOL}"
|
||||||
|
);
|
||||||
|
|
||||||
// Parse optional value
|
// Extract flags with optional values
|
||||||
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
|
for (int current = 0, next = 1; current < args.Length; current++, next++) {
|
||||||
string value = flagHasValue ? args[next].TrimStart('-') : "";
|
// Parse flag
|
||||||
|
bool isFlag = args[current].StartsWith("-");
|
||||||
|
if (!isFlag) continue;
|
||||||
|
string flag = args[current].TrimStart('-');
|
||||||
|
|
||||||
// Assign
|
// Parse optional value
|
||||||
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
|
bool flagHasValue = next < args.Length && !args[next].StartsWith("-");
|
||||||
providedArguments.Add(flag, value);
|
string value = flagHasValue ? args[next].TrimStart('-') : "";
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Dictionary<string, string> GetValidatedOptions()
|
// Assign
|
||||||
{
|
Console.WriteLine($"Found flag \"{flag}\" with value \"{value}\".");
|
||||||
ParseCommandLineArguments(out var validatedOptions);
|
providedArguments.Add(flag, value);
|
||||||
|
}
|
||||||
if (!validatedOptions.TryGetValue("projectPath", out var projectPath)) {
|
|
||||||
Console.WriteLine("Missing argument -projectPath");
|
|
||||||
EditorApplication.Exit(110);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validatedOptions.TryGetValue("buildTarget", out var buildTarget)) {
|
private static Dictionary<string, string> GetValidatedOptions()
|
||||||
Console.WriteLine("Missing argument -buildTarget");
|
{
|
||||||
EditorApplication.Exit(120);
|
ParseCommandLineArguments(out var validatedOptions);
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("projectPath", out var projectPath)) {
|
||||||
|
Console.WriteLine("Missing argument -projectPath");
|
||||||
|
EditorApplication.Exit(110);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("buildTarget", out var buildTarget)) {
|
||||||
|
Console.WriteLine("Missing argument -buildTarget");
|
||||||
|
EditorApplication.Exit(120);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) {
|
||||||
|
EditorApplication.Exit(121);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!validatedOptions.TryGetValue("customBuildPath", out var customBuildPath)) {
|
||||||
|
Console.WriteLine("Missing argument -customBuildPath");
|
||||||
|
EditorApplication.Exit(130);
|
||||||
|
}
|
||||||
|
|
||||||
|
string defaultCustomBuildName = "TestBuild";
|
||||||
|
if (!validatedOptions.TryGetValue("customBuildName", out var customBuildName)) {
|
||||||
|
Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
||||||
|
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
||||||
|
}
|
||||||
|
else if (customBuildName == "") {
|
||||||
|
Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
||||||
|
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return validatedOptions;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Enum.IsDefined(typeof(BuildTarget), buildTarget)) {
|
public static void BuildProject()
|
||||||
EditorApplication.Exit(121);
|
{
|
||||||
|
// Gather values from args
|
||||||
|
var options = GetValidatedOptions();
|
||||||
|
|
||||||
|
// Gather values from project
|
||||||
|
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
||||||
|
|
||||||
|
// Define BuildPlayer Options
|
||||||
|
var buildOptions = new BuildPlayerOptions {
|
||||||
|
scenes = scenes,
|
||||||
|
locationPathName = options["customBuildPath"],
|
||||||
|
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
|
||||||
|
};
|
||||||
|
|
||||||
|
// Perform build
|
||||||
|
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
||||||
|
|
||||||
|
// Summary
|
||||||
|
BuildSummary summary = buildReport.summary;
|
||||||
|
ReportSummary(summary);
|
||||||
|
|
||||||
|
// Result
|
||||||
|
BuildResult result = summary.result;
|
||||||
|
ExitWithResult(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validatedOptions.TryGetValue("customBuildPath", out var customBuildPath)) {
|
private static void ReportSummary(BuildSummary summary)
|
||||||
Console.WriteLine("Missing argument -customBuildPath");
|
{
|
||||||
EditorApplication.Exit(130);
|
Console.WriteLine(
|
||||||
|
$"{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"# Build results #{EOL}" +
|
||||||
|
$"###########################{EOL}" +
|
||||||
|
$"{EOL}" +
|
||||||
|
$"Duration: {summary.totalTime.ToString()}{EOL}" +
|
||||||
|
$"Warnings: {summary.totalWarnings.ToString()}{EOL}" +
|
||||||
|
$"Errors: {summary.totalErrors.ToString()}{EOL}" +
|
||||||
|
$"Size: {summary.totalSize.ToString()} bytes{EOL}" +
|
||||||
|
$"{EOL}"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
string defaultCustomBuildName = "TestBuild";
|
private static void ExitWithResult(BuildResult result)
|
||||||
if (!validatedOptions.TryGetValue("customBuildName", out var customBuildName)) {
|
{
|
||||||
Console.WriteLine($"Missing argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
if (result == BuildResult.Succeeded) {
|
||||||
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
Console.WriteLine("Build succeeded!");
|
||||||
}
|
EditorApplication.Exit(0);
|
||||||
else if (customBuildName == "") {
|
}
|
||||||
Console.WriteLine($"Invalid argument -customBuildName, defaulting to {defaultCustomBuildName}.");
|
|
||||||
validatedOptions.Add("customBuildName", defaultCustomBuildName);
|
|
||||||
}
|
|
||||||
|
|
||||||
return validatedOptions;
|
if (result == BuildResult.Failed) {
|
||||||
}
|
Console.WriteLine("Build failed!");
|
||||||
|
EditorApplication.Exit(101);
|
||||||
|
}
|
||||||
|
|
||||||
public static void BuildProject()
|
if (result == BuildResult.Cancelled) {
|
||||||
{
|
Console.WriteLine("Build cancelled!");
|
||||||
// Gather values from args
|
EditorApplication.Exit(102);
|
||||||
var options = GetValidatedOptions();
|
}
|
||||||
|
|
||||||
// Gather values from project
|
if (result == BuildResult.Unknown) {
|
||||||
var scenes = EditorBuildSettings.scenes.Where(scene => scene.enabled).Select(s => s.path).ToArray();
|
Console.WriteLine("Build result is unknown!");
|
||||||
|
EditorApplication.Exit(103);
|
||||||
// Define BuildPlayer Options
|
}
|
||||||
var buildOptions = new BuildPlayerOptions {
|
|
||||||
scenes = scenes,
|
|
||||||
locationPathName = options["customBuildPath"],
|
|
||||||
target = (BuildTarget) Enum.Parse(typeof(BuildTarget), options["buildTarget"]),
|
|
||||||
};
|
|
||||||
|
|
||||||
// Perform build
|
|
||||||
BuildReport buildReport = BuildPipeline.BuildPlayer(buildOptions);
|
|
||||||
|
|
||||||
// Summary
|
|
||||||
BuildSummary summary = buildReport.summary;
|
|
||||||
ReportSummary(summary);
|
|
||||||
|
|
||||||
// Result
|
|
||||||
BuildResult result = summary.result;
|
|
||||||
ExitWithResult(result);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ReportSummary(BuildSummary summary)
|
|
||||||
{
|
|
||||||
Console.WriteLine(
|
|
||||||
$"{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"# Build results #{EOL}" +
|
|
||||||
$"###########################{EOL}" +
|
|
||||||
$"{EOL}" +
|
|
||||||
$"Duration: {summary.totalTime.ToString()}{EOL}" +
|
|
||||||
$"Warnings: {summary.totalWarnings.ToString()}{EOL}" +
|
|
||||||
$"Errors: {summary.totalErrors.ToString()}{EOL}" +
|
|
||||||
$"Size: {summary.totalSize.ToString()} bytes{EOL}" +
|
|
||||||
$"{EOL}"
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ExitWithResult(BuildResult result)
|
|
||||||
{
|
|
||||||
if (result == BuildResult.Succeeded) {
|
|
||||||
Console.WriteLine("Build succeeded!");
|
|
||||||
EditorApplication.Exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Failed) {
|
|
||||||
Console.WriteLine("Build failed!");
|
|
||||||
EditorApplication.Exit(101);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Cancelled) {
|
|
||||||
Console.WriteLine("Build cancelled!");
|
|
||||||
EditorApplication.Exit(102);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result == BuildResult.Unknown) {
|
|
||||||
Console.WriteLine("Build result is unknown!");
|
|
||||||
EditorApplication.Exit(103);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: dc057061ce9f406aa6b57a62d67fe9c0
|
|
||||||
timeCreated: 1575145310
|
|
35
Builder/Properties/AssemblyInfo.cs
Normal file
35
Builder/Properties/AssemblyInfo.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// General Information about an assembly is controlled through the following
|
||||||
|
// set of attributes. Change these attribute values to modify the information
|
||||||
|
// associated with an assembly.
|
||||||
|
[assembly: AssemblyTitle("UnityBuilderAction")]
|
||||||
|
[assembly: AssemblyDescription("Builder script for Unity Builder action")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("UnityBuilderAction")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2019-present")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// Setting ComVisible to false makes the types in this assembly not visible
|
||||||
|
// to COM components. If you need to access a type in this assembly from
|
||||||
|
// COM, set the ComVisible attribute to true on that type.
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
||||||
|
[assembly: Guid("031F5EE1-35CE-4F77-975A-7E326F898185")]
|
||||||
|
|
||||||
|
// Version information for an assembly consists of the following four values:
|
||||||
|
//
|
||||||
|
// Major Version
|
||||||
|
// Minor Version
|
||||||
|
// Build Number
|
||||||
|
// Revision
|
||||||
|
//
|
||||||
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
|
// by using the '*' as shown below:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
57
Builder/UnityBuilderAction.csproj
Normal file
57
Builder/UnityBuilderAction.csproj
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{031F5EE1-35CE-4F77-975A-7E326F898185}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>UnityBuilderAction</RootNamespace>
|
||||||
|
<AssemblyName>UnityBuilderAction</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>bin\Debug\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<PlatformTarget>AnyCPU</PlatformTarget>
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="UnityEditor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null">
|
||||||
|
<HintPath>..\..\..\Program Files\Unity\2019.2.11f1\Editor\Data\Managed\UnityEditor.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="UnityEngine">
|
||||||
|
<HintPath>C:\Program Files\Unity\2019.2.11f1\Editor\Data\Managed\UnityEngine.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Builder.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|
||||||
|
Other similar extension points exist, see Microsoft.Common.targets.
|
||||||
|
<Target Name="BeforeBuild">
|
||||||
|
</Target>
|
||||||
|
<Target Name="AfterBuild">
|
||||||
|
</Target>
|
||||||
|
-->
|
||||||
|
</Project>
|
Loading…
Reference in New Issue
Block a user