-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
55 changed files
with
5,631 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# ------------------------------------------------------------------------------ | ||
# <auto-generated> | ||
# | ||
# This code was generated. | ||
# | ||
# - To turn off auto-generation set: | ||
# | ||
# [GitHubActions (AutoGenerate = false)] | ||
# | ||
# - To trigger manual generation invoke: | ||
# | ||
# nuke --generate-configuration GitHubActions_ci --host GitHubActions | ||
# | ||
# </auto-generated> | ||
# ------------------------------------------------------------------------------ | ||
|
||
name: ci | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
- dev | ||
- 'release/**' | ||
pull_request: | ||
branches: | ||
- 'release/**' | ||
|
||
jobs: | ||
ubuntu-latest: | ||
name: ubuntu-latest | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 'Cache: .nuke/temp, ~/.nuget/packages' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
.nuke/temp | ||
~/.nuget/packages | ||
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} | ||
- name: 'Run: Compile, Test' | ||
run: ./build.cmd Compile Test | ||
macos-latest: | ||
name: macos-latest | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 'Cache: .nuke/temp, ~/.nuget/packages' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
.nuke/temp | ||
~/.nuget/packages | ||
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} | ||
- name: 'Run: Compile, Test' | ||
run: ./build.cmd Compile Test | ||
windows-latest: | ||
name: windows-latest | ||
runs-on: windows-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
fetch-depth: 0 | ||
- name: 'Cache: .nuke/temp, ~/.nuget/packages' | ||
uses: actions/cache@v3 | ||
with: | ||
path: | | ||
.nuke/temp | ||
~/.nuget/packages | ||
key: ${{ runner.os }}-${{ hashFiles('**/global.json', '**/*.csproj', '**/Directory.Packages.props') }} | ||
- name: 'Run: Compile, Test' | ||
run: ./build.cmd Compile Test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2023 Rikarin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
using Rin.Core.Storage; | ||
using Serilog; | ||
|
||
namespace Rin.BuildEngine.Common; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
using Rin.Core.TODO; | ||
|
||
namespace Rin.BuildEngine.Common; | ||
|
||
/// <summary> | ||
/// A static class that allows to have a different <see cref="ObjectDatabase" /> on each <see cref="MicroThread" />. | ||
/// Objects can still be shared | ||
/// between micro-threads by using the <see cref="AddToSharedGroup" /> method. | ||
/// </summary> | ||
public static class MicroThreadLocalDatabases { | ||
static readonly Dictionary<ObjectUrl, OutputObject> SharedOutputObjects = new(); | ||
static readonly MicroThreadLocal<DatabaseFileProvider> MicroThreadLocalDatabaseFileProvider; | ||
|
||
public static IDatabaseFileProviderService ProviderService { get; } | ||
|
||
/// <summary> | ||
/// Gets a value indicating whether this instance has a valid database file provider. | ||
/// </summary> | ||
/// <value><c>true</c> if this instance has database file provider; otherwise, <c>false</c>.</value> | ||
public static bool HasValidDatabaseFileProvider => MicroThreadLocalDatabaseFileProvider.Value != null; | ||
|
||
/// <summary> | ||
/// Gets the currently mounted microthread-local database provider. | ||
/// </summary> | ||
public static DatabaseFileProvider DatabaseFileProvider => MicroThreadLocalDatabaseFileProvider.Value; | ||
|
||
static MicroThreadLocalDatabases() { | ||
MicroThreadLocalDatabaseFileProvider = new MicroThreadLocal<DatabaseFileProvider>(); | ||
|
||
ProviderService = new MicroThreadLocalProviderService(); | ||
} | ||
|
||
/// <summary> | ||
/// Merges the given dictionary of build output objects into the shared group. Objects merged here will be integrated | ||
/// to every database. | ||
/// </summary> | ||
/// <param name="outputObjects">The dictionary containing the <see cref="OutputObject" /> to merge into the shared group.</param> | ||
public static void AddToSharedGroup(IReadOnlyDictionary<ObjectUrl, OutputObject> outputObjects) { | ||
lock (SharedOutputObjects) { | ||
foreach (var outputObject in outputObjects) { | ||
SharedOutputObjects[outputObject.Key] = outputObject.Value; | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Gets a <see cref="MicroThreadLocalDatabaseFileProvider" /> containing only objects from the shared group. | ||
/// The shared group is a group of objects registered via <see cref="AddToSharedGroup" /> and shared amongst all | ||
/// databases. | ||
/// </summary> | ||
/// <returns>A <see cref="MicroThreadLocalDatabaseFileProvider" /> that can provide objects from the common group.</returns> | ||
public static DatabaseFileProvider GetSharedDatabase() => CreateDatabase(CreateTransaction(null)); | ||
|
||
/// <summary> | ||
/// Creates and mounts a database containing the given output object groups and the shared group in the | ||
/// microthread-local | ||
/// <see cref="MicroThreadLocalDatabaseFileProvider" />. | ||
/// </summary> | ||
/// <param name="outputObjectsGroups">A collection of dictionaries representing a group of output object.</param> | ||
public static void MountDatabase(IEnumerable<IReadOnlyDictionary<ObjectUrl, OutputObject>> outputObjectsGroups) { | ||
MountDatabase(CreateTransaction(outputObjectsGroups)); | ||
} | ||
|
||
/// <summary> | ||
/// Creates and mounts a database containing output objects from the shared group in the microthread-local | ||
/// <see cref="MicroThreadLocalDatabaseFileProvider" />. | ||
/// </summary> | ||
public static void MountCommonDatabase() { | ||
MicroThreadLocalDatabaseFileProvider.Value = CreateDatabase(CreateTransaction(null)); | ||
} | ||
|
||
/// <summary> | ||
/// Unmounts the currently mounted microthread-local database. | ||
/// </summary> | ||
public static void UnmountDatabase() { | ||
MicroThreadLocalDatabaseFileProvider.ClearValue(); | ||
} | ||
|
||
public static IEnumerable<IReadOnlyDictionary<ObjectUrl, OutputObject>> GetOutputObjectsGroups( | ||
IEnumerable<IReadOnlyDictionary<ObjectUrl, OutputObject>> transactionOutputObjectsGroups | ||
) { | ||
if (transactionOutputObjectsGroups != null) { | ||
foreach (var outputObjects in transactionOutputObjectsGroups) { | ||
yield return outputObjects; | ||
} | ||
} | ||
|
||
yield return SharedOutputObjects; | ||
} | ||
|
||
static DatabaseFileProvider CreateDatabase(BuildTransaction transaction) => | ||
new DatabaseFileProvider(new BuildTransaction.DatabaseContentIndexMap(transaction), Builder.ObjectDatabase); | ||
|
||
internal static void MountDatabase(BuildTransaction transaction) { | ||
MicroThreadLocalDatabaseFileProvider.Value = CreateDatabase(transaction); | ||
} | ||
|
||
internal static BuildTransaction CreateTransaction( | ||
IEnumerable<IReadOnlyDictionary<ObjectUrl, OutputObject>> transactionOutputObjectsGroups | ||
) => | ||
new BuildTransaction( | ||
Builder.ObjectDatabase.ContentIndexMap, | ||
GetOutputObjectsGroups(transactionOutputObjectsGroups) | ||
); | ||
|
||
class MicroThreadLocalProviderService : IDatabaseFileProviderService { | ||
public DatabaseFileProvider FileProvider => MicroThreadLocalDatabaseFileProvider.Value; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.