Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Masplund/filesystem #253

Merged
merged 5 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Scripts/Linux/release
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ OUT_DIR=$ROOT_DIR/out
RUN_DIR=$OUT_DIR/run

# Cleanup previous runs
tar -a -cf $OUT_DIR/soup-build-0.38.1-linux-x64.tar.gz -C $RUN_DIR .
tar -a -cf $OUT_DIR/soup-build-0.39.0-linux-x64.tar.gz -C $RUN_DIR .
2 changes: 1 addition & 1 deletion Scripts/Linux/soup
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CONFIG_HASH=Oltq7cGwk0Rbgy1I-3mCMDDE5yM

OWNER=mwasplund

SOUP_VERSION="0.38.1"
SOUP_VERSION="0.39.0"
COPY_VERSION="1.1.0"
MKDIR_VERSION="1.1.0"
SOUP_WREN_VERSION="0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Linux/soupd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ CONFIG_HASH=OZlIVjblazFuKXg-raWUNoGEnG4

OWNER=mwasplund

SOUP_VERSION="0.38.1"
SOUP_VERSION="0.39.0"
COPY_VERSION="1.1.0"
MKDIR_VERSION="1.1.0"
SOUP_WREN_VERSION="0.4.1"
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Windows/SignInstaller.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ SET OutDir=%RootDir%\out

SET SIGN_COMMAND=signtool sign /n "Open Source Developer, Matthew Asplund" /t http://time.certum.pl /fd sha1 /v

SET SignFiles=%OutDir%\soup-build-0.38.1-windows-x64.msi
SET SignFiles=%OutDir%\soup-build-0.39.0-windows-x64.msi

%SIGN_COMMAND% %SignFiles%
2 changes: 1 addition & 1 deletion Scripts/Windows/install.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ SET RootDir=%ScriptsDir%..\..
SET OutDir=%RootDir%\out

pushd %OutDir%
start msiexec /package soup-build-0.38.1-windows-x64.msi /passive
start msiexec /package soup-build-0.39.0-windows-x64.msi /passive
popd
2 changes: 1 addition & 1 deletion Scripts/Windows/release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ SET RunDir=%OutDir%\run
SET SourceDir=%RootDir%\Source
SET InstallerDir=%SourceDir%\Installer\SoupInstaller

SET SOUP_VERSION=0.38.1
SET SOUP_VERSION=0.39.0

REM - Build MSI Installer
echo msbuild %InstallerDir% -p:Configuration=Release
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Windows/soup-release.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SET ConfigHash=Oltq7cGwk0Rbgy1I-3mCMDDE5yM

SET PKG_OWNER=mwasplund

SET SOUP_VERSION=0.38.1
SET SOUP_VERSION=0.39.0
SET COPY_VERSION=1.1.0
SET MKDIR_VERSION=1.1.0
SET SOUP_WREN_VERSION=0.4.1
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Windows/soup.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SET ConfigHash=Oltq7cGwk0Rbgy1I-3mCMDDE5yM

SET PKG_OWNER=mwasplund

SET SOUP_VERSION=0.38.1
SET SOUP_VERSION=0.39.0
SET COPY_VERSION=1.1.0
SET MKDIR_VERSION=1.1.0
SET SOUP_WREN_VERSION=0.4.1
Expand Down
2 changes: 1 addition & 1 deletion Scripts/Windows/soupd.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SET ConfigHash=OZlIVjblazFuKXg-raWUNoGEnG4

SET PKG_OWNER=mwasplund

SET SOUP_VERSION=0.38.1
SET SOUP_VERSION=0.39.0
SET COPY_VERSION=1.1.0
SET MKDIR_VERSION=1.1.0
SET SOUP_WREN_VERSION=0.4.1
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/CLI/Recipe.sml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: 'Soup'
Version: '0.38.1'
Version: '0.39.0'
Language: 'C++|0'

Type: 'Executable'
Expand Down
2 changes: 1 addition & 1 deletion Source/Client/CLI/Source/Commands/VersionCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Soup::Client

// TODO var version = Assembly.GetExecutingAssembly().GetName().Version;
// Log::Message($"{version.Major}.{version.Minor}.{version.Build}");
Log::HighPriority("0.38.1");
Log::HighPriority("0.39.0");
}

private:
Expand Down
51 changes: 39 additions & 12 deletions Source/Client/Core/Source/Build/BuildEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ namespace Soup::Core
}

/// <summary>
/// The Core Execute task
/// Load the build graph
/// </summary>
static PackageProvider LoadBuildGraph(
const Path& builtInDirectory,
Expand All @@ -93,7 +93,7 @@ namespace Soup::Core
auto endTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(endTime - startTime);

// std::cout << "LoadSystemState: " << std::to_string(duration.count()) << " seconds." << std::endl;
std::cout << "LoadSystemState: " << std::to_string(duration.count()) << " seconds." << std::endl;

startTime = std::chrono::high_resolution_clock::now();

Expand All @@ -113,11 +113,38 @@ namespace Soup::Core
endTime = std::chrono::high_resolution_clock::now();
duration = std::chrono::duration_cast<std::chrono::duration<double>>(endTime - startTime);

// std::cout << "BuildLoadEngine: " << std::to_string(duration.count()) << " seconds." << std::endl;
std::cout << "BuildLoadEngine: " << std::to_string(duration.count()) << " seconds." << std::endl;

return packageProvider;
}

/// <summary>
/// Preload the file system
/// </summary>
static FileSystemState PreloadFileSystemState(
PackageProvider& packageProvider)
{
auto startTime = std::chrono::high_resolution_clock::now();

// Initialize a shared File System State to cache file system access
auto fileSystemState = FileSystemState();

for (auto package : packageProvider.GetPackageLookup())
{
fileSystemState.PreloadDirectory(package.second.PackageRoot, true);
// TODO: fileSystemState.PreloadDirectory(package.second.TargetDirectory, false);
}

auto endTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(endTime - startTime);

std::cout << "PreloadFileSystemState: " << std::to_string(duration.count()) << " seconds." << std::endl;

startTime = std::chrono::high_resolution_clock::now();

return fileSystemState;
}

static void Execute(
PackageProvider& packageProvider,
const RecipeBuildArguments& arguments,
Expand All @@ -126,21 +153,21 @@ namespace Soup::Core
{
auto startTime = std::chrono::high_resolution_clock::now();

// Initialize a shared File System State to cache file system access
auto fileSystemState = FileSystemState();

// Initialize a shared Evaluate Engine
auto evaluateEngine = BuildEvaluateEngine(
arguments.ForceRebuild,
fileSystemState);

// Initialize shared location manager
auto knownLanguages = GetKnownLanguages();
auto locationManager = RecipeBuildLocationManager(knownLanguages);

// Load the system specific state
auto systemReadAccess = LoadHostSystemAccess();

// Load the file system state
auto fileSystemState = PreloadFileSystemState(packageProvider);

// Initialize a shared Evaluate Engine
auto evaluateEngine = BuildEvaluateEngine(
arguments.ForceRebuild,
fileSystemState);

// Initialize the build runner that will perform the generate and evaluate phase
// for each individual package
auto buildRunner = BuildRunner(
Expand All @@ -157,7 +184,7 @@ namespace Soup::Core
auto endTime = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::duration<double>>(endTime - startTime);

// std::cout << "BuildRunner: " << std::to_string(duration.count()) << " seconds." << std::endl;
std::cout << "BuildRunner: " << std::to_string(duration.count()) << " seconds." << std::endl;
}

static Path GetSoupUserDataPath()
Expand Down
41 changes: 41 additions & 0 deletions Source/Client/Core/Source/Build/BuildRunner.h
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,10 @@ namespace Soup::Core
macroTargetDirectory,
realTargetDirectory);

// Preload target
// TODO: Ideally this should be done in the preload step, but easier here with the graph id
_fileSystemState.PreloadDirectory(realTargetDirectory, false);

//////////////////////////////////////////////
// SETUP
/////////////////////////////////////////////
Expand Down Expand Up @@ -363,6 +367,10 @@ namespace Soup::Core
// Generate the dependencies input state
globalState.emplace("Dependencies", GenerateParametersDependenciesValueTable(packageInfo));

// Pass along the file system state
auto fileSystemRoot = BuildDirectoryStructure(packageInfo.PackageRoot);
globalState.emplace("FileSystem", std::move(fileSystemRoot));

inputTable.emplace("GlobalState", std::move(globalState));

// Build up the input state for the generate call
Expand Down Expand Up @@ -826,5 +834,38 @@ namespace Soup::Core

return targetSet;
}

ValueList BuildDirectoryStructure(const Path& directory)
{
auto directoryState = _fileSystemState.GetDirectoryState(directory);

auto result = ValueList();
BuildDirectoryStructure(directoryState, result);

return result;
}

void BuildDirectoryStructure(DirectoryState& activeDirectory, ValueList& result)
{
for (auto& file : activeDirectory.Files)
{
result.push_back(file);
}

if (!activeDirectory.ChildDirectories.empty())
{
auto childDirectories = ValueTable();
for (auto& childDirectory : activeDirectory.ChildDirectories)
{
auto childDirectoryStructure = ValueList();
BuildDirectoryStructure(childDirectory.second, childDirectoryStructure);
childDirectories.emplace(
childDirectory.first,
std::move(childDirectoryStructure));
}

result.push_back(std::move(childDirectories));
}
}
};
}
Loading
Loading