Esempio n. 1
0
        private void MakeMabuPackage(string ProjectName, DirectoryReference ProjectDirectory, string ExePath, bool bForDistribution, string EngineDir, string MpkName)
        {
            string UE4BuildPath   = Path.Combine(ProjectDirectory.FullName, "Intermediate/Lumin/Mabu");
            string MabuOutputPath = Path.Combine(UE4BuildPath, "Packaged");
            // note this must match LuminPlatform.Automation:Package
            string MabuFile     = Path.Combine(UE4BuildPath, GetPackageName(ProjectName) + ".package");
            string ManifestFile = Path.Combine(UE4BuildPath, "manifest.xml");


            LuminToolChain ToolChain   = new LuminToolChain(ProjectFile);
            string         ExecSrcFile = Path.Combine(UE4BuildPath, "Binaries", Path.GetFileName(ExePath));

            // On installed builds on Mac, for BP-only projects,
            // if ExecSrcFile is already present,
            // File.Copy() (called directly or via ToolChain.StripSymbols())
            // fails to copy / overwrite ExePath to ExecSrcFile since the latter is read-only.
            // This is because BP-only projects use UE4Game executable
            // present in the Engine which is set read-only upon installation.
            // Copying this read-only file over to the project retains the read-only
            // flags, preventing any edit operations on it (such as stripping debug symbols).
            // Update the file attribs to make it read-write.
            MakeFileReadWrite(ExecSrcFile);

            if (bForDistribution || GetRemoveDebugInfo())
            {
                // If asked for, and if we are doing a distribution package, we strip debug symbols.
                Directory.CreateDirectory(Path.GetDirectoryName(ExecSrcFile));
                ToolChain.StripSymbols(new Tools.DotNETCommon.FileReference(ExePath), new Tools.DotNETCommon.FileReference(ExecSrcFile));
            }
            else
            {
                // The generated mabu needs the src exe file. So we copy the original as-is so mabu can find it.
                Directory.CreateDirectory(Path.GetDirectoryName(ExecSrcFile));
                File.Copy(ExePath, ExecSrcFile, true);
            }

            // On installed builds on Mac, for BP-only projects,
            // objcopy is unable to update ExecSrcFile when running
            // ToolChain.LinkSymbols() since the file is read-only.
            // This is because BP-only projects use UE4Game executable
            // present in the Engine which is set read-only upon installation.
            // Copying this read-only file over to the project retains the read-only
            // flags, preventing any edit operations on it (such as creating a gnu debug link).
            // Update the file attribs to make it read-write.
            MakeFileReadWrite(ExecSrcFile);

            // We also create a SYM file to support debugging
            string SymFile = Path.ChangeExtension(ExecSrcFile, "sym");

            ToolChain.ExtractSymbols(new FileReference(ExePath), new FileReference(SymFile));
            ToolChain.LinkSymbols(new FileReference(SymFile), new FileReference(ExecSrcFile));

            // Generate manifest (after UPL is setup
            const string Architecture = "arm64-v8a";
            var          Manifest     = GenerateManifest(ProjectName, bForDistribution, Architecture);

            File.WriteAllText(ManifestFile, Manifest);

            string MabuPackagingMessage = "Building mabu package....";
            string Certificate          = GetRuntimeSetting("Certificate");

            Certificate = CleanFilePath(Certificate);
            if (!string.IsNullOrEmpty(Certificate))
            {
                // For legacy sakes. We used to print this message when signing via the mbu commnd line so should continue to do so.
                // However, now this would only indicate if we are signing via the .package file and does not take into consideration
                // the MLCERT env var.
                MabuPackagingMessage = "Building signed mabu package....";
            }
            else if (bForDistribution)
            {
                // The user could be signing via the MLCERT env var so instead of throwing an exception, we simply log a warning.
                Log.TraceWarning("Packaging for distribution, however no certificate file has been chosen. Are you using the MLCERT environment variable instead?");
            }

            ToolChain.RunMabuWithException(Path.GetDirectoryName(MabuFile), String.Format("-t device --allow-unsigned -o \"{0}\" \"{1}\"", MabuOutputPath, Path.GetFileName(MabuFile)), MabuPackagingMessage);

            // copy the .mpk into binaries
            // @todo Lumin: Move this logic into a function in this class, and have AndroidAutomation call into it in GetFinalMpkName
            // @todo Lumin: Handle the whole Prebuilt thing, it may need to go somwehere else, or maybe this isn't even called?
            // @todo Lumin: This is losing the -Debug-Lumin stuff :|
            string SourceMpkPath = Path.Combine(MabuOutputPath, GetPackageName(ProjectName) + ".mpk");

            if (!Directory.Exists(Path.GetDirectoryName(MpkName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(MpkName));
            }
            if (File.Exists(MpkName))
            {
                File.Delete(MpkName);
            }
            File.Copy(SourceMpkPath, MpkName);
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="SourceFile"></param>
        /// <param name="TargetFile"></param>
        public static void StripSymbols(FileReference SourceFile, FileReference TargetFile)
        {
            LuminToolChain ToolChain = new LuminToolChain(null);

            ToolChain.StripSymbols(SourceFile, TargetFile);
        }
Esempio n. 3
0
        public void MakeMabuPackage(string ProjectName, DirectoryReference ProjectDirectory, string ExePath, bool bForDistribution, string EngineDir)
        {
            string UE4BuildPath   = Path.Combine(ProjectDirectory.FullName, "Intermediate/Lumin/Mabu");
            string MabuOutputPath = Path.Combine(UE4BuildPath, "Packaged");
            // note this must match LuminPlatform.Automation:Package
            string MabuFile     = Path.Combine(UE4BuildPath, GetPackageName(ProjectName) + ".package");
            string ManifestFile = Path.Combine(UE4BuildPath, "manifest.xml");


            LuminToolChain ToolChain = new LuminToolChain(ProjectFile);

            // Generate manifest (after UPL is setup
            string Architecture = "arm64-v8a";
            var    Manifest     = GenerateManifest(ProjectName, bForDistribution, Architecture);

            File.WriteAllText(ManifestFile, Manifest);

            string Certificate = GetRuntimeSetting("Certificate");

            Certificate = CleanFilePath(Certificate);
            if (!string.IsNullOrEmpty(Certificate))
            {
                Certificate = Path.GetFullPath(Path.Combine(EngineDir, "Binaries/Lumin", Certificate));

                if (File.Exists(Certificate))
                {
                    ToolChain.RunMabuWithException(Path.GetDirectoryName(MabuFile), String.Format("-t device -s \"{0}\" -o \"{1}\" \"{2}\"", Certificate, MabuOutputPath, Path.GetFileName(MabuFile)), "Building signed mabu package....");
                }
                else
                {
                    throw new BuildException(string.Format("Certificate file does not exist at path {0}. Please enter a valid certificate file path in Project Settings > Magic Leap or clear the field if you do not intend to sign the package.", Certificate));
                }
            }
            else
            {
                if (bForDistribution)
                {
                    // Certificate required for a distribution package.
                    throw new BuildException("Packaging for distribution, however no certificate file has been chosen. Please enter a certificate file in Project Settings > Magic Leap.");
                }
                // If a certificate file is not present but the package is not for distribution, package without signing.
                else
                {
                    ToolChain.RunMabuWithException(Path.GetDirectoryName(MabuFile), String.Format("-t device --allow-unsigned -o \"{0}\" \"{1}\"", MabuOutputPath, Path.GetFileName(MabuFile)), "Building mabu package....");
                }
            }

            // copy the .mpk into binaries
            // @todo Lumin: Move this logic into a function in this class, and have AndroidAutomation call into it in GetFinalMpkName
            // @todo Lumin: Handle the whole Prebuilt thing, it may need to go somwehere else, or maybe this isn't even called?
            // @todo Lumin: This is losing the -Debug-Lumin stuff :|
            string SourceMpkPath = Path.Combine(MabuOutputPath, GetPackageName(ProjectName) + ".mpk");

            string MpkName = Path.GetFileNameWithoutExtension(ExePath) + ".mpk";

            if (MpkName.StartsWith("UE4Game"))
            {
                MpkName = MpkName.Replace("UE4Game", ProjectName);
            }
            string DestMpkPath = Path.Combine(ProjectDirectory.FullName, "Binaries/Lumin", MpkName);

            if (!Directory.Exists(Path.GetDirectoryName(DestMpkPath)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(DestMpkPath));
            }
            if (File.Exists(DestMpkPath))
            {
                File.Delete(DestMpkPath);
            }
            File.Copy(SourceMpkPath, DestMpkPath);
        }
Esempio n. 4
0
        private void MakeMabuPackage(string ProjectName, DirectoryReference ProjectDirectory, string ExePath, bool bForDistribution, string EngineDir, string MpkName)
        {
            string UE4BuildPath   = Path.Combine(ProjectDirectory.FullName, "Intermediate/Lumin/Mabu");
            string MabuOutputPath = Path.Combine(UE4BuildPath, "Packaged");
            // note this must match LuminPlatform.Automation:Package
            string MabuFile     = Path.Combine(UE4BuildPath, GetPackageName(ProjectName) + ".package");
            string ManifestFile = Path.Combine(UE4BuildPath, "manifest.xml");


            LuminToolChain ToolChain   = new LuminToolChain(ProjectFile);
            string         ExecSrcFile = Path.Combine(UE4BuildPath, "Binaries", Path.GetFileName(ExePath));

            if (bForDistribution || GetRemoveDebugInfo())
            {
                // If asked for, and if we are doing a distribution package, we strip debug symbols.
                Directory.CreateDirectory(Path.GetDirectoryName(ExecSrcFile));
                ToolChain.StripSymbols(new Tools.DotNETCommon.FileReference(ExePath), new Tools.DotNETCommon.FileReference(ExecSrcFile));
                // We also create a SYM file to support debugging of stripped executables
                string SymFile = Path.ChangeExtension(ExecSrcFile, "sym");
                ToolChain.ExtractSymbols(new FileReference(ExePath), new FileReference(SymFile));
                ToolChain.LinkSymbols(new FileReference(SymFile), new FileReference(ExecSrcFile));
            }
            else
            {
                // The generated mabu needs the src exe file. So we copy the original as-is so mabu can find it.
                Directory.CreateDirectory(Path.GetDirectoryName(ExecSrcFile));
                File.Copy(ExePath, ExecSrcFile, true);
                // If the exe has debug info we need to remove a likely old sym file so that debugging doesn't use
                // outdated information.
                string SymFile = Path.ChangeExtension(ExecSrcFile, "sym");
                File.Delete(SymFile);
            }

            // Generate manifest (after UPL is setup
            string Architecture = "arm64-v8a";
            var    Manifest     = GenerateManifest(ProjectName, bForDistribution, Architecture);

            File.WriteAllText(ManifestFile, Manifest);

            string Certificate = GetRuntimeSetting("Certificate");

            Certificate = CleanFilePath(Certificate);
            if (!string.IsNullOrEmpty(Certificate))
            {
                Certificate = Path.GetFullPath(Path.Combine(ProjectDirectory.FullName, Certificate));

                if (File.Exists(Certificate))
                {
                    ToolChain.RunMabuWithException(Path.GetDirectoryName(MabuFile), String.Format("-t device -s \"{0}\" -o \"{1}\" \"{2}\"", Certificate, MabuOutputPath, Path.GetFileName(MabuFile)), "Building signed mabu package....");
                }
                else
                {
                    throw new BuildException(string.Format("Certificate file does not exist at path {0}. Please enter a valid certificate file path in Project Settings > Magic Leap or clear the field if you do not intend to sign the package.", Certificate));
                }
            }
            else
            {
                if (bForDistribution)
                {
                    // Certificate required for a distribution package.
                    throw new BuildException("Packaging for distribution, however no certificate file has been chosen. Please enter a certificate file in Project Settings > Magic Leap.");
                }
                // If a certificate file is not present but the package is not for distribution, package without signing.
                else
                {
                    ToolChain.RunMabuWithException(Path.GetDirectoryName(MabuFile), String.Format("-t device --allow-unsigned -o \"{0}\" \"{1}\"", MabuOutputPath, Path.GetFileName(MabuFile)), "Building mabu package....");
                }
            }

            // copy the .mpk into binaries
            // @todo Lumin: Move this logic into a function in this class, and have AndroidAutomation call into it in GetFinalMpkName
            // @todo Lumin: Handle the whole Prebuilt thing, it may need to go somwehere else, or maybe this isn't even called?
            // @todo Lumin: This is losing the -Debug-Lumin stuff :|
            string SourceMpkPath = Path.Combine(MabuOutputPath, GetPackageName(ProjectName) + ".mpk");

            if (!Directory.Exists(Path.GetDirectoryName(MpkName)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(MpkName));
            }
            if (File.Exists(MpkName))
            {
                File.Delete(MpkName);
            }
            File.Copy(SourceMpkPath, MpkName);
        }