Esempio n. 1
0
        public CxxTarget(CxxBinary target)
        {
            Name = target.Name;

            OutputName   = target.OutputName;
            OutputSuffix = target.OutputSuffix;

            SourceFiles = target.SourceFiles;
            SourceFiles.Sort();

            foreach (var dependency in target.Dependencies)
            {
                switch (dependency.Value)
                {
                case string s:
                    unlinkedDependencies_.Add(s);
                    break;

                case Target t:
                    unlinkedDependencies_.Add(t.Name);
                    break;
                }
            }

            PreprocessorDefinitions = target.PreprocessorDefinitions;
        }
Esempio n. 2
0
        private void ReadInf(string infFile, TitleReplacer titleReplacer)
        {
            InfFile = infFile;
            var infData = Data.CreateDataStorage();
            var ini     = new IniStorage(Encoding.GetEncoding("Unicode"));

            ini.SetData(infData);
            ini.ReadData(infFile);

            foreach (var section in infData.GetSections())
            {
                var sfi = SourceFileInfo.ReadSourceFileInfo(infFile, infData, section);
                if (sfi != null)
                {
                    SourceFiles.Add(sfi);
                }
            }

            Metadata = new Metadata();

            if (SourceFiles.Count > 0)
            {
                Metadata.PrintJobAuthor = SourceFiles[0].Author;
                Metadata.PrintJobName   = titleReplacer.Replace(SourceFiles[0].DocumentTitle);
                Metadata.Title          = ""; //Set to avoid null exception when replacing tokens
                Metadata.Author         = "";

                JobType = SourceFiles[0].Type;
            }
        }
        public override IEnumerable <string> Results(bool verbose)
        {
            var result = new List <string>();

            if (verbose)
            {
                result.Add($"Opened {FileType} File: {ProjectPath}");
                result.Add($"TargetFrameworkVersion {TargetFrameworkVersion}");
                result.Add($"Output {Assemblies.Count} Assemblies");
                result.AddRange(Assemblies.Select(assembly => '\t' + assembly.ToString()));
                result.Add($"Referenced {References.Count} Assemblies");
                result.AddRange(References.Select(assembly => '\t' + assembly.ToString()));
                result.Add($"Source Files {SourceFiles.Count}");
                result.AddRange(SourceFiles.Select(resource => '\t' + resource.ToString()));
                result.Add($"Dependancies {Dependencies.Count}");
                result.AddRange(Dependencies.Select(dependancy => '\t' + dependancy));
                result.Add($"Missing Files: {MissingFiles.Count}");
                result.AddRange(MissingFiles.Select(missing => '\t' + missing.Path));
            }
            else if (MissingFiles.Count > 0)
            {
                result.Add($"Opened {Path.GetFileName(ProjectPath)} Missing: {MissingFiles.Count}/{SourceFiles.Count} References: {References.Count}");
            }
            return(result);
        }
Esempio n. 4
0
        public DebugProject()
            : base(typeof(Target), typeof(Configuration), isInternal: true)
        {
            _projectInfo = DebugProjectGenerator.DebugProjects[GetType()];

            // set paths
            RootPath       = _projectInfo.ProjectFolder;
            SourceRootPath = RootPath;

            // add selected source files
            SourceFiles.AddRange(_projectInfo.ProjectFiles);

            // ensure that no file will be automagically added
            SourceFilesExtensions.Clear();
            ResourceFilesExtensions.Clear();
            PRIFilesExtensions.Clear();
            ResourceFiles.Clear();
            NoneExtensions.Clear();
            VsctExtension.Clear();

            Name = _projectInfo.DisplayName;

            // Use the new csproj style
            ProjectSchema = CSharpProjectSchema.NetCore;

            // prevents output dir to have a framework subfolder
            CustomProperties.Add("AppendTargetFrameworkToOutputPath", "false");

            // we need to disable determinism while because we are using wildcards in assembly versions
            // error CS8357: The specified version string contains wildcards, which are not compatible with determinism
            CustomProperties.Add("Deterministic", "false");

            AddTargets(DebugProjectGenerator.GetTargets());
        }
Esempio n. 5
0
        public DemoProject()
        {
            Name           = "DearWidgetsDemo";
            SourceRootPath = RootPath + @"\src\demo";

            SourceFiles.Add("[project.ExternPath]/glad/src/glad.c");
            SourceFiles.Add("[project.ExternPath]/imgui/imgui.cpp");
            SourceFiles.Add("[project.ExternPath]/imgui/imgui_tables.cpp");
            SourceFiles.Add("[project.ExternPath]/imgui/imgui_widgets.cpp");
            SourceFiles.Add("[project.ExternPath]/imgui/misc/cpp/imgui_stdlib.cpp");
            SourceFiles.Add("[project.ExternPath]/imgui/imgui_draw.cpp");

            // Mains
            SourceFiles.Add(@"[project.RootPath]/src/demo/main_dx11.cpp");
            SourceFiles.Add(@"[project.RootPath]/src/demo/main_dx12.cpp");

            // Backend
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_win32.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_win32.cpp");

            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_dx11.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_dx11.cpp");

            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_dx12.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_dx12.cpp");

            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_opengl3.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_opengl3.cpp");

            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_vulkan.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_vulkan.cpp");

            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_wgpu.h");
            SourceFiles.Add("[project.ExternPath]/imgui/backends/imgui_impl_wgpu.cpp");
        }
Esempio n. 6
0
        internal void AddResult(Mono.Cecil.Cil.SequencePoint sequencePoint, MutantMetaData mutantMetaData, bool mutantKilled)
        {
            if (sequencePoint == null || sequencePoint.Document == null)
            {
                return;
            }
            _mutantsCount++;
            _mutantsKilledCount += (mutantKilled ? 1 : 0);
            string sourceFileUrl = sequencePoint.Document.Url;

            _readerWriterLock.EnterUpgradeableReadLock();
            try
            {
                if (SourceFiles.All(s => s.Url != sourceFileUrl))
                {
                    _readerWriterLock.EnterWriteLock();
                    var newSourceFile = new SourceFile();
                    newSourceFile.SetUrl(sourceFileUrl);
                    SourceFiles.Add(newSourceFile);
                    _readerWriterLock.ExitWriteLock();
                }
            }
            finally
            {
                _readerWriterLock.ExitUpgradeableReadLock();
            }
            var sourceFile = SourceFiles.First(s => s.Url == sourceFileUrl);

            sourceFile.AddResult(sequencePoint, mutantMetaData, mutantKilled);
        }
Esempio n. 7
0
        public void AddFile(string fullPath)
        {
            if (!IsExcluded(fullPath))
            {
                var folder = FindFolder(Path.GetDirectoryName(fullPath) + "\\");

                var sourceFile = FileSystemFile.FromPath(this, folder, fullPath.ToPlatformPath().NormalizePath());

                SourceFiles.InsertSorted(sourceFile);

                if (folder != null)
                {
                    if (folder.Location == Project.CurrentDirectory)
                    {
                        Project.Items.InsertSorted(sourceFile);
                        sourceFile.Parent = Project;
                    }
                    else
                    {
                        folder.Items.InsertSorted(sourceFile);
                        sourceFile.Parent = folder;
                    }

                    FileAdded?.Invoke(this, sourceFile);
                }
            }
        }
Esempio n. 8
0
        /// <summary>
        ///     Deletes the inf file and optionally the source files
        ///     <param name="includeSourceFiles">If true, the source files will be deleted as well</param>
        /// </summary>
        public void Delete(bool includeSourceFiles)
        {
            if (includeSourceFiles)
            {
                foreach (var sourceFileInfo in SourceFiles)
                {
                    try
                    {
                        File.Delete(sourceFileInfo.Filename);
                    }
                    catch (IOException)
                    {
                    }
                }
                SourceFiles.Clear();
            }

            try
            {
                if (!string.IsNullOrEmpty(InfFile))
                {
                    File.Delete(InfFile);
                }
            }
            catch (IOException)
            {
            }
            InfFile = null;
        }
Esempio n. 9
0
        private void btnBrowse_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog fwd = new FolderBrowserDialog();

            fwd.RootFolder = Environment.SpecialFolder.MyComputer;
            if (fwd.ShowDialog() == DialogResult.OK)
            {
                clbCppFilesList.Items.Clear();
                string[] fileNames  = Directory.GetFiles(fwd.SelectedPath).Where(x => x.EndsWith(".cpp") || x.EndsWith(".h")).ToArray();
                int      filesCount = 0;
                int      totalFiles = fileNames.Length;
                foreach (string f in fileNames)
                {
                    FileObject fo = new FileObject();
                    fo.fileName      = Path.GetFileName(f);
                    fo.fileExtension = Path.GetExtension(fo.fileName);
                    fo.filePath      = f;
                    fo.cppCode       = File.ReadAllText(f);
                    fo.srcML         = GenerateSrcMl(f);
                    clbCppFilesList.Items.Add(fo);
                    SourceFiles.Add(fo);

                    filesCount++;
                    lbl_SrcMLFiles.Text = $"Source Files ({filesCount}/{totalFiles})";
                }
            }
        }
Esempio n. 10
0
 // Add a range of source files to compile
 public static void AddSourceFiles(string[] sourceFiles)
 {
     foreach (string src in sourceFiles)
     {
         SourceFiles.Add(OutputDirectory + src);
     }
 }
Esempio n. 11
0
 // Add a range of source files to compile
 public static void AddSourceFiles(string[] sourceFiles)
 {
     foreach (string src in sourceFiles)
     {
         SourceFiles.Add(Path.Combine(OutputDirectory, src));
     }
 }
Esempio n. 12
0
        internal void RegisterMethod(MethodDefinition method)
        {
            if (method.Body.Instructions.All(i => i.SequencePoint == null))
            {
                return;
            }
            string sourceFileUrl =
                method.Body.Instructions.First(i => i.SequencePoint != null).SequencePoint.Document.Url;

            _readerWriterLock.EnterUpgradeableReadLock();
            try
            {
                if (SourceFiles.All(s => s.Url != sourceFileUrl))
                {
                    _readerWriterLock.EnterWriteLock();
                    var newSourceFile = new SourceFile();
                    newSourceFile.SetUrl(sourceFileUrl);
                    SourceFiles.Add(newSourceFile);
                    _readerWriterLock.ExitWriteLock();
                }
            }
            finally
            {
                _readerWriterLock.ExitUpgradeableReadLock();
            }
            var sourceFile     = SourceFiles.First(s => s.Url == sourceFileUrl);
            var sequencePoints = method.Body.Instructions
                                 .Where(i => i.SequencePoint != null && i.ShouldReportSequencePoint())
                                 .Select(i => i.SequencePoint).Distinct();

            foreach (var point in sequencePoints)
            {
                sourceFile.AddSequencePoint(point);
            }
        }
Esempio n. 13
0
        public void Copy()
        {
            var events = new List <ManualResetEvent>();

            for (int index = 0; index < SourceFiles.Count; index++)
            {
                var resetEvent = new ManualResetEvent(false);
                ThreadPool.QueueUserWorkItem(state =>
                {
                    string source;
                    string target;
                    SourceFiles.TryDequeue(out source);
                    Target.TryDequeue(out target);
                    if (source != null && target != null)
                    {
                        lock (_lockObject)
                        {
                            if (Target != null && !Directory.Exists(Path.GetDirectoryName(target)))
                            {
                                Directory.CreateDirectory(Path.GetDirectoryName(target));
                            }
                        }
                        File.Copy(source, target, true);
                        Interlocked.Increment(ref _filesCounter);
                    }
                    resetEvent.Set();
                });
                events.Add(resetEvent);
            }
            WaitHandle.WaitAll(events.ToArray());
        }
Esempio n. 14
0
        /// <summary>
        /// Adds a file to this project, ignoring dupes
        /// </summary>
        /// <param name="FilePath">Path to the file on disk</param>
        /// <param name="RelativeBaseFolder">The directory the path within the project will be relative to</param>
        public void AddFileToProject(string FilePath, string RelativeBaseFolder)
        {
            // Don't add duplicates
            SourceFile ExistingFile = null;

            if (SourceFileMap.TryGetValue(FilePath, out ExistingFile))
            {
                if (ExistingFile.RelativeBaseFolder != RelativeBaseFolder)
                {
                    if ((ExistingFile.RelativeBaseFolder != null) != (RelativeBaseFolder != null) ||
                        !ExistingFile.RelativeBaseFolder.Equals(RelativeBaseFolder, StringComparison.InvariantCultureIgnoreCase))
                    {
                        throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but with a different relative base folder '" + RelativeBaseFolder + "' is different than the current file's '" + ExistingFile.RelativeBaseFolder + "'!");
                    }
                    else
                    {
                        throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but the specified project relative base folder is different than the current file's!");
                    }
                }
            }
            else
            {
                SourceFile File = AllocSourceFile(FilePath, RelativeBaseFolder);
                if (File != null)
                {
                    SourceFileMap[FilePath] = File;
                    SourceFiles.Add(File);
                }
            }
        }
Esempio n. 15
0
        private ImmutableDictionary <string, ImmutableList <LinkSourceInfo> > GetFileLinkSource(FileAndType ft, HtmlDocument doc)
        {
            var fileLinkSources = new Dictionary <string, List <LinkSourceInfo> >();

            foreach (var pair in (from n in doc.DocumentNode.Descendants()
                                  where !string.Equals(n.Name, "xref", StringComparison.OrdinalIgnoreCase)
                                  from attr in n.Attributes
                                  where string.Equals(attr.Name, "src", StringComparison.OrdinalIgnoreCase) ||
                                  string.Equals(attr.Name, "href", StringComparison.OrdinalIgnoreCase)
                                  where !string.IsNullOrWhiteSpace(attr.Value)
                                  select new { Node = n, Attr = attr }).ToList())
            {
                string linkFile;
                string anchor = null;
                var    link   = pair.Attr;
                if (TypeForwardedToPathUtility.IsRelativePath(link.Value))
                {
                    var index = link.Value.IndexOfAny(UriFragmentOrQueryString);
                    if (index == -1)
                    {
                        linkFile = link.Value;
                    }
                    else if (index == 0)
                    {
                        continue;
                    }
                    else
                    {
                        linkFile = link.Value.Remove(index);
                        anchor   = link.Value.Substring(index);
                    }
                    var    path = (TypeForwardedToRelativePath)ft.File + (TypeForwardedToRelativePath)linkFile;
                    string file = path.GetPathFromWorkingFolder().UrlDecode();
                    if (SourceFiles.ContainsKey(file))
                    {
                        link.Value = file;
                        if (!string.IsNullOrEmpty(anchor) &&
                            string.Equals(link.Name, "href", StringComparison.OrdinalIgnoreCase))
                        {
                            pair.Node.SetAttributeValue("anchor", anchor);
                        }
                    }

                    List <LinkSourceInfo> sources;
                    if (!fileLinkSources.TryGetValue(file, out sources))
                    {
                        sources = new List <LinkSourceInfo>();
                        fileLinkSources[file] = sources;
                    }
                    sources.Add(new LinkSourceInfo
                    {
                        Target     = file,
                        Anchor     = anchor,
                        SourceFile = pair.Node.GetAttributeValue("sourceFile", null),
                        LineNumber = pair.Node.GetAttributeValue("sourceStartLineNumber", 0),
                    });
                }
            }
            return(fileLinkSources.ToImmutableDictionary(x => x.Key, x => x.Value.ToImmutableList()));
        }
Esempio n. 16
0
        /// <summary>
        /// Adds a file to this project, ignoring dupes
        /// </summary>
        /// <param name="FilePath">Path to the file on disk</param>
        /// <param name="BaseFolder">The directory the path within the project will be relative to</param>
        public void AddFileToProject(FileReference FilePath, DirectoryReference BaseFolder)
        {
            // Check if hasn't already been added as an aliased file
            if (AliasedFilesSet.Contains(FilePath))
            {
                return;
            }

            // Don't add duplicates
            SourceFile ExistingFile = null;

            if (SourceFileMap.TryGetValue(FilePath, out ExistingFile))
            {
                if (ExistingFile.BaseFolder != BaseFolder)
                {
                    throw new BuildException("Trying to add file '" + FilePath + "' to project '" + ProjectFilePath + "' when the file already exists, but with a different relative base folder '" + BaseFolder + "' is different than the current file's '" + ExistingFile.BaseFolder + "'!");
                }
            }
            else
            {
                SourceFile File = AllocSourceFile(FilePath, BaseFolder);
                if (File != null)
                {
                    SourceFileMap[FilePath] = File;
                    SourceFiles.Add(File);
                }
            }
        }
Esempio n. 17
0
        public override bool Execute()
        {
            TaskLoggingHelper loggingHelper = new TaskLoggingHelper(this);

            try
            {
                loggingHelper.LogMessageFromText("*** Start View Model generation from Proto Reflection", MessageImportance.High);
                if (SourceFiles.Count() != DestinationFiles.Count())
                {
                    loggingHelper.LogError("Expected SourceFiles.Count == DestinationFiles.Count");
                    return(false);
                }
                int count = SourceFiles.Count();
                if (count == 0)
                {
                    loggingHelper.LogError("Expected SourceFiles.Count > 0");
                    return(false);
                }
                for (int i = 0; i < count; i++)
                {
                    Generate(SourceFiles[i], DestinationFiles[i], loggingHelper);
                }
            }
            catch (Exception ex)
            {
                loggingHelper.LogErrorFromException(ex);
                return(false);
            }
            return(true);
        }
Esempio n. 18
0
        public int Assemble()
        {
            var args = new StringBuilder("-march mips3 -mabi 32 -mno-shared -call_nonpic -EB ");

            args.AppendFormat("-o \"{0}\" ", OutputFile);

            args.Append(SourceFiles.Aggregate((allFiles, filename) => allFiles += " \"" + filename + "\""));

            Console.WriteLine("Assembling to {0}...", OutputFile);

            var info = new ProcessStartInfo()
            {
                FileName               = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Binaries", "as.exe"),
                Arguments              = args.ToString(),
                CreateNoWindow         = true,
                ErrorDialog            = false,
                RedirectStandardInput  = true,
                RedirectStandardOutput = true,
                RedirectStandardError  = true,
                UseShellExecute        = false,
                WorkingDirectory       = Directory.GetCurrentDirectory()
            };

            var assembler = new Process
            {
                StartInfo = info
            };

            assembler.OutputDataReceived += (source, evt) =>
            {
                Console.Out.WriteLine(evt.Data);
            };
            assembler.ErrorDataReceived += (source, evt) =>
            {
                Console.Error.WriteLine(evt.Data);
            };

            assembler.EnableRaisingEvents = true;
            assembler.Start();
            assembler.BeginOutputReadLine();
            assembler.BeginErrorReadLine();

            while (!assembler.HasExited)
            {
                assembler.WaitForExit(50);
            }

            if (assembler.ExitCode != 0)
            {
                Console.Error.WriteLine("Failed to assemble {0} (exit code was {1}), exiting.", OutputFile, assembler.ExitCode);
                return(assembler.ExitCode);
            }

            Pipeline.AssembledArtifact = OutputFile;

            Console.WriteLine("Assembled ELF object file: {0}", OutputFile);

            return(0);
        }
 private static string GetSourceFileSeparator(string source)
 {
     try
     {
         return(SourceFilesLanguageSeparator[SourceFiles.ToList().IndexOf(source)]);
     }
     catch { return(string.Empty); }
 }
Esempio n. 20
0
        public override void ExcludeFile(ISourceFile file)
        {
            file.Parent.Items.Remove(file);

            ExcludedFiles.Add(file.Project.CurrentDirectory.MakeRelativePath(file.Location).ToAvalonPath());
            SourceFiles.Remove(file);
            Save();
        }
Esempio n. 21
0
 public ProjectNetImgui(string version)
     : base(false)
 {
     mVersion       = version;
     Name           = "netImguiLib (" + version + ")";
     SourceRootPath = @"[project.SharpmakeCsPath]\..\Code\Client";
     SourceFiles.Add(@"[project.SharpmakeCsPath]\..\Code\ThirdParty\" + SolutionAll.sDefaultImguiVersion + @"\imgui.h");
 }
Esempio n. 22
0
 /// <summary>
 /// Adds the source files.
 /// </summary>
 /// <param name="files">The files.</param>
 public void AddSourceFiles(IEnumerable <string> files)
 {
     foreach (string file in files)
     {
         SourceFile sourceFile = new SourceFile(file);
         SourceFiles.Add(sourceFile);
     }
 }
Esempio n. 23
0
 private static IEnumerable <CopyJob> GetCopyJobs(SourceFiles sourceFiles, string sourceBaseFolder, string targetBaseFolder)
 {
     return(from sourceFile in sourceFiles.Files
            let relativePath = sourceFile.Replace(sourceBaseFolder, null)
                               let targetFile = PathCombine(targetBaseFolder, relativePath)
                                                select new CopyJob {
         Source = sourceFile, Target = targetFile
     });
 }
Esempio n. 24
0
        public void RemoveFile(ISourceFile file)
        {
            file.Parent?.Items.Remove(file);
            SourceFiles.Remove(file);

            IoC.Get <IShell>().RemoveDocument(file);

            FileRemoved?.Invoke(this, file);
        }
Esempio n. 25
0
        public override string ToString()
        {
            if (SourceFiles?.Any() == true)
            {
                return($"{Alias} ({string.Join(", ", SourceFiles)})");
            }

            return(Alias);
        }
Esempio n. 26
0
        public void RemoveFile(string path)
        {
            SourceFile file = SourceFiles.FirstOrDefault(f => string.Compare(f.Path, path) == 0);

            if (file != null)
            {
                SourceFiles.Remove(file);
            }
        }
Esempio n. 27
0
 public ProjectNetImgui(string imguiFullPath)
     : base(false)
 {
     mVersion       = Path.GetFileName(imguiFullPath);
     mImguiPath     = imguiFullPath;
     Name           = "NetImguiLib (" + mVersion + ")";
     SourceRootPath = NetImguiTarget.GetPath(@"\Code\Client");
     SourceFiles.Add(mImguiPath + @"\imgui.h");
 }
Esempio n. 28
0
        /// <summary>
        /// Adds the source file.
        /// </summary>
        /// <param name="path">The path.</param>
        public void AddSourceFile(string path)
        {
            if (string.IsNullOrWhiteSpace(path))
            {
                return;
            }

            SourceFiles.AddIfNew(path);
        }
Esempio n. 29
0
        public void DisplayCurrentCode()
        {
            RefreshSourceMaps();

            //
            // Select active files in the source file list
            //
            SourceFiles.ClearSelected();

            foreach (SourceMap s in _sourceMaps)
            {
                foreach (string fileName in s.GetSourceFiles())
                {
                    for (int i = 0; i < SourceFiles.Items.Count; i++)
                    {
                        if (fileName == (string)SourceFiles.Items[i])
                        {
                            SourceFiles.SetSelected(i, true);
                        }
                    }
                }
            }

            //
            // Find the source line that matches the current TPC, if any.
            //
            int tpc = _system.CP.TPC[(int)_system.CP.CurrentTask];

            foreach (SourceMap s in _sourceMaps)
            {
                SourceEntry entry = s.GetExactSourceForAddress((ushort)tpc);

                if (entry != null)
                {
                    // WE GOT ONE!!!
                    SourceDisplay.AttachMap(s);
                    SourceDisplay.SelectSourceEntry(entry, false, false /* cp */);

                    // Select the source file in the source list
                    for (int i = 0; i < SourceFiles.Items.Count; i++)
                    {
                        if (entry.SourcePath == (string)SourceFiles.Items[i])
                        {
                            SourceFiles.SetSelected(i, true);
                        }
                    }

                    break;
                }
            }

            //
            // Highlight the line in the disassembly as well.
            //
            Disassembly.SelectAddress(tpc);
        }
Esempio n. 30
0
    public override void ExecuteBuild()
    {
        // Command parameters - not all required if using existing manifest
        string             ProjectPath  = ParseParamValue("ProjectPath");
        string             ManifestFile = ParseParamValue("ManifestFile");
        string             UE4Exe       = ParseParamValue("UE4Exe", "UE4Editor-Cmd.exe");
        string             Maps         = ParseParamValue("Maps");
        string             Parameters   = ParseParamValue("Parameters");
        DirectoryReference FromDir      = new DirectoryReference(ParseParamValue("FromDir"));
        DirectoryReference ToDir        = new DirectoryReference(ParseParamValue("ToDir"));
        bool UseExistingManifest        = ParseParam("UseExistingManifest");

        List <string> SourceFiles;

        if (UseExistingManifest && FileExists_NoExceptions(ManifestFile))
        {
            // Read Source Files from Manifest
            List <string> Lines = new List <string>(ReadAllLines(ManifestFile));
            if (Lines.Count < 1)
            {
                throw new AutomationException("Manifest file {0} does not list any files.", ManifestFile);
            }
            SourceFiles = new List <string>();
            foreach (var ThisFile in Lines)
            {
                var TestFile = CombinePaths(ThisFile);
                if (!FileExists_NoExceptions(TestFile))
                {
                    throw new AutomationException("GenerateDistillFileSets produced {0}, but {1} doesn't exist.", ThisFile, TestFile);
                }
                // we correct the case here
                var TestFileInfo = new FileInfo(TestFile);
                var FinalFile    = CombinePaths(TestFileInfo.FullName);
                if (!FileExists_NoExceptions(FinalFile))
                {
                    throw new AutomationException("GenerateDistillFileSets produced {0}, but {1} doesn't exist.", ThisFile, FinalFile);
                }
                SourceFiles.Add(FinalFile);
            }
        }
        else
        {
            // Run commandlet to get files required for maps
            FileReference Project   = new FileReference(ProjectPath);
            string[]      SplitMaps = null;
            if (!String.IsNullOrEmpty(Maps))
            {
                SplitMaps = Maps.Split(new char[] { '+', ';' }, StringSplitOptions.RemoveEmptyEntries).ToArray();
            }
            SourceFiles = GenerateDistillFileSetsCommandlet(Project, ManifestFile, UE4Exe, SplitMaps, Parameters);
        }
        // Convert Source file paths to output paths and copy
        IEnumerable <FileReference> TargetFiles = SourceFiles.Select(x => FileReference.Combine(ToDir, new FileReference(x).MakeRelativeTo(FromDir)));

        CommandUtils.ThreadedCopyFiles(SourceFiles, TargetFiles.Select(x => x.FullName).ToList());
    }
Esempio n. 31
0
        public SourceFile(string identity, string body)
        {
            Body = body;

            if (identity != null)
                Identity = identity.Replace('/', '\\');

            if (identity != string.Empty)
                BasePath = Path.GetDirectoryName(identity);

            _components = new SourceFiles();
        }
Esempio n. 32
0
        public void InputValidationSpecifications()
        {
            Parser parser = null;
            "Given new Parser".Context(() => parser = new Parser());

            "ParseSourceFiles throws ArgumentNullException when invoked with null".AssertThrows<ArgumentNullException>(() => parser.ParseSourceFiles(null, ParserOptions.Default));
            "ParseSourceFiles throws InvalidOperationException when invoked with source file containing a null Body"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles {new SourceFile("filename.js", null)};
                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
            "ParseSourceFiles throws InvalidOperationException when invoked with source file containing a null Identity"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles {new SourceFile(null, "@rivet")};
                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
            "ParseSourceFiles throws InvalidOperationExceptionwhen when invoked with source file containing an empty Identity"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles {new SourceFile(string.Empty, "@rivet")};
                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
            "ParseSourceFiles throws InvalidOperationException when invoked with source files referencing a file that does not exist"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles {new SourceFile("filename.js", "@rivet includes.push(\"include.js\");")};
                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
            "ParseSourceFiles throws InvalidOperationException when invoked with an include file containing an empty Body"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles
                                                         		                  	{
                                                         		                  		new SourceFile("main.js", "@rivet includes.push(\"include.js\");"),
                                                         		                  		new SourceFile("include.js", string.Empty)
                                                         		                  	};
                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
            "ParseSourceFiles does not throw an exception when invoked with an empty source file that is not referenced by a Rivet file"
                .Assert(() =>
                            {
                                var sourceFiles = new SourceFiles
                                                  	{
                                                  		new SourceFile("main.js", "@rivet includes.push(\"include.js\");"),
                                                  		new SourceFile("include.js", "TEST"),
                                                  		new SourceFile("unreferenced.js", string.Empty)
                                                  	};
                                parser.ParseSourceFiles(sourceFiles, ParserOptions.Default).Count.ShouldEqual(1);
                            });
        }
Esempio n. 33
0
        public void DetectNestedSourceFilesCircularReferencesSpecifications()
        {
            Parser parser = null;
            "Given new Parser".Context(() => parser = new Parser());

            "ParseSourceFiles throws InvalidOperationException when invoked with SourceFiles containing circular nested references"
                .AssertThrows<InvalidOperationException>(() =>
                                                         	{
                                                         		var sourceFiles = new SourceFiles
                                                         		                  	{
                                                         		                  		new SourceFile("rivet-A.js", "@rivet includes.push(\"rivet-B.js\");"),
                                                         		                  		new SourceFile("rivet-B.js", "@rivet includes.push(\"rivet-C.js\");"),
                                                         		                  		new SourceFile("rivet-C.js", "@rivet includes.push(\"rivet-A.js\");"),
                                                         		                  	};

                                                         		parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                                                         	});
        }
Esempio n. 34
0
        private SourceFiles ParseSourceFilesInternal(IEnumerable<SourceFile> sourceFiles, ParserOptions parserOptions)
        {
            IEnumerable<SourceFile> rivetFiles = sourceFiles.Where(IsRivetFile);
            var outputFiles = new SourceFiles();

            foreach (var markedFile in rivetFiles)
            {
                var outputFile = ParseSourceFile(markedFile, sourceFiles, parserOptions);
                outputFiles.Add(outputFile);
            }

            return outputFiles;
        }
Esempio n. 35
0
        public void ParseNestedSourceFilesSpecifications()
        {
            Parser parser = null;
            "Given new Parser".Context(() => parser = new Parser());

            SourceFiles parserOutput = null;
            "when ParseSourceFiles is invoked with SourceFiles containing nested references"
                .Do(() =>
                        {
                            var sourceFiles = new SourceFiles
                                              	{
                                              		new SourceFile("rivet-A.js", "@rivet includes.push(\"A.js\"); includes.push(\"rivet-B.js\");"),
                                              		new SourceFile("A.js", "A"),
                                              		new SourceFile("rivet-B.js", "@rivet includes.push(\"B.js\"); includes.push(\"rivet-C.js\");"),
                                              		new SourceFile("B.js", "B"),
                                              		new SourceFile("rivet-C.js", "@rivet includes.push(\"C1.js\"); includes.push(\"C2.js\");"),
                                              		new SourceFile("C1.js", "@VARIABLE"),
                                              		new SourceFile("C2.js", "C2"),
                                              	};
                            var parserOptions = new ParserOptions();
                            parserOptions.AddVariable(new Variable("VARIABLE", "C1"));

                            parserOutput = parser.ParseSourceFiles(sourceFiles, parserOptions);
                        });

            "output contains 3 SourceFile".Assert(() => parserOutput.Count.ShouldEqual(3));
            "group A nested references are resolved".Assert(() => parserOutput[0].Body.ShouldEqual("ABC1C2"));
            "Rivet file A is made up of 4 components".Assert(() => parserOutput[0].Components.Count.ShouldEqual(4));
            "group B nested references are resolved".Assert(() => parserOutput[1].Body.ShouldEqual("BC1C2"));
            "Rivet file B is made up of 3 components".Assert(() => parserOutput[1].Components.Count.ShouldEqual(3));
            "group C nested references are resolved".Assert(() => parserOutput[2].Body.ShouldEqual("C1C2"));
            "Rivet file C is made up of 2 components".Assert(() => parserOutput[2].Components.Count.ShouldEqual(2));
        }
Esempio n. 36
0
        public void ParseSourceFilesSpecifications()
        {
            Parser parser = null;
            "Given new Parser".Context(() => parser = new Parser());

            SourceFiles parserOutput = null;
            "when ParseSourceFiles is invoked with SourceFiles"
                .Do(() =>
                        {
                            var sourceFiles = new SourceFiles
                                              	{
                                              		new SourceFile("main.js", "@rivet includes.push(\"include.js\"); includes.push(\"dir/include.js\"); includes.push(\"dir/dir/include.js\");"),
                                              		new SourceFile("include.js", "BEFORE\r\nTEST//##DEBUG\r\nAFTER\r\n"),
                                              		new SourceFile("dir\\include.js", "BEFORE\r\n//##DEBUG_STARTTEST\r\n//##DEBUG_ENDAFTER\r\n"),
                                              		new SourceFile("dir\\dir\\include.js", "var i = @VARIABLE_1;var j = @VARIABLE_2;")
                                              	};
                            var parserOptions = new ParserOptions();
                            parserOptions.AddVariable(new Variable("VARIABLE_1", "1"));
                            parserOptions.AddVariable(new Variable("VARIABLE_2", "2"));

                            parserOutput = parser.ParseSourceFiles(sourceFiles, parserOptions);
                        });

            "output contains 1 SourceFile".Assert(() => parserOutput.Count.ShouldEqual(1));
            "Identity of output file is \"main.js\"".Assert(() => parserOutput.First().Identity.ShouldEqual("main.js"));
            "Body of output file is \"BEFORE\r\nAFTER\r\nBEFORE\r\nAFTER\r\nvar i = 1;var j = 2;\"".Assert(() => parserOutput.First().Body.ShouldEqual("BEFORE\r\nAFTER\r\nBEFORE\r\nAFTER\r\nvar i = 1;var j = 2;"));
            "first output file has 3 components".Assert(() => parserOutput.First().Components.Count.ShouldEqual(3));
            "Identity of first component of output file is \"include.js\"".Assert(() => parserOutput.First().Components[0].Identity.ShouldEqual("include.js"));
            "Identity of second component of output file is \"dir\\include.js\"".Assert(() => parserOutput.First().Components[1].Identity.ShouldEqual("dir\\include.js"));
            "Identity of third component of output file is \"dir\\dir\\include.js\"".Assert(() => parserOutput.First().Components[2].Identity.ShouldEqual("dir\\dir\\include.js"));
        }
Esempio n. 37
0
        public void ParseSourceFilesWithCommentsSpecifications()
        {
            Parser parser = null;
            "Given new Parser".Context(() => parser = new Parser());

            SourceFiles parserOutput = null;
            "when ParseSourceFiles is invoked with SourceFiles containing include.push() expression in multiline comment"
                .Do(() =>
                        {
                            var sourceFiles = new SourceFiles
                                              	{
                                              		new SourceFile("main.js", @"@rivet
                                                                            /*
                                                                                example: includes.push(""include.js"");
                                                                            */
                                                                            // example: includes.push(""include.js"");
                                                                            includes.push(""include.js"");"),
                                              		new SourceFile("include.js", "TEST")
                                              	};

                            parserOutput = parser.ParseSourceFiles(sourceFiles, ParserOptions.Default);
                        });

            "Body of output file is \"TEST\"".Assert(() => parserOutput.First().Body.ShouldEqual("TEST"));
        }