This commit is contained in:
watrabi
2025-09-18 17:55:52 -04:00
commit 977f1ff4b8
15030 changed files with 17324420 additions and 0 deletions
+73
View File
@@ -0,0 +1,73 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>9.0.30729</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{0A8CF97A-079B-45B4-A68A-296B02859A59}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>IncludeChecker</RootNamespace>
<AssemblyName>IncludeChecker</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'ReleaseStudio|AnyCPU' ">
<OutputPath>bin\ReleaseStudio\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<CodeAnalysisUseTypeNameInSuppression>true</CodeAnalysisUseTypeNameInSuppression>
<CodeAnalysisModuleSuppressionsFile>GlobalSuppressions.cs</CodeAnalysisModuleSuppressionsFile>
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data.DataSetExtensions">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
+235
View File
@@ -0,0 +1,235 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Text.RegularExpressions;
namespace IncludeChecker
{
class Node
{
public string Name { get; set; }
private Node(string name)
{
Name = name.ToLower();
allNodes[Name] = this;
}
public static Node Get(string name)
{
name = name.ToLower();
return allNodes.ContainsKey(name) ? allNodes[name] : new Node(name);
}
public void AddInclude(string name)
{
name = name.ToLower();
includes.Add(Get(name));
}
public bool MayInclude(string name)
{
return MayInclude(name, new HashSet<Node>());
}
bool MayInclude(string name, HashSet<Node> visited)
{
if (visited.Contains(this))
return false;
visited.Add(this);
name = name.ToLower();
if (!allNodes.ContainsKey(name))
return false;
if (includes.Contains(allNodes[name]))
return true;
foreach (var node in includes)
if (node.MayInclude(name, visited))
return true;
return false;
}
static Dictionary<string, Node> allNodes = new Dictionary<string, Node>();
HashSet<Node> includes = new HashSet<Node>();
}
class Program
{
static int errorCount = 0;
static int checkCount = 0;
static void DefineIncludes()
{
Node.Get("V8DataModel").AddInclude("V8World");
Node.Get("V8DataModel").AddInclude("V8Tree");
Node.Get("V8DataModel").AddInclude("Network");
Node.Get("V8DataModel").AddInclude("gui");
Node.Get("V8DataModel").AddInclude("util");
Node.Get("V8DataModel").AddInclude("Tool");
Node.Get("V8DataModel").AddInclude("Humanoid");
Node.Get("V8DataModel").AddInclude("Script");
Node.Get("Darwin").AddInclude("V8DataModel");
Node.Get("src").AddInclude("script");
Node.Get("Humanoid").AddInclude("V8DataModel");
Node.Get("Lua").AddInclude("V8DataModel");
Node.Get("Script").AddInclude("LUa");
Node.Get("V8Tree").AddInclude("Reflection");
Node.Get("V8Tree").AddInclude("RBX/Intrusive");
Node.Get("Reflection").AddInclude("Security");
Node.Get("Reflection").AddInclude("util");
Node.Get("Reflection").AddInclude("v8xml");
Node.Get("Darwin").AddInclude("rbx");
Node.Get("Darwin").AddInclude("util");
Node.Get("Security").AddInclude("rbx");
Node.Get("Tool").AddInclude("V8DataModel");
Node.Get("V8Kernel").AddInclude("util");
Node.Get("V8World").AddInclude("V8Kernel");
Node.Get("V8World").AddInclude("rbx");
Node.Get("V8Xml").AddInclude("Util");
Node.Get("V8Xml").AddInclude("Reflection");
Node.Get("util").AddInclude("rbx");
Node.Get("util").AddInclude("rbxg3d");
Node.Get("gui").AddInclude("Util");
Node.Get("gui").AddInclude("AppDraw");
Node.Get("gui").AddInclude("GfxBase");
Node.Get("gui").AddInclude("V8DataModel");
}
static void Main(string[] args)
{
DefineIncludes();
Console.WriteLine("Go!");
DirectoryInfo app = new DirectoryInfo(Directory.GetCurrentDirectory());
//Check(app.Parent.Parent.Parent.GetDirectories("Base")[0]);
Check(app.Parent.Parent.Parent.GetDirectories("App")[0]);
Console.WriteLine(errorCount + " errors out of " + checkCount);
}
private static void Check(DirectoryInfo dir)
{
foreach (var file in dir.GetFiles())
Check(file);
foreach (var d in dir.GetDirectories())
Check(d);
}
private static void Check(FileInfo file)
{
if (!IsCFile(file))
return;
var paths = GetIncludePaths(file);
foreach (var path in paths)
Check(file, path);
}
private static void Check(FileInfo file, string includePath)
{
checkCount++;
// Implement simple rules
if (includePath == "")
return;
if (includePath.ToLower() == "g3d")
return;
if (includePath.ToLower() == "corefoundation")
return;
if (includePath.StartsWith("boost"))
return;
if (includePath.StartsWith("mach-o"))
return;
if (includePath.StartsWith("readline"))
return;
if (includePath.Contains("fmod"))
return;
if (includePath.StartsWith("ext"))
return;
if (includePath.StartsWith("openssl"))
return;
if (includePath.ToLower() == "rbx/darwin")
return;
if (includePath.StartsWith("sys"))
return;
if (includePath.StartsWith("tbb"))
return;
string dir = file.Directory.Name;
if (dir.ToLower() == includePath.ToLower())
return;
Node node = Node.Get(file.Directory.Name);
if (!node.MayInclude(includePath))
{
Console.WriteLine(file.Directory.Name + "/" + file.Name + " " + includePath);
errorCount++;
}
}
private static HashSet<string> GetIncludePaths(FileInfo file)
{
var paths = new HashSet<string>();
using (StreamReader reader = new StreamReader(file.FullName))
{
while (!reader.EndOfStream)
{
string line = reader.ReadLine().ToLower();
TryMatch(paths, Regex.Match(line, @"#include ""(.+)"""));
TryMatch(paths, Regex.Match(line, @"#include <(.+)>"));
}
}
return paths;
}
private static void TryMatch(HashSet<string> paths, Match match)
{
if (match.Groups.Count == 2)
{
string path = match.Groups[1].Value;
if (path.StartsWith("./"))
path = path.Substring(2);
int index = path.LastIndexOf('/');
if (index > 0)
paths.Add(path.Substring(0, index));
else
paths.Add("");
}
}
private static bool IsCFile(FileInfo file)
{
if (file.Extension == ".cpp")
return true;
if (file.Extension == ".c")
return true;
if (file.Extension == ".h")
return true;
if (file.Extension == ".hpp")
return true;
if (file.Extension == ".inl")
return true;
if (file.Extension == ".cxx")
return true;
return false;
}
}
}
+36
View File
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("IncludeChecker")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("IncludeChecker")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("249b221f-bbd8-449c-a3a8-4c3aad05712b")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]