예제 #1
0
        void Parse(XElement element, string filterBase, string prepend)
        {
            foreach (var child in element.Elements())
            {
                if (child.Name == "Filter")
                {
                    string filter = (string.IsNullOrEmpty(filterBase) ? "" : filterBase + "\\") + (string)child.Attribute("Name");
                    Filters.Add(filter, "");

                    Parse(child, filter, prepend);
                }
                else
                {
                    string path      = Path.Combine(prepend, (string)child.Attribute("RelativePath"));
                    string extension = Path.GetExtension(path);

                    if (extension == ".h")
                    {
                        IncludeFiles.Add(path, filterBase);
                    }
                    else if (extension == ".cpp")
                    {
                        SourceFiles.Add(path, filterBase);
                    }
                    else if (extension == ".resx")
                    {
                        ResourceFiles.Add(path, filterBase);
                    }
                    else
                    {
                        OtherFiles.Add(path, filterBase);
                    }
                }
            }
        }
예제 #2
0
        private static void GetResourcePaths(Assembly assembly)
        {
            var culture         = System.Threading.Thread.CurrentThread.CurrentCulture;
            var resourceName    = assembly.GetName().Name + ".g";
            var resourceManager = new ResourceManager(resourceName, assembly);

            try
            {
                var resourceSet = resourceManager.GetResourceSet(culture, true, true);

                foreach (System.Collections.DictionaryEntry resource in resourceSet)
                {
                    if (resource.Value != null && !ResourceFiles.ContainsKey(Path.GetFileName(resource.Key.ToString())))
                    {
                        ResourceFiles.Add(Path.GetFileName(resource.Key.ToString()), resource.Key.ToString());
                    }
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                resourceManager.ReleaseAllResources();
            }
        }
예제 #3
0
 public ProjectNetImguiServer()
     : base(true)
 {
     Name           = "netImguiServer";
     SourceRootPath = @"[project.SharpmakeCsPath]\..\Code\ServerApp";
     ResourceFiles.Add(@"[project.SharpmakeCsPath]\..\Code\ServerApp\small.ico");
     ResourceFiles.Add(@"[project.SharpmakeCsPath]\..\Code\ServerApp\netImguiApp.ico");
     ResourceFiles.Add(@"[project.SharpmakeCsPath]\..\Code\ServerApp\netImguiApp.rc");
     ResourceFiles.Add(@"[project.SharpmakeCsPath]\..\Code\ServerApp\Background.png");
 }
예제 #4
0
 public ProjectNetImguiServer()
     : base(true)
 {
     Name           = "NetImguiServer";
     SourceRootPath = NetImguiTarget.GetPath(@"\Code\ServerApp");
     ResourceFiles.Add(NetImguiTarget.GetPath(@"\Code\ServerApp\small.ico"));
     ResourceFiles.Add(NetImguiTarget.GetPath(@"\Code\ServerApp\netImguiApp.ico"));
     ResourceFiles.Add(NetImguiTarget.GetPath(@"\Code\ServerApp\netImguiApp.rc"));
     ResourceFiles.Add(NetImguiTarget.GetPath(@"\Code\ServerApp\Background.png"));
     SourceFilesBuildExcludeRegex.Add(@".*Code\\ServerApp\\Source\\Fonts\\.*");
     AddImguiBackendSources();
 }
예제 #5
0
        private void LoadAllWithExtension(string dataDirectory, string extension)
        {
            foreach (var file in Directory.GetFiles(dataDirectory, "*" + extension))
            {
                if (file.EndsWith(extension, StringComparison.OrdinalIgnoreCase))
                {
                    FileStream fs = null;
                    try
                    {
                        fs = new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
                        string  lcfileName = Path.GetFileName(file).ToLower();
                        LodFile lod        = new LodFile(this, fs);

                        lod.LoadFAT();
                        ResourceFiles.Add(lod);
                    }
                    catch (Exception ex)
                    {
                        fs.Close();
                    }
                }
            }
        }
예제 #6
0
        public ExePackaging() : base(typeof(CommonTarget))
        {
            DeployProject = true;

            Name = "exepackaging";

            SourceRootPath = Path.Combine(ProjectRootPath, @"codebase\temp\projects\" + Name);

            if (!Directory.Exists(SourceRootPath))
            {
                Directory.CreateDirectory(SourceRootPath);
            }

            AndroidManifest          = "AndroidManifest.xml";
            AntBuildXml              = "build.xml";
            AntProjectPropertiesFile = "project.properties";

            SourceFilesExtensions.Add(".xml");
            SourceFilesExclude.Add("AndroidManifest.xml", "build.xml");

            AddTargets(CommonTarget.GetAndroidTargets());

            //the plugin and gradle version are good and stable version to be used with Android libraries,
            //we don't want to use the default version on VS(ver. 0.4.0 and 2.8 respectively) since it is quite old
            GradlePlugin  = "gradle:4.2.0";
            GradleVersion = "6.7.1";

            // Path to the Gradle template files
            GradleTemplateFiles.Add(@"app\src\main\AndroidManifest.xml.template");
            GradleTemplateFiles.Add(@"app\build.gradle.template");
            GradleTemplateFiles.Add(@"build.gradle.template");
            GradleTemplateFiles.Add(@"settings.gradle.template");
            GradleTemplateFiles.Add(@"gradle\wrapper\gradle-wrapper.properties.template");

            ResourceFiles.Add(@"app\src\main\res\values\strings.xml");
        }
        public void Process(ConfigurationFile configurationFile)
        {
            Dictionary <string, string> aliases = configurationFile.Aliases.ToDictionary(x => x.Alias, x => x.FullClassName);
            ViewFileReader    viewFileReader    = new ViewFileReader(aliases);
            ViewFileProcessor viewFileProcessor = new ViewFileProcessor();
            ViewFileWriter    viewFileWriter    = new ViewFileWriter();

            DataTemplateProcessor dataTemplateProcessor = new DataTemplateProcessor(viewFileProcessor, viewFileWriter);

            List <Resource>             globalResources             = new List <Resource>();
            List <StyleResource>        globalStyleResources        = new List <StyleResource>();
            List <DataTemplateResource> globalDataTemplateResources = new List <DataTemplateResource>();

            foreach (string resourceFile in configurationFile.GlobalResourceFiles)
            {
                string resourceRelativePath = PathHelper.GetRelativePath(resourceFile);

                Log.LogMessage(MessageImportance.High, "\t# Preprocessing resource file {0}", resourceRelativePath);

                List <Resource>      resources      = viewFileProcessor.ExtractGlobalResources(viewFileReader.Read(resourceFile));
                List <StyleResource> styleResources = resources.Where(x => ParsingHelper.IsStyleTag(x.ResourceElement)).Select(x => new StyleResource(x)).ToList();
                resources.RemoveAll(x => ParsingHelper.IsStyleTag(x.ResourceElement));
                List <DataTemplateResource> dataTemplatesResources = resources.Where(x => ParsingHelper.IsDataTemplateTag(x.ResourceElement)).Select(x => new DataTemplateResource(x)).ToList();
                resources.RemoveAll(x => ParsingHelper.IsDataTemplateTag(x.ResourceElement));

                //assign an id to all data template before processing it (could be loop or just unordered things)
                string viewName = Path.GetFileNameWithoutExtension(resourceFile);
                foreach (DataTemplateResource dataTemplate in dataTemplatesResources)
                {
                    dataTemplate.ViewId = string.Format("G_{0}_DT_{1}", viewName, dataTemplate.Key);
                    dataTemplate.ViewHolderClassName = NameGeneratorHelper.GetViewHolderName();
                }

                globalResources.AddRange(resources);
                globalStyleResources.AddRange(styleResources);
                globalDataTemplateResources.AddRange(dataTemplatesResources);
            }
            //process each data template
            foreach (DataTemplateResource dataTemplate in globalDataTemplateResources)
            {
                dataTemplateProcessor.Process(dataTemplate, globalResources, globalStyleResources, globalDataTemplateResources, configurationFile);
            }


            foreach (FileBindingDescription fileBindingDescription in configurationFile.FileDescriptions)
            {
                string viewInputRelativePath  = PathHelper.GetRelativePath(fileBindingDescription.View.InputFile);
                string viewOutputRelativePath = PathHelper.GetRelativePath(fileBindingDescription.View.OutputFile);

                Log.LogMessage(MessageImportance.High, "\t# Preprocessing activity {0}.{1} with view {2}", fileBindingDescription.Activity.NamespaceName, fileBindingDescription.Activity.ClassName, viewInputRelativePath);

                XmlElement rootViewElement = viewFileReader.Read(fileBindingDescription.View.InputFile);
                //Parse expression, Extract resources and simplify the view file
                var expressionParsingResult              = viewFileProcessor.ExtractExpressions(rootViewElement);
                List <IdViewObject> viewObjects          = expressionParsingResult.Item2;
                List <XmlAttribute> expressionAttributes = expressionParsingResult.Item1;
                List <Resource>     resources            = viewFileProcessor.ExtractResources(rootViewElement);
                //filter resources for DataTemplate
                List <DataTemplateResource> dataTemplatesResources = resources.Where(x => ParsingHelper.IsDataTemplateTag(x.ResourceElement)).Select(x => new DataTemplateResource(x)).ToList();
                resources.RemoveAll(x => ParsingHelper.IsDataTemplateTag(x.ResourceElement));
                //filter resources for Style
                List <StyleResource> styleResources = resources.Where(x => ParsingHelper.IsStyleTag(x.ResourceElement)).Select(x => new StyleResource(x)).ToList();
                resources.RemoveAll(x => ParsingHelper.IsStyleTag(x.ResourceElement));


                List <StyleResource> totalStyleResources = new List <StyleResource>(styleResources);
                totalStyleResources.AddRange(globalStyleResources);

                //Write the view file for Android (axml format)
                Log.LogMessage(MessageImportance.High, "\t\t Generating view file {0}", viewOutputRelativePath);
                viewFileWriter.Write(rootViewElement, fileBindingDescription.View.OutputFile, totalStyleResources);
                ResourceFiles.Add(viewOutputRelativePath);


                //assign an id to all data template before processing it (could be loop or just unordered things)
                string viewName = Path.GetFileNameWithoutExtension(fileBindingDescription.View.OutputFile);
                foreach (DataTemplateResource dataTemplate in dataTemplatesResources)
                {
                    dataTemplate.ViewId = string.Format("{0}_DT_{1}", viewName, dataTemplate.Key);
                    dataTemplate.ViewHolderClassName = NameGeneratorHelper.GetViewHolderName();
                }

                List <Resource> totalResources = new List <Resource>(resources);
                totalResources.AddRange(globalResources);
                List <DataTemplateResource> totalDataTemplateResources = new List <DataTemplateResource>(dataTemplatesResources);
                totalDataTemplateResources.AddRange(globalDataTemplateResources);

                //process each data template
                foreach (DataTemplateResource dataTemplate in dataTemplatesResources)
                {
                    dataTemplateProcessor.Process(dataTemplate, totalResources, totalStyleResources, totalDataTemplateResources, configurationFile);
                }

                string classOutputFile         = fileBindingDescription.Activity.OutputFile;
                string classOutputRelativePath = PathHelper.GetRelativePath(classOutputFile);

                List <Resource> mergedResources = new List <Resource>(totalResources);
                mergedResources.AddRange(totalDataTemplateResources);
                AbstractBindingHandlerClassGenerator generator;
                if (fileBindingDescription.Activity.IsFragment)
                {
                    Log.LogMessage(MessageImportance.High, "\t\t Generating class file for Fragment to {0}", classOutputRelativePath);

                    generator = new FragmentGenerator
                    {
                        BaseClassType  = null,
                        ClassName      = fileBindingDescription.Activity.ClassName,
                        Configuration  = configurationFile,
                        IsPartialClass = true,
                        NamespaceName  = fileBindingDescription.Activity.NamespaceName,
                    };
                }
                else
                {
                    Log.LogMessage(MessageImportance.High, "\t\t Generating class file for Activity to {0}", classOutputRelativePath);

                    generator = new ActivityGenerator
                    {
                        BaseClassType  = null,
                        ClassName      = fileBindingDescription.Activity.ClassName,
                        Configuration  = configurationFile,
                        IsPartialClass = true,
                        NamespaceName  = fileBindingDescription.Activity.NamespaceName,
                    };
                }

                generator.Preprocess(expressionAttributes, mergedResources, viewObjects);
                generator.Generate(classOutputFile);

                ClassFiles.Add(classOutputRelativePath);
            }

            ClassFiles.AddRange(dataTemplateProcessor.ClassFiles);
            ResourceFiles.AddRange(dataTemplateProcessor.ResourceFiles);

            CreateDummyClass(configurationFile);
        }