示例#1
0
        public override void ExportStandaloneVm(
            Dictionary <string, FileOutput> output,
            IList <VariableDeclaration> globals,
            IList <StructDefinition> structDefinitions,
            IList <FunctionDefinition> functionDefinitions,
            IList <LibraryForExport> everyLibrary,
            ILibraryNativeInvocationTranslatorProvider libraryNativeInvocationTranslatorProviderForPlatform)
        {
            Dictionary <string, string> libraryProjectNameToGuid = new Dictionary <string, string>();

            string runtimeProjectGuid  = IdGenerator.GenerateCSharpGuid("runtime", "runtime-project");
            string runtimeAssemblyGuid = IdGenerator.GenerateCSharpGuid("runtime", "runtime-assembly");

            Dictionary <string, string> replacements = new Dictionary <string, string>()
            {
                { "PROJECT_ID", "CrayonRuntime" },
                { "PROJECT_GUID", runtimeProjectGuid },
                { "INTERPRETER_PROJECT_GUID", runtimeProjectGuid },
                { "ASSEMBLY_GUID", runtimeAssemblyGuid },
                { "PROJECT_TITLE", "Crayon Runtime" },
                { "COPYRIGHT", "©" },
                { "CURRENT_YEAR", DateTime.Now.Year.ToString() },
                { "DLL_REFERENCES", "" },
                { "CSHARP_APP_ICON", "<ApplicationIcon>icon.ico</ApplicationIcon>" },
                { "EMBEDDED_RESOURCES", "<EmbeddedResource Include=\"icon.ico\" />" },
                { "CSHARP_CONTENT_ICON", "" },
                { "DLLS_COPIED", "" },
            };
            string baseDir = "CrayonRuntime/";

            string dllReferencesOriginal = replacements["DLL_REFERENCES"];
            string dllsCopiedOriginal    = replacements["DLLS_COPIED"];
            string embeddedResources     = replacements["EMBEDDED_RESOURCES"];

            replacements["EMBEDDED_RESOURCES"] = "";
            foreach (LibraryForExport library in everyLibrary)
            {
                string libBaseDir = "Libs/" + library.Name + "/";
                List <LangCSharp.DllFile> dlls = new List <LangCSharp.DllFile>();
                if (this.GetLibraryCode(libBaseDir, library, dlls, output, libraryNativeInvocationTranslatorProviderForPlatform))
                {
                    string name        = library.Name;
                    string projectGuid = IdGenerator.GenerateCSharpGuid(library.Name + "|" + library.Version, "library-project");
                    replacements["PROJECT_GUID"]  = projectGuid;
                    replacements["ASSEMBLY_GUID"] = IdGenerator.GenerateCSharpGuid(library.Name + "|" + library.Version, "library-assembly");
                    replacements["PROJECT_TITLE"] = library.Name;
                    replacements["LIBRARY_NAME"]  = library.Name;
                    LangCSharp.DllReferenceHelper.AddDllReferencesToProjectBasedReplacements(replacements, dlls, library.LibProjectNamesAndGuids);

                    libraryProjectNameToGuid[name] = projectGuid;

                    replacements["DOT_NET_LIBS"] = Util.JoinLines(
                        library.DotNetLibs.Select(
                            dotNetLib =>
                            "    <Reference Include=\"" + dotNetLib + "\" />")
                        .ToArray());

                    this.CopyResourceAsText(output, libBaseDir + library.Name + ".sln", "ResourcesLib/Solution.txt", replacements);
                    this.CopyResourceAsText(output, libBaseDir + library.Name + ".csproj", "ResourcesLib/ProjectFile.txt", replacements);
                    this.CopyResourceAsText(output, libBaseDir + "Properties/AssemblyInfo.cs", "ResourcesLib/AssemblyInfo.txt", replacements);

                    foreach (LangCSharp.DllFile dll in dlls)
                    {
                        output[libBaseDir + dll.HintPath] = dll.FileOutput;
                    }
                }
            }
            replacements["DLL_REFERENCES"]     = dllReferencesOriginal;
            replacements["DLLS_COPIED"]        = dllsCopiedOriginal;
            replacements["EMBEDDED_RESOURCES"] = embeddedResources;
            replacements["PROJECT_GUID"]       = runtimeProjectGuid;
            replacements["ASSEMBLY_GUID"]      = runtimeAssemblyGuid;

            this.CopyTemplatedFiles(baseDir, output, replacements, true);
            this.ExportInterpreter(baseDir, output, globals, structDefinitions, functionDefinitions);
            this.ExportProjectFiles(baseDir, output, replacements, libraryProjectNameToGuid, true);
            this.CopyResourceAsBinary(output, baseDir + "icon.ico", "ResourcesVm/icon.ico");

            TODO.MoveCbxParserIntoTranslatedPastelCode();
            this.CopyResourceAsText(output, baseDir + "CbxDecoder.cs", "ResourcesVm/CbxDecoder.txt", replacements);
        }
示例#2
0
        public override void ExportStandaloneVm(
            Dictionary <string, FileOutput> output,
            IList <LibraryForExport> everyLibrary)
        {
            Dictionary <string, string> libraryProjectNameToGuid = new Dictionary <string, string>();

            TemplateReader templateReader = new TemplateReader(new PkgAwareFileUtil(), this);

            string runtimeProjectGuid  = IdGenerator.GenerateCSharpGuid("runtime", "runtime-project");
            string runtimeAssemblyGuid = IdGenerator.GenerateCSharpGuid("runtime", "runtime-assembly");

            Dictionary <string, string> replacements = new Dictionary <string, string>()
            {
                { "PROJECT_ID", "CrayonRuntime" },
                { "PROJECT_GUID", runtimeProjectGuid },
                { "INTERPRETER_PROJECT_GUID", runtimeProjectGuid },
                { "ASSEMBLY_GUID", runtimeAssemblyGuid },
                { "PROJECT_TITLE", "Crayon Runtime" },
                { "COPYRIGHT", "©" },
                { "CURRENT_YEAR", CommonUtil.DateTime.Time.GetCurrentYear() + "" },
                { "DLL_REFERENCES", "" },
                { "CSHARP_APP_ICON", "<ApplicationIcon>icon.ico</ApplicationIcon>" },
                { "EMBEDDED_RESOURCES", "<EmbeddedResource Include=\"icon.ico\" />" },
                { "CSHARP_CONTENT_ICON", "" },
                { "DLLS_COPIED", "" },
            };
            string baseDir = "CrayonRuntime/";

            string dllReferencesOriginal = replacements["DLL_REFERENCES"];
            string dllsCopiedOriginal    = replacements["DLLS_COPIED"];
            string embeddedResources     = replacements["EMBEDDED_RESOURCES"];

            replacements["EMBEDDED_RESOURCES"] = "";
            foreach (LibraryForExport library in everyLibrary.Where(lib => lib.HasNativeCode))
            {
                string libBaseDir = "Libs/" + library.Name + "/";
                List <LangCSharp.DllFile> dlls       = new List <LangCSharp.DllFile>();
                HashSet <string>          dotNetRefs = new HashSet <string>();
                this.GetLibraryCode(templateReader, libBaseDir, library, dlls, dotNetRefs, output);

                string name        = library.Name;
                string projectGuid = IdGenerator.GenerateCSharpGuid(library.Name + "|" + library.Version, "library-project");
                replacements["PROJECT_GUID"]   = projectGuid;
                replacements["ASSEMBLY_GUID"]  = IdGenerator.GenerateCSharpGuid(library.Name + "|" + library.Version, "library-assembly");
                replacements["PROJECT_TITLE"]  = library.Name;
                replacements["LIBRARY_NAME"]   = library.Name;
                replacements["DLL_REFERENCES"] = GetFrameworkReferencesCsProjCode(dotNetRefs);

                LangCSharp.DllReferenceHelper.AddDllReferencesToProjectBasedReplacements(replacements, dlls);

                libraryProjectNameToGuid[name] = projectGuid;

                this.CopyResourceAsText(output, libBaseDir + library.Name + ".sln", "ResourcesLib/Solution.sln", replacements);
                this.CopyResourceAsText(output, libBaseDir + library.Name + ".csproj", "ResourcesLib/ProjectFile.csproj", replacements);
                this.CopyResourceAsText(output, libBaseDir + "Properties/AssemblyInfo.cs", "ResourcesLib/AssemblyInfo.cs", replacements);

                foreach (LangCSharp.DllFile dll in dlls)
                {
                    output[libBaseDir + dll.HintPath] = dll.FileOutput;
                }
            }
            replacements["DLL_REFERENCES"]     = dllReferencesOriginal;
            replacements["DLLS_COPIED"]        = dllsCopiedOriginal;
            replacements["EMBEDDED_RESOURCES"] = embeddedResources;
            replacements["PROJECT_GUID"]       = runtimeProjectGuid;
            replacements["ASSEMBLY_GUID"]      = runtimeAssemblyGuid;

            this.CopyTemplatedFiles(baseDir, output, replacements, true);
            this.ExportInterpreter(templateReader, baseDir, output);
            this.ExportProjectFiles(baseDir, output, replacements, libraryProjectNameToGuid, true);
            this.CopyResourceAsBinary(output, baseDir + "icon.ico", "ResourcesVm/icon.ico");

            TODO.MoveCbxParserIntoTranslatedPastelCode();
            this.CopyResourceAsText(output, baseDir + "CbxDecoder.cs", "ResourcesVm/CbxDecoder.cs", replacements);
        }