-
Notifications
You must be signed in to change notification settings - Fork 0
/
CCompilerTask.cs
44 lines (39 loc) · 1.13 KB
/
CCompilerTask.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
using System;
using System.Collections.Generic;
using bs.Tests;
namespace bs
{
public class CCompilerTask
{
private readonly string _targetFile;
private readonly string _sourceFile;
public CCompilerTask(string targetFile, string sourceFile)
{
_targetFile = targetFile;
_sourceFile = sourceFile;
}
public IEnumerable<string> GetInputFiles()
{
yield return _sourceFile;
foreach (var file in GetFilesIncludedBy(_sourceFile))
yield return file;
}
private static IEnumerable<string> GetFilesIncludedBy(string file)
{
var includeScanner = new IncludeScanner();
foreach(var includedFile in includeScanner.Scan(file))
{
var foundIncludeFile = FindSpecifiedIncludeFileInSearchDirs(includedFile);
if (foundIncludeFile == null)
throw new InvalidOperationException("unable to find the header file: "+includedFile+" in the header search paths.");
yield return foundIncludeFile;
foreach (var file2 in GetFilesIncludedBy(foundIncludeFile))
yield return file2;
}
}
private static string FindSpecifiedIncludeFileInSearchDirs(string includedFile)
{
return includedFile;
}
}
}