-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy pathCmakeGenerator.cs
78 lines (67 loc) · 2.2 KB
/
CmakeGenerator.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// =====================================================================
// <copyright file="CMakeGenerator.cs" company="Advanced Micro Devices, Inc.">
// Copyright (c) 2019-2020 Advanced Micro Devices, Inc. All rights reserved.
// </copyright>
// <author>
// AMD Developer Tools Team
// </author>
// <summary>
// Generates the CMake file for the listed directories
// </summary>
// =====================================================================
using System;
using System.Collections.Generic;
using System.IO;
namespace GpaTools
{
class CMakeGenerator
{
public delegate void ProcessFilesDelegate(string fileName);
public delegate void InitDelegate();
public delegate void CMakeWriterDelegate();
public static ProcessFilesDelegate ProcessFile = null;
public static InitDelegate Init = null;
public static CMakeWriterDelegate CMakeWriter = null;
private static readonly List<string> _dirList = new List<string>();
/// <summary>
/// Adds the directory
/// </summary>
/// <param name="dir">directory name</param>
public static void AddDirectory(string dir)
{
_dirList.Add(dir);
}
/// <summary>
/// Generates the CMake file
/// </summary>
public static void GenerateCMakeFiles()
{
Init?.Invoke();
foreach (var dir in _dirList)
{
ProcessDir(dir);
}
CMakeWriter?.Invoke();
}
/// <summary>
/// Process the directory
/// </summary>
/// <param name="directory">directory name</param>
private static void ProcessDir(string directory)
{
string[] files = Directory.GetFiles(directory);
foreach (var file in files)
{
if (file.Contains(".txt") || file.Contains(".h") || file.Contains(".cc"))
{
ProcessFile?.Invoke(file);
}
}
string[] subDir = Directory.GetDirectories(directory);
foreach (var dir in subDir)
{
ProcessDir(dir);
}
}
}
}