Skip to content

Commit

Permalink
Cleanup logging with node titles
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Asplund committed Dec 28, 2019
1 parent 0706833 commit e0dfdb0
Show file tree
Hide file tree
Showing 13 changed files with 153 additions and 60 deletions.
2 changes: 1 addition & 1 deletion Dependencies/SoupTest
10 changes: 10 additions & 0 deletions Source/Build/Extension/BuildGraphNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ namespace Soup::Build

public:
BuildGraphNode(
std::string title,
Path program,
std::string arguments,
Path workingDirectory,
std::vector<Path> inputFiles,
std::vector<Path> outputFiles) :
_id(UniqueId++),
_title(std::move(title)),
_program(std::move(program)),
_arguments(std::move(arguments)),
_workingDirectory(std::move(workingDirectory)),
Expand All @@ -32,13 +34,15 @@ namespace Soup::Build
}

BuildGraphNode(
std::string title,
Path program,
std::string arguments,
Path workingDirectory,
std::vector<Path> inputFiles,
std::vector<Path> outputFiles,
std::vector<std::shared_ptr<BuildGraphNode>> children) :
_id(UniqueId++),
_title(std::move(title)),
_program(std::move(program)),
_arguments(std::move(arguments)),
_workingDirectory(std::move(workingDirectory)),
Expand Down Expand Up @@ -111,6 +115,11 @@ namespace Soup::Build
return _id;
}

const std::string& GetTitle() const
{
return _title;
}

const Path& GetProgram() const
{
return _program;
Expand Down Expand Up @@ -143,6 +152,7 @@ namespace Soup::Build

private:
int _id;
std::string _title;
Path _program;
std::string _arguments;
Path _workingDirectory;
Expand Down
5 changes: 5 additions & 0 deletions Source/Compiler/Clang.UnitTests/CompilerTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace Soup::Compiler::Clang::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"File.cpp",
Path("C:/Clang/bin/clang++.exe"),
"-nostdinc -Wno-unknown-attributes -Xclang -flto-visibility-public-std -std=c++11 -c File.cpp -o obj/File.o",
Path("Source"),
Expand Down Expand Up @@ -71,6 +72,7 @@ namespace Soup::Compiler::Clang::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"File.cpp",
Path("C:/Clang/bin/clang++.exe"),
"-nostdinc -Wno-unknown-attributes -Xclang -flto-visibility-public-std -std=c++11 -I\"Includes\" -DDEBUG -fmodule-file=\"Module.pcm\" --precompile File.cpp -o obj/File.pcm",
Path("Source"),
Expand All @@ -83,6 +85,7 @@ namespace Soup::Compiler::Clang::UnitTests
}),
std::vector<std::shared_ptr<Build::BuildGraphNode>>({
std::make_shared<Build::BuildGraphNode>(
"obj/File.pcm",
Path("C:/Clang/bin/clang++.exe"),
"-nostdinc -Wno-unknown-attributes -Xclang -flto-visibility-public-std -std=c++11 -c obj/File.pcm -o obj/File.obj",
Path("Source"),
Expand Down Expand Up @@ -114,6 +117,7 @@ namespace Soup::Compiler::Clang::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"Library.mock.a",
Path("C:/Clang/bin/llvm-ar.exe"),
"rc Library.mock.a File.mock.o",
Path("Source"),
Expand Down Expand Up @@ -147,6 +151,7 @@ namespace Soup::Compiler::Clang::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"Something.exe",
Path("C:/Clang/bin/lld-link.exe"),
"/nologo /subsystem:console /machine:X64 /out:\"Something.exe\" Library.mock.a File.mock.o",
Path("Source"),
Expand Down
4 changes: 4 additions & 0 deletions Source/Compiler/Clang/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ namespace Soup::Compiler::Clang
auto commandArgs = ArgumentBuilder::BuildLinkerArguments(args, inputFiles, outputFiles);

auto buildNode = std::make_shared<Build::BuildGraphNode>(
args.TargetFile.ToString(),
std::move(executablePath),
CombineArguments(commandArgs),
args.RootDirectory,
Expand All @@ -128,6 +129,7 @@ namespace Soup::Compiler::Clang
auto commandArgs = ArgumentBuilder::BuildCompilerArguments(args, inputFiles, outputFiles);

auto buildNode = std::make_shared<Build::BuildGraphNode>(
args.SourceFile.ToString(),
std::move(executablePath),
CombineArguments(commandArgs),
args.RootDirectory,
Expand Down Expand Up @@ -168,6 +170,7 @@ namespace Soup::Compiler::Clang
generatePrecompiledModuleOutputFiles);

auto precompiledModuleBuildNode = std::make_shared<Build::BuildGraphNode>(
generatePrecompiledModuleArgs.SourceFile.ToString(),
executablePath,
CombineArguments(generatePrecompiledModuleCommandArgs),
args.RootDirectory,
Expand All @@ -192,6 +195,7 @@ namespace Soup::Compiler::Clang
compileObjectOutputFiles);

auto compileBuildNode = std::make_shared<Build::BuildGraphNode>(
compileObjectArgs.SourceFile.ToString(),
std::move(executablePath),
CombineArguments(compileObjectCommandArgs),
args.RootDirectory,
Expand Down
4 changes: 4 additions & 0 deletions Source/Compiler/MSVC.UnitTests/CompilerTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace Soup::Compiler::MSVC::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"File.cpp",
Path("./bin/mock.cl.exe"),
"/nologo /std:c++11 /Od /X /RTC1 /EHsc /MTd /bigobj /c File.cpp /Fo\"obj/File.obj\"",
Path("Source"),
Expand Down Expand Up @@ -83,6 +84,7 @@ namespace Soup::Compiler::MSVC::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"File.cpp",
Path("./bin/mock.cl.exe"),
"/nologo /std:c++11 /Od /I\"Includes\" /DDEBUG /X /RTC1 /EHsc /MTd /module:reference \"Module.pcm\" /module:export /module:output \"obj/File.ifc\" /bigobj /c File.cpp /Fo\"obj/File.obj\"",
Path("Source"),
Expand Down Expand Up @@ -119,6 +121,7 @@ namespace Soup::Compiler::MSVC::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"Library.mock.a",
Path("./bin/mock.lib.exe"),
"/nologo /machine:X64 /out:\"Library.mock.a\" File.mock.obj",
Path("Source"),
Expand Down Expand Up @@ -156,6 +159,7 @@ namespace Soup::Compiler::MSVC::UnitTests

// Verify result
auto expected = std::make_shared<Build::BuildGraphNode>(
"Something.exe",
Path("./bin/mock.link.exe"),
"/nologo /subsystem:console /machine:X64 /out:\"Something.exe\" Library.mock.a File.mock.obj",
Path("Source"),
Expand Down
3 changes: 3 additions & 0 deletions Source/Compiler/MSVC/Compiler.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ namespace Soup::Compiler::MSVC
auto commandArgs = ArgumentBuilder::BuildLinkerArguments(args, inputFiles, outputFiles);

auto buildNode = std::make_shared<Build::BuildGraphNode>(
args.TargetFile.ToString(),
std::move(executablePath),
CombineArguments(commandArgs),
args.RootDirectory,
Expand All @@ -127,6 +128,7 @@ namespace Soup::Compiler::MSVC
ArgumentBuilder::BuildCompilerArguments(args, _toolsPath, inputFiles, outputFiles);

auto buildNode = std::make_shared<Build::BuildGraphNode>(
args.SourceFile.ToString(),
std::move(executablePath),
CombineArguments(commandArgs),
args.RootDirectory,
Expand Down Expand Up @@ -166,6 +168,7 @@ namespace Soup::Compiler::MSVC
outputFiles);

auto buildNode = std::make_shared<Build::BuildGraphNode>(
args.SourceFile.ToString(),
std::move(executablePath),
CombineArguments(compiledModuleCommandArgs),
args.RootDirectory,
Expand Down
45 changes: 32 additions & 13 deletions Source/Core.UnitTests/Build/Runner/BuildRunnerTests.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ namespace Soup::Build::UnitTests
std::vector<std::string>({
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down Expand Up @@ -93,6 +94,7 @@ namespace Soup::Build::UnitTests
"INFO: No previous state found, full rebuild required",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down Expand Up @@ -135,8 +137,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.in"),
Expand All @@ -151,9 +154,11 @@ namespace Soup::Build::UnitTests
// Verify expected logs
Assert::AreEqual(
std::vector<std::string>({
"DIAG: Execute: Command.exe 1",
"HIGH: TestCommand: 1",
"DIAG: Execute: Command.exe Arguments",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand All @@ -171,7 +176,7 @@ namespace Soup::Build::UnitTests
// Verify expected process requests
Assert::AreEqual(
std::vector<std::string>({
"Execute: C:/TestWorkingDirectory/: Command.exe 1",
"Execute: C:/TestWorkingDirectory/: Command.exe Arguments",
}),
processManager->GetRequests(),
"Verify process manager requests match expected.");
Expand All @@ -197,8 +202,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.in"),
Expand All @@ -216,9 +222,11 @@ namespace Soup::Build::UnitTests
"DIAG: Loading previous build state",
"INFO: BuildHistory file does not exist",
"INFO: No previous state found, full rebuild required",
"DIAG: Execute: Command.exe 1",
"HIGH: TestCommand: 1",
"DIAG: Execute: Command.exe Arguments",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand All @@ -237,7 +245,7 @@ namespace Soup::Build::UnitTests
// Verify expected process requests
Assert::AreEqual(
std::vector<std::string>({
"Execute: C:/TestWorkingDirectory/: Command.exe 1",
"Execute: C:/TestWorkingDirectory/: Command.exe Arguments",
}),
processManager->GetRequests(),
"Verify process manager requests match expected.");
Expand Down Expand Up @@ -271,8 +279,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.cpp"),
Expand All @@ -290,9 +299,11 @@ namespace Soup::Build::UnitTests
"DIAG: Loading previous build state",
"INFO: Check for updated source",
"INFO: Missing file info: InputFile.cpp",
"DIAG: Execute: Command.exe 1",
"HIGH: TestCommand: 1",
"DIAG: Execute: Command.exe Arguments",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down Expand Up @@ -344,8 +355,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.in"),
Expand All @@ -363,9 +375,11 @@ namespace Soup::Build::UnitTests
"DIAG: Loading previous build state",
"INFO: Check for updated source",
"INFO: Output target does not exist: C:/TestWorkingDirectory/OutputFile.out",
"DIAG: Execute: Command.exe 1",
"HIGH: TestCommand: 1",
"DIAG: Execute: Command.exe Arguments",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down Expand Up @@ -421,8 +435,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.in"),
Expand All @@ -442,9 +457,11 @@ namespace Soup::Build::UnitTests
"DIAG: IsOutdated: C:/TestWorkingDirectory/OutputFile.out [1434993000]",
"DIAG: C:/TestWorkingDirectory/InputFile.in [1434993060]",
"INFO: Input altered after target [C:/TestWorkingDirectory/InputFile.in] -> [C:/TestWorkingDirectory/OutputFile.out]",
"DIAG: Execute: Command.exe 1",
"HIGH: TestCommand: 1",
"DIAG: Execute: Command.exe Arguments",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down Expand Up @@ -503,8 +520,9 @@ namespace Soup::Build::UnitTests
// Setup the input build state
auto nodes = std::vector<std::shared_ptr<BuildGraphNode>>({
std::make_shared<BuildGraphNode>(
"TestCommand: 1",
Path("Command.exe"),
"1",
"Arguments",
Path("C:/TestWorkingDirectory/"),
std::vector<Path>({
Path("InputFile.in"),
Expand All @@ -527,6 +545,7 @@ namespace Soup::Build::UnitTests
"INFO: Up to date",
"INFO: Saving updated build state",
"INFO: Create Directory: .soup",
"HIGH: Done",
}),
testListener->GetMessages(),
"Verify log messages match expected.");
Expand Down
Loading

0 comments on commit e0dfdb0

Please sign in to comment.