Exemplo n.º 1
0
        public static ExportResponse Run(
            Platform.AbstractPlatform platform,
            string projectDirectory,
            string outputDirectory,
            BuildData buildData)
        {
            if (platform == null)
            {
                throw new InvalidOperationException("Unrecognized platform. See usage.");
            }

            if (!Path.IsAbsolute(outputDirectory))
            {
                outputDirectory = FileUtil.JoinPath(projectDirectory, outputDirectory);
            }
            outputDirectory = FileUtil.GetCanonicalizeUniversalPath(outputDirectory);
            FileOutputExporter exporter = new FileOutputExporter(outputDirectory);

            Dictionary <string, FileOutput> result = new Dictionary <string, FileOutput>();

            ExportProperties exportProperties = buildData.ExportProperties;

            platform.GleanInformationFromPreviouslyExportedProject(exportProperties, outputDirectory);
            platform.ExportProject(result, buildData, exportProperties);

            exporter.ExportFiles(result);

            return(new ExportResponse());
        }
Exemplo n.º 2
0
 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);
     }
 }
Exemplo n.º 3
0
        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>");
                }
            }
        }
Exemplo n.º 4
0
        public ExportBundle ExportVmBundle(ExportCommand command, BuildContext buildContext)
        {
            // TODO: Worker: platform = GetPlatform(buildContext, command)
            string platformId = buildContext.Platform.ToLowerInvariant();

            Platform.AbstractPlatform platform = command.PlatformProvider.GetPlatform(platformId);
            if (platform == null)
            {
                throw new InvalidOperationException("Unrecognized platform. See usage.");
            }

            // TODO: Worker: Compile
            ExportBundle compilationResult = ExportBundle.Compile(buildContext);

            AssemblyMetadata[] libraries = compilationResult.LibraryScopesUsed.Select(scope => scope.Metadata).ToArray();

            ResourceDatabase resourceDatabase = ResourceDatabaseBuilder.PrepareResources(buildContext, compilationResult.ByteCode);

            string outputDirectory = command.HasOutputDirectoryOverride
                ? command.OutputDirectoryOverride
                : buildContext.OutputFolder;

            if (!Path.IsAbsolute(outputDirectory))
            {
                outputDirectory = FileUtil.JoinPath(buildContext.ProjectDirectory, outputDirectory);
            }
            outputDirectory = FileUtil.GetCanonicalizeUniversalPath(outputDirectory);
            FileOutputExporter exporter = new FileOutputExporter(outputDirectory);

            VmGenerator vmGenerator = new VmGenerator();
            Dictionary <string, FileOutput> result = new Dictionary <string, FileOutput>();

            vmGenerator.GenerateVmSourceCodeForPlatform(
                result,
                platform,
                compilationResult,
                resourceDatabase,
                libraries,
                outputDirectory,
                VmGenerationMode.EXPORT_SELF_CONTAINED_PROJECT_SOURCE);

            exporter.ExportFiles(result);

            // TODO: this needs to be the result of an earlier step after this is split into workers.
            return(compilationResult);
        }