https://gitee.com/weifen/hybrid-clrexample
hybridclr 热更真机测试
热更构建的时候会把生成的文件复制到StreamingAssets目录下
如果是构建热更会根据编译目标存放到 FileServer/{buildtarget}下
// 整个程序集都不要裁剪
private static readonly HashSet<string> assemblyAlls = new HashSet<string>
{
"mscorlib",
};
// 构建不同平台时会导致link增删,这里提供额外的补充
private static readonly Dictionary<string, List<string>> fixedList = new Dictionary<string, List<string>>()
{
};
根据提交记录和上次构建整包对比文件变化,aot出现改动时阻断
private static void HotUpdateDll(BuildTarget buildTarget, bool developmentBuild = false, bool isGenerateAot = false)
{
if (!SettingsUtil.Enable)
{
Debug.Log("HybridCLR unenable");
return;
}
InstallerController installer = new InstallerController();
if (!installer.HasInstalledHybridCLR())
installer.InstallDefaultHybridCLR();
Il2CppDefGeneratorCommand.GenerateIl2CppDef();
CompileDllCommand.CompileDll(buildTarget, developmentBuild);
// 工程导出后已经裁剪的类不能通过AOT增加?
// 暂时热更的时候去除AOT生成
if(isGenerateAot)
{
StripAOTDllCommand.GenerateStripedAOTDlls(buildTarget);
AOTReferenceGeneratorCommand.GenerateAOTGenericReference(buildTarget);
}
// 热更可能不能生成桥接函数,暂时先放着
MethodBridgeGeneratorCommand.GenerateMethodBridge(buildTarget);
}
构建步骤:
预留了读取buildInfo.json文件方便使用命令行模式启动时读取编译参数,以下为编译参数
private struct BuildInfo
{
public BuildTarget buildTarget;
public BuildTargetGroup buildTargetGroup;
public string localPathName;
public UIOrientation orientation;
public bool isRoationPortrait;
public bool isRoationLeft;
public bool isRoationRight;
public bool isRoationDown;
public bool isEnableHybridCLR;
public string identifier;
public bool isMono;
public BuildType buildType;
public bool buildWithDeepProfilingSupport;
public bool ExportProject;
public string bundleVersion;
public int bundleVersionCode;
public bool isAssetBundleIncrement;
}