112 lines
4.3 KiB
C#
112 lines
4.3 KiB
C#
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
|
|
using System;
|
|
using System.Diagnostics;
|
|
using System.IO;
|
|
using UnrealBuildTool;
|
|
|
|
public class MosisSDK : ModuleRules
|
|
{
|
|
public MosisSDK(ReadOnlyTargetRules Target) : base(Target)
|
|
{
|
|
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
|
|
|
|
PublicDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"Core"
|
|
}
|
|
);
|
|
|
|
PrivateDependencyModuleNames.AddRange(
|
|
new string[]
|
|
{
|
|
"CoreUObject",
|
|
"Engine",
|
|
"Slate",
|
|
"SlateCore",
|
|
"RenderCore",
|
|
"RHI",
|
|
"EnhancedInput",
|
|
"InputCore"
|
|
}
|
|
);
|
|
|
|
if (Target.Platform == UnrealTargetPlatform.Android)
|
|
{
|
|
// Android-specific module dependencies
|
|
PrivateDependencyModuleNames.AddRange(new string[] {
|
|
"Launch",
|
|
"ApplicationCore",
|
|
"VulkanRHI"
|
|
});
|
|
|
|
// Add Vulkan support (Vulkan headers for HardwareBuffer import)
|
|
AddEngineThirdPartyPrivateStaticDependencies(Target, "Vulkan");
|
|
|
|
// Register the UPL file
|
|
string PluginPath = Utils.MakePathRelativeTo(ModuleDirectory, Target.RelativeEnginePath);
|
|
AdditionalPropertiesForReceipt.Add("AndroidPlugin", Path.Combine(PluginPath, "MosisSDK_UPL.xml"));
|
|
|
|
// Android system libraries
|
|
PublicAdditionalLibraries.Add("binder_ndk");
|
|
PublicAdditionalLibraries.Add("android");
|
|
PublicAdditionalLibraries.Add("nativewindow");
|
|
PublicSystemLibraries.Add("vulkan");
|
|
|
|
string SDKPath = Environment.GetEnvironmentVariable("ANDROID_HOME");
|
|
string BinderPath = Path.Combine(SDKPath, "platforms/android-36/optional/libbinder_ndk_cpp");
|
|
PublicIncludePaths.Add(BinderPath);
|
|
|
|
// Include generated AIDL headers (includes hardware_buffer_aidl.h locally)
|
|
string GeneratedPath = Path.Combine(ModuleDirectory, "Generated");
|
|
PublicIncludePaths.Add(GeneratedPath);
|
|
PrivateIncludePaths.Add(GeneratedPath);
|
|
|
|
string AidlPath = Path.Combine(SDKPath, "build-tools/36.1.0/aidl.exe");
|
|
string AidlSourceDir = Path.Combine(ModuleDirectory, "AIDL");
|
|
string OutputHeaderDir = Path.Combine(ModuleDirectory, "Generated");
|
|
// Put cpp files in Private/Android/ so they're only compiled on Android
|
|
string OutputCppDir = Path.Combine(ModuleDirectory, "Private", "Android", "Generated");
|
|
|
|
// Ensure output directories exist
|
|
Directory.CreateDirectory(OutputCppDir);
|
|
|
|
string[] Files = Directory.GetFiles(Path.Combine(AidlSourceDir, "com/omixlab/mosis"), "*.aidl", SearchOption.AllDirectories);
|
|
|
|
foreach (string FilePath in Files)
|
|
{
|
|
string Args = $"--lang=ndk --min_sdk_version=36 -I \"{AidlSourceDir}\" -o \"{OutputCppDir}\" -h \"{OutputHeaderDir}\" \"{FilePath}\"";
|
|
ProcessStartInfo PSI = new ProcessStartInfo();
|
|
PSI.FileName = AidlPath;
|
|
PSI.Arguments = Args;
|
|
PSI.RedirectStandardOutput = true;
|
|
PSI.RedirectStandardError = true;
|
|
PSI.UseShellExecute = false;
|
|
PSI.CreateNoWindow = true;
|
|
|
|
Console.WriteLine($"Running AIDL : {Args}");
|
|
|
|
using (Process Proc = Process.Start(PSI))
|
|
{
|
|
Proc.WaitForExit();
|
|
if (Proc.ExitCode != 0)
|
|
{
|
|
string Error = Proc.StandardError.ReadToEnd();
|
|
Console.WriteLine($"AIDL Error: {Error}");
|
|
throw new BuildException($"Failed to compile AIDL: {FilePath}");
|
|
}
|
|
}
|
|
}
|
|
|
|
// Delete any stale cpp files from Generated/ (they should be in Private/Android/Generated/)
|
|
string[] StaleCppFiles = Directory.GetFiles(GeneratedPath, "*.cpp", SearchOption.AllDirectories);
|
|
foreach (string StaleCpp in StaleCppFiles)
|
|
{
|
|
Console.WriteLine($"Removing stale AIDL cpp: {StaleCpp}");
|
|
File.Delete(StaleCpp);
|
|
}
|
|
}
|
|
}
|
|
}
|