Skip to content

Commit

Permalink
chore: merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
nattb8 committed Sep 27, 2024
1 parent 24e27d0 commit f3dc5d0
Show file tree
Hide file tree
Showing 51 changed files with 56,508 additions and 1,681 deletions.
38 changes: 13 additions & 25 deletions src/Packages/Passport/Editor/FileHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,43 @@ namespace Immutable.Passport.Editor
public static class FileHelpers
{
/// <summary>
/// Copies everything except .meta files in the source directory to the destination directory
/// </summary>
/// Copies everything except .meta files in the source directory to the destination directory
/// </summary>
public static void CopyDirectory(string sourcePath, string destinationPath)
{
// Checks if the destination directory exists
DirectoryInfo destinationDir = new DirectoryInfo(destinationPath);
var destinationDir = new DirectoryInfo(destinationPath);
if (!destinationDir.Exists)
{
Directory.CreateDirectory(destinationPath);
}
else
{
// If the directory exists, clear it
ClearDirectory(destinationPath);
}

var dir = new DirectoryInfo(sourcePath);
DirectoryInfo[] dirs = dir.GetDirectories();
foreach (FileInfo file in dir.GetFiles())
{
var dirs = dir.GetDirectories();
foreach (var file in dir.GetFiles())
if (!file.Name.EndsWith(".meta"))
{
string targetFilePath = Path.Combine(destinationPath, file.Name);
var targetFilePath = Path.Combine(destinationPath, file.Name);
file.CopyTo(targetFilePath, true);
}
}

foreach (DirectoryInfo subDir in dirs)
foreach (var subDir in dirs)
{
string newdestinationPath = Path.Combine(destinationPath, subDir.Name);
var newdestinationPath = Path.Combine(destinationPath, subDir.Name);
CopyDirectory(subDir.FullName, newdestinationPath);
}
}

/// <summary>
/// Deletes everything in the given directory
/// </summary>
/// Deletes everything in the given directory
/// </summary>
public static void ClearDirectory(string directoryPath)
{
DirectoryInfo directory = new DirectoryInfo(directoryPath);
foreach (FileInfo fileInfo in directory.EnumerateFiles())
{
fileInfo.Delete();
}
var directory = new DirectoryInfo(directoryPath);
foreach (var fileInfo in directory.EnumerateFiles()) fileInfo.Delete();

foreach (DirectoryInfo directoryInfo in directory.EnumerateDirectories())
{
directoryInfo.Delete(true);
}
foreach (var directoryInfo in directory.EnumerateDirectories()) directoryInfo.Delete(true);
}
}
}
10 changes: 5 additions & 5 deletions src/Packages/Passport/Editor/PassportAndroidProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,29 @@

using System;
using System.IO;
using UnityEditor;
using UnityEditor.Android;
using UnityEngine;

namespace Immutable.Passport.Editor
{
class PassportAndroidProcessor : IPostGenerateGradleAndroidProject
internal class PassportAndroidProcessor : IPostGenerateGradleAndroidProject
{
public int callbackOrder { get { return 0; } }
public int callbackOrder => 0;

public void OnPostGenerateGradleAndroidProject(string path)
{
Debug.Log("MyCustomBuildProcessor.OnPostGenerateGradleAndroidProject at path " + path);

// Find the location of the files
string passportWebFilesDir = Path.GetFullPath("Packages/com.immutable.passport/Runtime/Resources");
var passportWebFilesDir = Path.GetFullPath("Packages/com.immutable.passport/Runtime/Resources");
if (!Directory.Exists(passportWebFilesDir))
{
Debug.LogError("The Passport files directory doesn't exist!");
return;
}

FileHelpers.CopyDirectory(passportWebFilesDir, $"{path}/src/main/assets/ImmutableSDK/Runtime/Passport");
Debug.Log($"Sucessfully copied Passport files");
Debug.Log("Sucessfully copied Passport files");

AddUseAndroidX(path);
}
Expand Down
32 changes: 16 additions & 16 deletions src/Packages/Passport/Editor/PassportEditor.asmdef
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
{
"name": "Immutable.Passport.Editor",
"rootNamespace": "Immutable.Passport.Editor",
"references": [],
"includePlatforms": [
"Editor",
"macOSStandalone",
"WindowsStandalone64"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
"name": "Immutable.Passport.Editor",
"rootNamespace": "Immutable.Passport.Editor",
"references": [],
"includePlatforms": [
"Editor",
"macOSStandalone",
"WindowsStandalone64"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
63 changes: 26 additions & 37 deletions src/Packages/Passport/Editor/PassportPostprocess.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
#if UNITY_EDITOR

using System.IO;
using System.Reflection;
using System.Text.RegularExpressions;
using System.Text;
using System.Xml;
using System;
using System.IO;
using UnityEditor;
using UnityEditor.Build;
using UnityEditor.Build.Reporting;
Expand All @@ -19,19 +15,19 @@ internal class PassportPostprocess : IPostprocessBuildWithReport

public void OnPostprocessBuild(BuildReport report)
{
Debug.Log($"Passport post-processing...");
Debug.Log("Passport post-processing...");

if (report.summary.result is BuildResult.Failed || report.summary.result is BuildResult.Cancelled)
return;

BuildTarget buildTarget = report.summary.platform;
var buildTarget = report.summary.platform;

string buildFullOutputPath = report.summary.outputPath;
string buildAppName = Path.GetFileNameWithoutExtension(buildFullOutputPath);
string buildOutputPath = Path.GetDirectoryName(buildFullOutputPath);
var buildFullOutputPath = report.summary.outputPath;
var buildAppName = Path.GetFileNameWithoutExtension(buildFullOutputPath);
var buildOutputPath = Path.GetDirectoryName(buildFullOutputPath);

// Get the build's data folder
string buildDataPath = Path.GetFullPath($"{buildOutputPath}/{buildAppName}_Data/");
var buildDataPath = Path.GetFullPath($"{buildOutputPath}/{buildAppName}_Data/");
if (buildTarget == BuildTarget.StandaloneOSX)
{
buildDataPath =
Expand All @@ -41,7 +37,8 @@ public void OnPostprocessBuild(BuildReport report)
// but there is no way to check that so try another path
if (!Directory.Exists(buildDataPath))
{
buildDataPath = Path.GetFullPath($"{buildFullOutputPath}/{Application.productName}/Resources/Data/");
buildDataPath =
Path.GetFullPath($"{buildFullOutputPath}/{Application.productName}/Resources/Data/");
Debug.Log($"StandaloneOSX buildDataPath 2: {buildDataPath}");
}
}
Expand All @@ -58,15 +55,16 @@ public void OnPostprocessBuild(BuildReport report)

// Copy passport files to data directory for these target
// For other platforms, check the pre process file
if (buildTarget == BuildTarget.StandaloneWindows64 || buildTarget == BuildTarget.StandaloneOSX || buildTarget == BuildTarget.iOS)
if (buildTarget == BuildTarget.StandaloneWindows64 || buildTarget == BuildTarget.StandaloneOSX ||
buildTarget == BuildTarget.iOS)
{
CopyIntoDataDir(buildDataPath);
Debug.Log($"Successfully copied Passport files");
Debug.Log("Successfully copied Passport files");
}

if (buildTarget == BuildTarget.iOS)
{
string projPath = $"{buildOutputPath}/{buildAppName}" + "/Unity-iPhone.xcodeproj/project.pbxproj";
var projPath = $"{buildOutputPath}/{buildAppName}" + "/Unity-iPhone.xcodeproj/project.pbxproj";
var type = Type.GetType("UnityEditor.iOS.Xcode.PBXProject, UnityEditor.iOS.Extensions.Xcode");

if (type == null)
Expand Down Expand Up @@ -104,16 +102,14 @@ public void OnPostprocessBuild(BuildReport report)
}

var cflags = "";
if (EditorUserBuildSettings.development)
{
cflags += " -DUNITYWEBVIEW_DEVELOPMENT";
}
if (EditorUserBuildSettings.development) cflags += " -DUNITYWEBVIEW_DEVELOPMENT";

cflags = cflags.Trim();

if (!string.IsNullOrEmpty(cflags))
{
var method = type.GetMethod("AddBuildProperty", new Type[] { typeof(string), typeof(string), typeof(string) });
var method = type.GetMethod("AddBuildProperty",
new[] { typeof(string), typeof(string), typeof(string) });
method.Invoke(proj, new object[] { target, "OTHER_CFLAGS", cflags });
}

Expand All @@ -132,25 +128,22 @@ private void CopyIntoDataDir(string buildDataPath)
// Check that the data folder exists
if (!Directory.Exists(buildDataPath))
{
string errorMessage = "Failed to get the build's data folder. Make sure your build is the same name as your product name (In your project settings).";
var errorMessage =
"Failed to get the build's data folder. Make sure your build is the same name as your product name (In your project settings).";
Debug.LogError(errorMessage);
throw new Exception(errorMessage);
}

// Passport folder in the data folder
string buildPassportPath = $"{buildDataPath}/ImmutableSDK/Runtime/Passport/";
var buildPassportPath = $"{buildDataPath}/ImmutableSDK/Runtime/Passport/";

// Make sure it exists
DirectoryInfo buildPassportInfo = new DirectoryInfo(buildPassportPath);
var buildPassportInfo = new DirectoryInfo(buildPassportPath);
if (!buildPassportInfo.Exists)
{
Directory.CreateDirectory(buildPassportPath);
}
else
{
// If the directory exists, clear it
FileHelpers.ClearDirectory(buildPassportPath);
}

buildPassportPath = Path.GetFullPath(buildPassportPath);

Expand All @@ -162,28 +155,24 @@ private void CopyFilesTo(string destinationPath)
Debug.Log("Copying Passport files...");

// Find the location of the files
string passportWebFilesDir = Path.GetFullPath("Packages/com.immutable.passport/Runtime/Resources");
var passportWebFilesDir = Path.GetFullPath("Packages/com.immutable.passport/Runtime/Resources");
if (!Directory.Exists(passportWebFilesDir))
{
Debug.LogError("The Passport files directory doesn't exist!");
return;
}

foreach (string dir in Directory.GetDirectories(passportWebFilesDir, "*", SearchOption.AllDirectories))
foreach (var dir in Directory.GetDirectories(passportWebFilesDir, "*", SearchOption.AllDirectories))
{
string dirToCreate = dir.Replace(passportWebFilesDir, destinationPath);
var dirToCreate = dir.Replace(passportWebFilesDir, destinationPath);
Directory.CreateDirectory(dirToCreate);
}

foreach (string newPath in Directory.GetFiles(passportWebFilesDir, "*.*", SearchOption.AllDirectories))
{
foreach (var newPath in Directory.GetFiles(passportWebFilesDir, "*.*", SearchOption.AllDirectories))
if (!newPath.EndsWith(".meta"))
{
File.Copy(newPath, newPath.Replace(passportWebFilesDir, destinationPath), true);
}
}
}
}
}

}

#endif
Loading

0 comments on commit f3dc5d0

Please sign in to comment.