Skip to content

Commit 545b35d

Browse files
authored
Merge pull request #953 from swiftlang/t/actioncache
[llbuild3] Cleanup and Implement action cache support
2 parents da9efe6 + 9fdf05c commit 545b35d

File tree

2,563 files changed

+12447
-830736
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

2,563 files changed

+12447
-830736
lines changed

LICENSE.txt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,11 @@ licenses, and/or restrictions:
222222

223223
Program Directory
224224
------- ---------
225-
Google Test llbuild/utils/unittest/googletest
226-
LLVM llbuild/lib/llvm, llbuild/include/llvm
225+
BLAKE3 thirdparty/BLAKE3
227226
CMake cmake/modules/FindSQLite3.cmake
227+
LLVM llbuild/lib/llvm, llbuild/include/llvm
228+
Google Protobuf thirdparty/protobuf
229+
Google Test llbuild/utils/unittest/googletest
230+
Swift Protobuf thridparty/swift-protobuf
231+
result.hpp products/llbuild3/Result.hpp
232+

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Helper makefile for generating Tritium protobuf files
1+
# Helper makefile for generating llbuild3 protobuf files
22

33
.PHONY: generate
44
generate: generate-protos
@@ -15,7 +15,7 @@ generate-protos: proto-toolchain
1515
--swift_out=src \
1616
--swift_opt=Visibility=Public \
1717
--swift_opt=ProtoPathModuleMappings=src/module_map.asciipb \
18-
$$(find src -name \*.proto)
18+
$$(find src -name \*.proto -not -name \*Internal\*)
1919

2020
.PHONY: proto-toolchain
2121
proto-toolchain:

README.tritium.md renamed to README.llbuild3.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Tritium — llbuild3
1+
# llbuild3
22

33
## Objectives
44

@@ -18,7 +18,7 @@
1818

1919
## API Overview — Ergonomics
2020

21-
Tritium will incorporate concepts from llbuild1, llbuild2, and llbuild2fx. The constructs are intended to enable a separation of the items that can be produced (Artifacts) from the computations that can produce them (Rules/Tasks), addressing an expression challenge that exists today in llbuild2fx rule definition.
21+
llbuild3 will incorporate concepts from llbuild1, llbuild2, and llbuild2fx. The constructs are intended to enable a separation of the items that can be produced (Artifacts) from the computations that can produce them (Rules/Tasks), addressing an expression challenge that exists today in llbuild2fx rule definition.
2222

2323
### Dynamic Graph Definition
2424

@@ -53,7 +53,7 @@ Tritium will incorporate concepts from llbuild1, llbuild2, and llbuild2fx. The
5353
* Build
5454
* Outstanding, in-progress request to produce a specific artifact from the overall build namespace
5555

56-
![Tritium Classes](./docs/tritium.jpg)
56+
![llbuild3 Classes](./docs/llbuild3.jpg)
5757

5858
### Engine Components
5959

@@ -111,8 +111,8 @@ Next steps
111111
Code Structure
112112

113113
* Framework Headers
114-
* products/Tritium
114+
* products/llbuild3
115115
* Framework Sources
116-
* src/tritium
116+
* src/llbuild3
117117
* Unit Tests
118-
* unittests/TritiumCoreTests
118+
* unittests/llbuild3CoreTests

Xcode/Configs/TritiumCommon.xcconfig renamed to Xcode/Configs/llbuild3Common.xcconfig

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
TRITIUM_INSTALL_BASE_PATH = $(TRITIUM_INSTALL_DIR:default=$(LOCAL_LIBRARY_DIR))
14-
TRITIUM_FRAMEWORKS_INSTALL_DIR = $(TRITIUM_INSTALL_BASE_PATH)/Frameworks
13+
LLBUILD3_INSTALL_BASE_PATH = $(LLBUILD3_INSTALL_DIR:default=$(LOCAL_LIBRARY_DIR))
14+
LLBUILD3_FRAMEWORKS_INSTALL_DIR = $(LLBUILD3_INSTALL_BASE_PATH)/Frameworks
1515

1616
// Set the default product name.
1717
PRODUCT_NAME = $(TARGET_NAME)
@@ -69,4 +69,4 @@ CODE_SIGN_ENTITLEMENTS = $(LLBUILD_CODE_SIGN_ENTITLEMENTS__producttype_eq_$(PROD
6969
LLBUILD_CODE_SIGN_ENTITLEMENTS__producttype_eq_com_apple_product_type_tool = $(LLBUILD_TOOL_CODE_SIGN_ENTITLEMENTS)
7070
LLBUILD_TOOL_CODE_SIGN_ENTITLEMENTS =
7171

72-
#include? "TritiumOverrides.xcconfig"
72+
#include? "llbuild3Overrides.xcconfig"

Xcode/Configs/TritiumDebug.xcconfig renamed to Xcode/Configs/llbuild3Debug.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
// Shared build settings.
14-
#include "TritiumCommon.xcconfig"
14+
#include "llbuild3Common.xcconfig"
1515

1616
// Only build the active architecture for Debug.
1717
ONLY_ACTIVE_ARCH = YES

Xcode/Configs/TritiumRelease.xcconfig renamed to Xcode/Configs/llbuild3Release.xcconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
// Shared build settings.
14-
#include "TritiumCommon.xcconfig"
14+
#include "llbuild3Common.xcconfig"
1515

1616
// Prefer binary Info.plists for Release.
1717
INFOPLIST_OUTPUT_FORMAT = binary

Xcode/Tritium.xctestplan renamed to Xcode/llbuild3.xctestplan

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"target" : {
1717
"containerPath" : "container:llbuild.xcodeproj",
1818
"identifier" : "4072B5DD2C51BE5100B68221",
19-
"name" : "TritiumTests"
19+
"name" : "llbuild3Tests"
2020
}
2121
}
2222
],
File renamed without changes.

llbuild.xcodeproj/project.pbxproj

Lines changed: 140 additions & 866 deletions
Large diffs are not rendered by default.

llbuild.xcodeproj/xcshareddata/xcschemes/Tritium.xcscheme renamed to llbuild.xcodeproj/xcshareddata/xcschemes/llbuild3.xcscheme

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<BuildableReference
1717
BuildableIdentifier = "primary"
1818
BlueprintIdentifier = "4072B5D62C51BE5100B68221"
19-
BuildableName = "Tritium.framework"
20-
BlueprintName = "Tritium"
19+
BuildableName = "llbuild3.framework"
20+
BlueprintName = "llbuild3"
2121
ReferencedContainer = "container:llbuild.xcodeproj">
2222
</BuildableReference>
2323
</BuildActionEntry>
@@ -30,8 +30,8 @@
3030
<BuildableReference
3131
BuildableIdentifier = "primary"
3232
BlueprintIdentifier = "4072B5DD2C51BE5100B68221"
33-
BuildableName = "TritiumTests.xctest"
34-
BlueprintName = "TritiumTests"
33+
BuildableName = "llbuild3Tests.xctest"
34+
BlueprintName = "llbuild3Tests"
3535
ReferencedContainer = "container:llbuild.xcodeproj">
3636
</BuildableReference>
3737
</BuildActionEntry>
@@ -44,7 +44,7 @@
4444
shouldUseLaunchSchemeArgsEnv = "YES">
4545
<TestPlans>
4646
<TestPlanReference
47-
reference = "container:Xcode/Tritium.xctestplan"
47+
reference = "container:Xcode/llbuild3.xctestplan"
4848
default = "YES">
4949
</TestPlanReference>
5050
</TestPlans>
@@ -71,8 +71,8 @@
7171
<BuildableReference
7272
BuildableIdentifier = "primary"
7373
BlueprintIdentifier = "4072B5D62C51BE5100B68221"
74-
BuildableName = "Tritium.framework"
75-
BlueprintName = "Tritium"
74+
BuildableName = "llbuild3.framework"
75+
BlueprintName = "llbuild3"
7676
ReferencedContainer = "container:llbuild.xcodeproj">
7777
</BuildableReference>
7878
</MacroExpansion>

llbuild.xcodeproj/xcshareddata/xcschemes/TritiumTests.xcscheme renamed to llbuild.xcodeproj/xcshareddata/xcschemes/llbuild3Tests.xcscheme

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@
2020
<BuildableReference
2121
BuildableIdentifier = "primary"
2222
BlueprintIdentifier = "4072B5DD2C51BE5100B68221"
23-
BuildableName = "TritiumTests.xctest"
24-
BlueprintName = "TritiumTests"
23+
BuildableName = "llbuild3Tests.xctest"
24+
BlueprintName = "llbuild3Tests"
2525
ReferencedContainer = "container:llbuild.xcodeproj">
2626
</BuildableReference>
2727
</TestableReference>

llbuild.xcodeproj/xcshareddata/xcschemes/TritiumThirdParty.xcscheme renamed to llbuild.xcodeproj/xcshareddata/xcschemes/llbuild3ThirdParty.xcscheme

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
<BuildableReference
1717
BuildableIdentifier = "primary"
1818
BlueprintIdentifier = "4072B4DF2C51B3A000B68221"
19-
BuildableName = "libTritiumThirdParty.a"
20-
BlueprintName = "TritiumThirdParty"
19+
BuildableName = "libllbuild3ThirdParty.a"
20+
BlueprintName = "llbuild3ThirdParty"
2121
ReferencedContainer = "container:llbuild.xcodeproj">
2222
</BuildableReference>
2323
</BuildActionEntry>
@@ -52,8 +52,8 @@
5252
<BuildableReference
5353
BuildableIdentifier = "primary"
5454
BlueprintIdentifier = "4072B4DF2C51B3A000B68221"
55-
BuildableName = "libTritiumThirdParty.a"
56-
BlueprintName = "TritiumThirdParty"
55+
BuildableName = "libllbuild3ThirdParty.a"
56+
BlueprintName = "llbuild3ThirdParty"
5757
ReferencedContainer = "container:llbuild.xcodeproj">
5858
</BuildableReference>
5959
</MacroExpansion>

products/Tritium/Tritium.h

Lines changed: 0 additions & 24 deletions
This file was deleted.

products/Tritium/Errors.hpp renamed to products/llbuild3/Errors.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef TRITIUM_CORE_ERRORS_H
14-
#define TRITIUM_CORE_ERRORS_H
13+
#ifndef LLBUILD3_CORE_ERRORS_H
14+
#define LLBUILD3_CORE_ERRORS_H
1515

1616
#include <cstdint>
1717

18-
namespace tritium {
18+
namespace llbuild3 {
1919
namespace core {
2020

2121
enum EngineError: uint64_t {

products/Tritium/Result.hpp renamed to products/llbuild3/Result.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
#ifndef RESULT_RESULT_HPP
3333
#define RESULT_RESULT_HPP
3434

35-
// BEGIN: Tritium additions
36-
#include <Tritium/Visibility.hpp>
37-
#define RESULT_NAMESPACE tritium
35+
// BEGIN: llbuild3 additions
36+
#include <llbuild3/Visibility.hpp>
37+
#define RESULT_NAMESPACE llbuild3
3838
#define RESULT_EXCEPTIONS_DISABLED
3939
#define RESULT_DISABLE_EXCEPTIONS
40-
// END: Tritium additions
40+
// END: llbuild3 additions
4141

4242
#include <cstddef> // std::size_t
4343
#include <type_traits> // std::enable_if, std::is_constructible, etc
@@ -303,7 +303,7 @@ inline namespace bitwizeshift {
303303
explicit in_place_error_t() = default;
304304
};
305305

306-
TRITIUM_EXPORT constexpr auto in_place_error = in_place_error_t{};
306+
LLBUILD3_EXPORT constexpr auto in_place_error = in_place_error_t{};
307307

308308
//===========================================================================
309309
// forward-declarations
@@ -5998,8 +5998,8 @@ auto RESULT_NS_IMPL::swap(result<void,E>& lhs, result<void,E>& rhs)
59985998
#undef RESULT_NODISCARD
59995999
#undef RESULT_WARN_UNUSED
60006000

6001-
// BEGIN: Tritium additions
6001+
// BEGIN: llbuild3 additions
60026002
#undef RESULT_NAMESPACE
6003-
// END: Tritium additions
6003+
// END: llbuild3 additions
60046004

60056005
#endif /* RESULT_RESULT_HPP */

products/Tritium/SwiftAdaptors.hpp renamed to products/llbuild3/SwiftAdaptors.hpp

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef TRITIUM_CORE_SWIFTADAPTORS_H
14-
#define TRITIUM_CORE_SWIFTADAPTORS_H
13+
#ifndef LLBUILD3_CORE_SWIFTADAPTORS_H
14+
#define LLBUILD3_CORE_SWIFTADAPTORS_H
1515

1616
#include <memory>
1717
#include <optional>
1818
#include <string>
1919
#include <vector>
2020

21-
#include <Tritium/Visibility.hpp>
22-
#include <Tritium/Result.hpp>
21+
#include <llbuild3/Visibility.hpp>
22+
#include <llbuild3/Result.hpp>
2323

2424

25-
namespace tritium {
25+
namespace llbuild3 {
2626
namespace core {
2727

2828
class Build;
@@ -31,6 +31,8 @@ struct EngineConfig;
3131

3232
// Serialized Protobuf Objects
3333
typedef std::string ArtifactPB;
34+
typedef std::string CacheKeyPB;
35+
typedef std::string CacheValuePB;
3436
typedef std::string ErrorPB;
3537
typedef std::string LabelPB;
3638
typedef std::string SignaturePB;
@@ -66,17 +68,18 @@ class ExtTaskInterface {
6668
public:
6769
ExtTaskInterface(void* impl, uint64_t ctx) : impl(impl), ctx(ctx) { }
6870

69-
TRITIUM_EXPORT ErrorPB registerRuleProvider(const ExtRuleProvider provider);
71+
LLBUILD3_EXPORT ErrorPB registerRuleProvider(const ExtRuleProvider provider);
7072

71-
TRITIUM_EXPORT result<uint64_t, ErrorPB> requestArtifact(const LabelPB label);
72-
TRITIUM_EXPORT result<uint64_t, ErrorPB> requestRule(const LabelPB label);
73-
TRITIUM_EXPORT result<uint64_t, ErrorPB> requestAction();
73+
LLBUILD3_EXPORT result<uint64_t, ErrorPB> requestArtifact(const LabelPB label);
74+
LLBUILD3_EXPORT result<uint64_t, ErrorPB> requestRule(const LabelPB label);
75+
LLBUILD3_EXPORT result<uint64_t, ErrorPB> requestAction();
7476
};
7577

7678
struct ExtTask {
7779
void* ctx;
7880

7981
LabelPB name;
82+
SignaturePB signature;
8083

8184
bool isInit = false;
8285

@@ -106,25 +109,44 @@ class BuildRef {
106109
public:
107110
BuildRef(std::shared_ptr<Build> build) : build(build) { }
108111

109-
TRITIUM_EXPORT void cancel();
110-
TRITIUM_EXPORT void addCompletionHandler(void* ctx, void (*handler)(void*, result<ArtifactPB, ErrorPB>*));
112+
LLBUILD3_EXPORT void cancel();
113+
LLBUILD3_EXPORT void addCompletionHandler(void* ctx, void (*handler)(void*, result<ArtifactPB, ErrorPB>*));
111114
};
112115

116+
class CASDatabase;
117+
typedef std::shared_ptr<CASDatabase> CASDatabaseRef;
118+
LLBUILD3_EXPORT CASDatabaseRef makeInMemoryCASDatabase();
119+
120+
struct ExtActionCache {
121+
void* ctx;
122+
123+
// FIXME: cleanup context
124+
125+
void (*getFn)(void* ctx, CacheKeyPB key, std::function<void (CacheValuePB, ErrorPB)>);
126+
void (*updateFn)(void*, CacheKeyPB key, CacheValuePB value);
127+
};
128+
129+
class ActionCache;
130+
typedef std::shared_ptr<ActionCache> ActionCacheRef;
131+
LLBUILD3_EXPORT ActionCacheRef makeExtActionCache(ExtActionCache extCache);
132+
LLBUILD3_EXPORT ActionCacheRef makeInMemoryActionCache();
133+
134+
113135
struct ExtEngineConfig {
114136
std::optional<LabelPB> initRule;
115137

116-
TRITIUM_EXPORT inline void setInitRule(LabelPB ir) { initRule = ir; }
138+
LLBUILD3_EXPORT inline void setInitRule(LabelPB ir) { initRule = ir; }
117139
};
118140

119141
class EngineRef {
120142
std::shared_ptr<Engine> engine;
121143
public:
122144
EngineRef(std::shared_ptr<Engine> engine) : engine(engine) { }
123145

124-
TRITIUM_EXPORT BuildRef build(const LabelPB artifact);
146+
LLBUILD3_EXPORT BuildRef build(const LabelPB artifact);
125147
};
126148

127-
TRITIUM_EXPORT EngineRef makeEngine(ExtEngineConfig config, /* action cache, ... */ const ExtRuleProvider provider);
149+
LLBUILD3_EXPORT EngineRef makeEngine(ExtEngineConfig config, CASDatabaseRef casdb, ActionCacheRef cache, const ExtRuleProvider provider);
128150

129151
}
130152
}

products/Tritium/Visibility.hpp renamed to products/llbuild3/Visibility.hpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13-
#ifndef TRITIUM_VISIBILITY_H
14-
#define TRITIUM_VISIBILITY_H
13+
#ifndef LLBUILD3_VISIBILITY_H
14+
#define LLBUILD3_VISIBILITY_H
1515

1616
#if defined(__ELF__) || (defined(__APPLE__) && defined(__MACH__))
17-
#define TRITIUM_EXPORT __attribute__((__visibility__("default")))
17+
#define LLBUILD3_EXPORT __attribute__((__visibility__("default")))
1818
#else
1919
// asume PE/COFF
2020
#if defined(_WINDLL)
21-
#define TRITIUM_EXPORT __declspec(dllexport)
21+
#define LLBUILD3_EXPORT __declspec(dllexport)
2222
#else
23-
#define TRITIUM_EXPORT
23+
#define LLBUILD3_EXPORT
2424
#endif
2525
#endif
2626

0 commit comments

Comments
 (0)