Exemplo n.º 1
0
        private LibraryExporter(LibraryMetadata metadata, Platform.AbstractPlatform platform)
        {
            TODO.LibrariesNeedVersionNumber();

            this.Metadata     = metadata;
            this.platformName = platform.Name;

            this.Resources = new LibraryResourceDatabase(this, platform);

            this.CompileTimeConstants = this.LoadFlagsForPlatform(platform);

            this.filepathsByFunctionName = new Dictionary <string, string>();
            // Build a lookup dictionary of all file names that are simple function names e.g. "foo.cry"
            // Then go through and look up all the file names that contain . prefixes with the platform name and
            // overwrite the lookup value for that entry with the more specific path.
            // myFunction.cry
            // android.myFunction.cry
            // on Python, myFunction will be included for lib_foo_myFunction(), but on Android, android.myFunction.cry will be included instead.

            string[] files = new string[0];
            if (FileUtil.DirectoryExists(this.Metadata.Directory + "/translate"))
            {
                files = FileUtil.DirectoryListFileNames(FileUtil.JoinPath(this.Metadata.Directory, "translate"));
            }
            Dictionary <string, string> moreSpecificFiles = new Dictionary <string, string>();

            foreach (string file in files)
            {
                if (file.EndsWith(".pst"))
                {
                    string functionName = file.Substring(0, file.Length - ".pst".Length);
                    if (functionName.Contains('.'))
                    {
                        // Add this file to the more specific lookup, but only if it contains the current platform.
                        if (functionName.StartsWith(platformName + ".") ||
                            functionName.Contains("." + platformName + "."))
                        {
                            string[] parts = functionName.Split('.');
                            moreSpecificFiles[parts[parts.Length - 1]] = file;
                        }
                        else
                        {
                            // just let it get filtered away.
                        }
                    }
                    else
                    {
                        this.filepathsByFunctionName[functionName] = file;
                    }
                }
            }

            foreach (string functionName in moreSpecificFiles.Keys)
            {
                this.filepathsByFunctionName[functionName] = moreSpecificFiles[functionName];
            }
        }
Exemplo n.º 2
0
        private LibraryExporter(AssemblyMetadata metadata, Platform.AbstractPlatform platform)
        {
            TODO.LibrariesNeedVersionNumber();

            this.Metadata     = metadata;
            this.platformName = platform.Name;

            this.Resources = new LibraryResourceDatabase(this, platform);

            this.CompileTimeConstants = this.LoadFlagsForPlatform(platform);
        }
Exemplo n.º 3
0
        private Platform.LibraryForExport CreateLibraryForExport(
            string libraryName,
            string libraryVersion,
            string directory,
            LibraryResourceDatabase libResDb)
        {
            using (new PerformanceSection("VmGenerator.CreateLibraryForExport"))
            {
                Multimap <string, Platform.ExportEntity> exportEntities = libResDb.ExportEntities;

                return(new Platform.LibraryForExport(directory)
                {
                    Name = libraryName,
                    Version = libraryVersion,
                    HasNativeCode = libResDb.HasNativeCode,
                    ExportEntities = exportEntities,
                });
            }
        }
Exemplo n.º 4
0
        private Platform.LibraryForExport CreateLibraryForExport(
            string libraryName,
            string libraryVersion,
            Pastel.PastelCompiler compilation,
            LibraryResourceDatabase libResDb)
        {
            using (new PerformanceSection("VmGenerator.CreateLibraryForExport"))
            {
                Multimap <string, Platform.ExportEntity> exportEntities = libResDb.ExportEntities;
                FunctionDefinition manifestFunction = null;
                Dictionary <string, FunctionDefinition> otherFunctions = new Dictionary <string, FunctionDefinition>();
                foreach (FunctionDefinition functionDefinition in compilation.FunctionDefinitions.Values)
                {
                    string functionName = functionDefinition.NameToken.Value;
                    if (functionName == "lib_manifest_RegisterFunctions")
                    {
                        manifestFunction = functionDefinition;
                    }
                    else
                    {
                        otherFunctions[functionName] = functionDefinition;
                    }
                }

                string[]             names      = otherFunctions.Keys.OrderBy(s => s).ToArray();
                FunctionDefinition[] functions  = names.Select(n => otherFunctions[n]).ToArray();
                string[]             dotNetLibs = libResDb.DotNetLibs.OrderBy(s => s.ToLower()).ToArray();

                return(new Platform.LibraryForExport()
                {
                    Name = libraryName,
                    Version = libraryVersion,
                    FunctionRegisteredNamesOrNulls = names,
                    Functions = functions,
                    Structs = compilation.StructDefinitions.Values.ToArray(),
                    ManifestFunction = manifestFunction,
                    ExportEntities = exportEntities,
                    DotNetLibs = dotNetLibs,
                    LibProjectNamesAndGuids = libResDb.ProjectReferenceToGuid,
                });
            }
        }
Exemplo n.º 5
0
        private Platform.LibraryForExport CreateLibraryForExport(
            string libraryName,
            string libraryVersion,
            PastelContext nullableLibaryPastelContext,
            LibraryResourceDatabase libResDb)
        {
            using (new PerformanceSection("VmGenerator.CreateLibraryForExport"))
            {
                Multimap <string, Platform.ExportEntity> exportEntities = libResDb.ExportEntities;

                string[] dotNetLibs = libResDb.DotNetLibs.OrderBy(s => s.ToLower()).ToArray();

                return(new Platform.LibraryForExport()
                {
                    Name = libraryName,
                    Version = libraryVersion,
                    PastelContext = nullableLibaryPastelContext,
                    ExportEntities = exportEntities,
                    DotNetLibs = dotNetLibs,
                    LibProjectNamesAndGuids = libResDb.ProjectReferenceToGuid,
                });
            }
        }