Browse
---
Chat
---
Wekan
Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
os
games
sample-3d
Commits
cf85a92c
Commit
cf85a92c
authored
4 years ago
by
kc
Browse files
Options
Download
Email Patches
Plain Diff
rm webgl zip name. adjustable buildname
parent
1c4cb0f5
master
dev
No related merge requests found
Pipeline
#197
passed with stages
in 2 minutes and 15 seconds
Changes
3
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitlab-ci.yml
+10
-8
.gitlab-ci.yml
Assets/scripts/Editor/BuildCommand_ref.cs.bak
+0
-262
Assets/scripts/Editor/BuildCommand_ref.cs.bak
Assets/scripts/Editor/BuildCommand_ref.cs.bak.meta
+7
-0
Assets/scripts/Editor/BuildCommand_ref.cs.bak.meta
with
17 additions
and
270 deletions
+17
-270
.gitlab-ci.yml
+
10
-
8
View file @
cf85a92c
...
...
@@ -4,6 +4,9 @@ stages:
-
win64_build
-
clean
variables
:
BUILD_NAME
:
3dworld
echo_env_vars
:
stage
:
echo
tags
:
...
...
@@ -37,17 +40,16 @@ build_webgl:
-
unity
script
:
-
bash build.sh --lin --webgl
-
rm -rf
3dworld && mkdir -p 3dworld
-
mv Builds/
3dworld_WebGL/3dworld/* 3dworld
/
-
rm -rf
${BUILD_NAME} && mkdir -p ${BUILD_NAME}
-
mv Builds/
${BUILD_NAME}_WebGL/${BUILD_NAME}/* ${BUILD_NAME}
/
cache
:
key
:
unity-lib
paths
:
-
Library/
artifacts
:
name
:
3dworld
# Name of zip file
expire_in
:
1 day
paths
:
-
3dworld
/
-
${BUILD_NAME}
/
dependencies
:
[]
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"web"
&&
$CI_COMMIT_REF_NAME
!=
"master"'
...
...
@@ -64,17 +66,17 @@ build_win64:
-
unity
script
:
-
bash build.sh --lin --win64
-
rm -rf
3dworld && mkdir -p 3dworld
-
mv Builds/
3dworld
_StandaloneWindows64/*
3dworld
/
-
rm -rf
${BUILD_NAME} && mkdir -p ${BUILD_NAME}
-
mv Builds/
${BUILD_NAME}
_StandaloneWindows64/*
${BUILD_NAME}
/
cache
:
key
:
unity-lib
paths
:
-
Library/
artifacts
:
name
:
3dworld
name
:
${BUILD_NAME}
# Name of zip file
expire_in
:
1 day
paths
:
-
3dworld
/
-
${BUILD_NAME}
/
dependencies
:
[]
rules
:
-
if
:
'
$CI_PIPELINE_SOURCE
==
"web"
&&
$CI_COMMIT_REF_NAME
!=
"master"'
...
...
This diff is collapsed.
Click to expand it.
Assets/scripts/Editor/BuildCommand_ref.cs.bak
deleted
100644 → 0
+
0
-
262
View file @
1c4cb0f5
using UnityEditor;
using System.Linq;
using System;
using System.IO;
static class BuildCommand
{
private const string KEYSTORE_PASS = "KEYSTORE_PASS";
private const string KEY_ALIAS_PASS = "KEY_ALIAS_PASS";
private const string KEY_ALIAS_NAME = "KEY_ALIAS_NAME";
private const string KEYSTORE = "keystore.keystore";
private const string BUILD_OPTIONS_ENV_VAR = "BuildOptions";
private const string ANDROID_BUNDLE_VERSION_CODE = "BUNDLE_VERSION_CODE";
private const string ANDROID_APP_BUNDLE = "BUILD_APP_BUNDLE";
private const string SCRIPTING_BACKEND_ENV_VAR = "SCRIPTING_BACKEND";
static string GetArgument(string name)
{
string[] args = Environment.GetCommandLineArgs();
for (int i = 0; i < args.Length; i++)
{
if (args[i].Contains(name))
{
return args[i + 1];
}
}
return null;
}
static string[] GetEnabledScenes()
{
return (
from scene in EditorBuildSettings.scenes
where scene.enabled
where !string.IsNullOrEmpty(scene.path)
select scene.path
).ToArray();
}
static BuildTarget GetBuildTarget()
{
string buildTargetName = GetArgument("customBuildTarget");
Console.WriteLine(":: Received customBuildTarget " + buildTargetName);
if (buildTargetName.ToLower() == "android")
{
#if !UNITY_5_6_OR_NEWER
// https://issuetracker.unity3d.com/issues/buildoptions-dot-acceptexternalmodificationstoplayer-causes-unityexception-unknown-project-type-0
// Fixed in Unity 5.6.0
// side effect to fix android build system:
EditorUserBuildSettings.androidBuildSystem = AndroidBuildSystem.Internal;
#endif
}
if (buildTargetName.TryConvertToEnum(out BuildTarget target))
return target;
Console.WriteLine($":: {nameof(buildTargetName)} \"{buildTargetName}\" not defined on enum {nameof(BuildTarget)}, using {nameof(BuildTarget.NoTarget)} enum to build");
return BuildTarget.NoTarget;
}
static string GetBuildPath()
{
string buildPath = GetArgument("customBuildPath");
Console.WriteLine(":: Received customBuildPath " + buildPath);
if (buildPath == "")
{
throw new Exception("customBuildPath argument is missing");
}
return buildPath;
}
static string GetBuildName()
{
string buildName = GetArgument("customBuildName");
Console.WriteLine(":: Received customBuildName " + buildName);
if (buildName == "")
{
throw new Exception("customBuildName argument is missing");
}
return buildName;
}
static string GetFixedBuildPath(BuildTarget buildTarget, string buildPath, string buildName)
{
if (buildTarget.ToString().ToLower().Contains("windows")) {
buildName += ".exe";
} else if (buildTarget == BuildTarget.Android) {
#if UNITY_2018_3_OR_NEWER
buildName += EditorUserBuildSettings.buildAppBundle ? ".aab" : ".apk";
#else
buildName += ".apk";
#endif
}
return buildPath + buildName;
}
static BuildOptions GetBuildOptions()
{
if (TryGetEnv(BUILD_OPTIONS_ENV_VAR, out string envVar)) {
string[] allOptionVars = envVar.Split(',');
BuildOptions allOptions = BuildOptions.None;
BuildOptions option;
string optionVar;
int length = allOptionVars.Length;
Console.WriteLine($":: Detecting {BUILD_OPTIONS_ENV_VAR} env var with {length} elements ({envVar})");
for (int i = 0; i < length; i++) {
optionVar = allOptionVars[i];
if (optionVar.TryConvertToEnum(out option)) {
allOptions |= option;
}
else {
Console.WriteLine($":: Cannot convert {optionVar} to {nameof(BuildOptions)} enum, skipping it.");
}
}
return allOptions;
}
return BuildOptions.None;
}
// https://stackoverflow.com/questions/1082532/how-to-tryparse-for-enum-value
static bool TryConvertToEnum<TEnum>(this string strEnumValue, out TEnum value)
{
if (!Enum.IsDefined(typeof(TEnum), strEnumValue))
{
value = default;
return false;
}
value = (TEnum)Enum.Parse(typeof(TEnum), strEnumValue);
return true;
}
static bool TryGetEnv(string key, out string value)
{
value = Environment.GetEnvironmentVariable(key);
return !string.IsNullOrEmpty(value);
}
static void SetScriptingBackendFromEnv(BuildTarget platform) {
var targetGroup = BuildPipeline.GetBuildTargetGroup(platform);
if (TryGetEnv(SCRIPTING_BACKEND_ENV_VAR, out string scriptingBackend)) {
if (scriptingBackend.TryConvertToEnum(out ScriptingImplementation backend)) {
Console.WriteLine($":: Setting ScriptingBackend to {backend}");
PlayerSettings.SetScriptingBackend(targetGroup, backend);
} else {
string possibleValues = string.Join(", ", Enum.GetValues(typeof(ScriptingImplementation)).Cast<ScriptingImplementation>());
throw new Exception($"Could not find '{scriptingBackend}' in ScriptingImplementation enum. Possible values are: {possibleValues}");
}
} else {
var defaultBackend = PlayerSettings.GetDefaultScriptingBackend(targetGroup);
Console.WriteLine($":: Using project's configured ScriptingBackend (should be {defaultBackend} for tagetGroup {targetGroup}");
}
}
static void PerformBuild()
{
Console.WriteLine(":: Performing build");
var buildTarget = GetBuildTarget();
if (buildTarget == BuildTarget.Android) {
HandleAndroidAppBundle();
HandleAndroidBundleVersionCode();
HandleAndroidKeystore();
}
var buildPath = GetBuildPath();
var buildName = GetBuildName();
var buildOptions = GetBuildOptions();
var fixedBuildPath = GetFixedBuildPath(buildTarget, buildPath, buildName);
SetScriptingBackendFromEnv(buildTarget);
var buildReport = BuildPipeline.BuildPlayer(GetEnabledScenes(), fixedBuildPath, buildTarget, buildOptions);
if (buildReport.summary.result != UnityEditor.Build.Reporting.BuildResult.Succeeded)
throw new Exception($"Build ended with {buildReport.summary.result} status");
Console.WriteLine(":: Done with build");
}
private static void HandleAndroidAppBundle()
{
if (TryGetEnv(ANDROID_APP_BUNDLE, out string value))
{
#if UNITY_2018_3_OR_NEWER
if (bool.TryParse(value, out bool buildAppBundle))
{
EditorUserBuildSettings.buildAppBundle = buildAppBundle;
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected, set buildAppBundle to {value}.");
}
else
{
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected but the value \"{value}\" is not a boolean.");
}
#else
Console.WriteLine($":: {ANDROID_APP_BUNDLE} env var detected but does not work with lower Unity version than 2018.3");
#endif
}
}
private static void HandleAndroidBundleVersionCode()
{
if (TryGetEnv(ANDROID_BUNDLE_VERSION_CODE, out string value))
{
if (int.TryParse(value, out int version))
{
PlayerSettings.Android.bundleVersionCode = version;
Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected, set the bundle version code to {value}.");
}
else
Console.WriteLine($":: {ANDROID_BUNDLE_VERSION_CODE} env var detected but the version value \"{value}\" is not an integer.");
}
}
private static void HandleAndroidKeystore()
{
#if UNITY_2019_1_OR_NEWER
PlayerSettings.Android.useCustomKeystore = false;
#endif
if (!File.Exists(KEYSTORE)) {
Console.WriteLine($":: {KEYSTORE} not found, skipping setup, using Unity's default keystore");
return;
}
PlayerSettings.Android.keystoreName = KEYSTORE;
string keystorePass;
string keystoreAliasPass;
if (TryGetEnv(KEY_ALIAS_NAME, out string keyaliasName)) {
PlayerSettings.Android.keyaliasName = keyaliasName;
Console.WriteLine($":: using ${KEY_ALIAS_NAME} env var on PlayerSettings");
} else {
Console.WriteLine($":: ${KEY_ALIAS_NAME} env var not set, using Project's PlayerSettings");
}
if (!TryGetEnv(KEYSTORE_PASS, out keystorePass)) {
Console.WriteLine($":: ${KEYSTORE_PASS} env var not set, skipping setup, using Unity's default keystore");
return;
}
if (!TryGetEnv(KEY_ALIAS_PASS, out keystoreAliasPass)) {
Console.WriteLine($":: ${KEY_ALIAS_PASS} env var not set, skipping setup, using Unity's default keystore");
return;
}
#if UNITY_2019_1_OR_NEWER
PlayerSettings.Android.useCustomKeystore = true;
#endif
PlayerSettings.Android.keystorePass = keystorePass;
PlayerSettings.Android.keyaliasPass = keystoreAliasPass;
}
}
This diff is collapsed.
Click to expand it.
Assets/scripts/Editor/BuildCommand_ref.cs.bak.meta
0 → 100644
+
7
-
0
View file @
cf85a92c
fileFormatVersion: 2
guid: 45d5b0f760cb698429574627afafea4d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets