private static void ExportStandaloneVm(Dictionary <string, string> args) { using (new PerformanceSection("ExportStandaloneVm")) { string vm; string targetDirectory; if (!args.TryGetValue(FlagParser.VM, out vm) || !args.TryGetValue(FlagParser.VM_DIR, out targetDirectory)) { throw new InvalidOperationException("-vm and -vmdir flags must both have correct values."); } Platform.AbstractPlatform standaloneVmPlatform = platformProvider.GetPlatform(vm); targetDirectory = FileUtil.FinalizeTilde(targetDirectory); VmGenerator vmGenerator = new VmGenerator(); List <Library> allLibraries = new LibraryManager(platformProvider).GetAllAvailableLibraries(standaloneVmPlatform); Dictionary <string, FileOutput> result = vmGenerator.GenerateVmSourceCodeForPlatform( standaloneVmPlatform, null, null, allLibraries, VmGenerationMode.EXPORT_VM_AND_LIBRARIES); FileOutputExporter exporter = new FileOutputExporter(targetDirectory); exporter.ExportFiles(result); } }
private static void ExportVmBundle(Dictionary <string, string> argLookup) { using (new PerformanceSection("ExportVmBundle")) { BuildContext buildContext = GetBuildContext(argLookup); Platform.AbstractPlatform platform = GetPlatformInstance(buildContext); if (platform == null) { throw new InvalidOperationException("Unrecognized platform. See usage."); } CompilationBundle compilationResult = CompilationBundle.Compile(buildContext); // Need to re-instantiate the libraries. The libraries are instantiated in a platform-context-free // for the purpose of compiling the byte code. For the VM bundle, they need to know about the platform. Library[] libraries; using (new PerformanceSection("Program.ExportVmBundle.CloneLibraries")) { libraries = compilationResult.LibrariesUsed .Select(lib => lib.CloneWithNewPlatform(platform)) .ToArray(); } ResourceDatabase resourceDatabase = PrepareResources(buildContext, compilationResult.ByteCode); string outputDirectory = buildContext.OutputFolder; if (!FileUtil.IsAbsolutePath(outputDirectory)) { outputDirectory = FileUtil.JoinPath(buildContext.ProjectDirectory, outputDirectory); } outputDirectory = FileUtil.GetCanonicalizeUniversalPath(outputDirectory); FileOutputExporter exporter = new FileOutputExporter(outputDirectory); VmGenerator vmGenerator = new VmGenerator(); Dictionary <string, FileOutput> result = vmGenerator.GenerateVmSourceCodeForPlatform( platform, compilationResult, resourceDatabase, libraries, outputDirectory, VmGenerationMode.EXPORT_SELF_CONTAINED_PROJECT_SOURCE); exporter.ExportFiles(result); if (argLookup.ContainsKey(FlagParser.LIBRARY_DEP_TREE)) { string libs = LibraryDependencyResolver.GetDependencyTreeLog(compilationResult.LibrariesUsed.ToArray()); Console.WriteLine("<LibraryDependencies>"); Console.WriteLine(libs.Trim()); Console.WriteLine("</LibraryDependencies>"); } } }