Skip to content

Commit 15f2908

Browse files
authored
[Cleanup] Remove Lock APIs (#217)
1 parent 05ad3df commit 15f2908

22 files changed

+4
-282
lines changed

buildcc/lib/target/include/target/api/target_getter.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ template <typename T> class TargetGetter {
3838
// Target State
3939
const TargetState &GetState() const;
4040
bool IsBuilt() const;
41-
bool IsLocked() const;
4241

4342
// Target Config
4443
const TargetConfig &GetConfig() const;

buildcc/lib/target/include/target/target_info.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,6 @@ class TargetInfo : public internal::SourceApi<TargetInfo>,
8686
TargetEnv env_;
8787

8888
//
89-
FunctionLock lock_;
9089
UserTargetSchema user_;
9190

9291
private:

buildcc/lib/target/src/api/deps_api.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,12 @@ template <typename T>
2424
void DepsApi<T>::AddCompileDependencyAbsolute(const fs::path &absolute_path) {
2525
T &t = static_cast<T &>(*this);
2626

27-
t.lock_.ExpectsUnlock(__FUNCTION__);
2827
t.user_.compile_dependencies.insert(absolute_path);
2928
}
3029
template <typename T>
3130
void DepsApi<T>::AddLinkDependencyAbsolute(const fs::path &absolute_path) {
3231
T &t = static_cast<T &>(*this);
3332

34-
t.lock_.ExpectsUnlock(__FUNCTION__);
3533
t.user_.link_dependencies.insert(absolute_path);
3634
}
3735

buildcc/lib/target/src/api/flag_api.cpp

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,55 +24,47 @@ template <typename T>
2424
void FlagApi<T>::AddPreprocessorFlag(const std::string &flag) {
2525
T &t = static_cast<T &>(*this);
2626

27-
t.lock_.ExpectsUnlock(__FUNCTION__);
2827
t.user_.preprocessor_flags.insert(flag);
2928
}
3029
template <typename T>
3130
void FlagApi<T>::AddCommonCompileFlag(const std::string &flag) {
3231
T &t = static_cast<T &>(*this);
3332

34-
t.lock_.ExpectsUnlock(__FUNCTION__);
3533
t.user_.common_compile_flags.insert(flag);
3634
}
3735
template <typename T>
3836
void FlagApi<T>::AddPchCompileFlag(const std::string &flag) {
3937
T &t = static_cast<T &>(*this);
4038

41-
t.lock_.ExpectsUnlock(__FUNCTION__);
4239
t.user_.pch_compile_flags.insert(flag);
4340
}
4441
template <typename T>
4542
void FlagApi<T>::AddPchObjectFlag(const std::string &flag) {
4643
T &t = static_cast<T &>(*this);
4744

48-
t.lock_.ExpectsUnlock(__FUNCTION__);
4945
t.user_.pch_object_flags.insert(flag);
5046
}
5147
template <typename T>
5248
void FlagApi<T>::AddAsmCompileFlag(const std::string &flag) {
5349
T &t = static_cast<T &>(*this);
5450

55-
t.lock_.ExpectsUnlock(__FUNCTION__);
5651
t.user_.asm_compile_flags.insert(flag);
5752
}
5853
template <typename T>
5954
void FlagApi<T>::AddCCompileFlag(const std::string &flag) {
6055
T &t = static_cast<T &>(*this);
6156

62-
t.lock_.ExpectsUnlock(__FUNCTION__);
6357
t.user_.c_compile_flags.insert(flag);
6458
}
6559
template <typename T>
6660
void FlagApi<T>::AddCppCompileFlag(const std::string &flag) {
6761
T &t = static_cast<T &>(*this);
6862

69-
t.lock_.ExpectsUnlock(__FUNCTION__);
7063
t.user_.cpp_compile_flags.insert(flag);
7164
}
7265
template <typename T> void FlagApi<T>::AddLinkFlag(const std::string &flag) {
7366
T &t = static_cast<T &>(*this);
7467

75-
t.lock_.ExpectsUnlock(__FUNCTION__);
7668
t.user_.link_flags.insert(flag);
7769
}
7870

buildcc/lib/target/src/api/include_api.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ template <typename T>
2424
void IncludeApi<T>::AddHeaderAbsolute(const fs::path &absolute_filepath) {
2525
T &t = static_cast<T &>(*this);
2626

27-
t.lock_.ExpectsUnlock(__FUNCTION__);
2827
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
2928
t.user_.headers.insert(absolute_filepath);
3029
}
@@ -74,7 +73,6 @@ void IncludeApi<T>::AddIncludeDirAbsolute(const fs::path &absolute_include_dir,
7473
bool glob_headers) {
7574
T &t = static_cast<T &>(*this);
7675

77-
t.lock_.ExpectsUnlock(__FUNCTION__);
7876
t.user_.include_dirs.insert(absolute_include_dir);
7977

8078
if (glob_headers) {

buildcc/lib/target/src/api/lib_api.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ template <typename T>
2525
void LibApi<T>::AddLibDirAbsolute(const fs::path &absolute_lib_dir) {
2626
T &t = static_cast<T &>(*this);
2727

28-
t.lock_.ExpectsUnlock(__FUNCTION__);
2928
t.user_.lib_dirs.insert(absolute_lib_dir);
3029
}
3130

@@ -40,14 +39,12 @@ void LibApi<T>::AddLibDir(const fs::path &relative_lib_dir) {
4039
template <typename T> void LibApi<T>::AddLibDep(const BaseTarget &lib_dep) {
4140
T &t = static_cast<T &>(*this);
4241

43-
t.lock_.ExpectsUnlock(__FUNCTION__);
4442
t.user_.libs.push_back(lib_dep.GetTargetPath());
4543
}
4644

4745
template <typename T> void LibApi<T>::AddLibDep(const std::string &lib_dep) {
4846
T &t = static_cast<T &>(*this);
4947

50-
t.lock_.ExpectsUnlock(__FUNCTION__);
5148
t.user_.external_libs.push_back(lib_dep);
5249
}
5350

buildcc/lib/target/src/api/pch_api.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ template <typename T>
2424
void PchApi<T>::AddPchAbsolute(const fs::path &absolute_filepath) {
2525
T &t = static_cast<T &>(*this);
2626

27-
t.lock_.ExpectsUnlock(__FUNCTION__);
2827
t.toolchain_.GetConfig().ExpectsValidHeader(absolute_filepath);
2928

3029
const fs::path absolute_pch = fs::path(absolute_filepath).make_preferred();

buildcc/lib/target/src/api/source_api.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ template <typename T>
2424
void SourceApi<T>::AddSourceAbsolute(const fs::path &absolute_source) {
2525
T &t = static_cast<T &>(*this);
2626

27-
t.lock_.ExpectsUnlock(__FUNCTION__);
2827
t.toolchain_.GetConfig().ExpectsValidSource(absolute_source);
2928
t.user_.sources.emplace(fs::path(absolute_source).make_preferred());
3029
}

buildcc/lib/target/src/api/sync_api.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ template <typename TargetType>
4141
void SyncApi<T>::SpecializedCopy(TargetType target,
4242
std::initializer_list<SyncOption> options) {
4343
T &t = static_cast<T &>(*this);
44-
t.lock_.ExpectsUnlock(__FUNCTION__);
4544
for (const SyncOption o : options) {
4645
switch (o) {
4746
case SyncOption::PreprocessorFlags:
@@ -122,7 +121,6 @@ template <typename TargetType>
122121
void SyncApi<T>::SpecializedInsert(TargetType target,
123122
std::initializer_list<SyncOption> options) {
124123
T &t = static_cast<T &>(*this);
125-
t.lock_.ExpectsUnlock(__FUNCTION__);
126124
for (const SyncOption o : options) {
127125
switch (o) {
128126
case SyncOption::PreprocessorFlags:

buildcc/lib/target/src/api/target_getter.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,6 @@ template <typename T> const TargetConfig &TargetGetter<T>::GetConfig() const {
4040
return t.config_;
4141
}
4242

43-
template <typename T> bool TargetGetter<T>::IsLocked() const {
44-
const T &t = static_cast<const T &>(*this);
45-
46-
return t.lock_.IsLocked();
47-
}
48-
4943
template <typename T> const fs::path &TargetGetter<T>::GetBinaryPath() const {
5044
const T &t = static_cast<const T &>(*this);
5145

@@ -95,22 +89,19 @@ const std::string &
9589
TargetGetter<T>::GetCompileCommand(const fs::path &source) const {
9690
const T &t = static_cast<const T &>(*this);
9791

98-
t.lock_.ExpectsLock(__FUNCTION__);
9992
return t.compile_object_.GetObjectData(source).command;
10093
}
10194

10295
template <typename T>
10396
const std::string &TargetGetter<T>::GetLinkCommand() const {
10497
const T &t = static_cast<const T &>(*this);
10598

106-
t.lock_.ExpectsLock(__FUNCTION__);
10799
return t.link_target_.GetCommand();
108100
}
109101

110102
template <typename T> tf::Taskflow &TargetGetter<T>::GetTaskflow() {
111103
T &t = static_cast<T &>(*this);
112104

113-
t.lock_.ExpectsLock(__FUNCTION__);
114105
return t.tf_;
115106
}
116107

buildcc/lib/target/src/target/build.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ namespace buildcc {
5454
void Target::Build() {
5555
env::log_trace(name_, __FUNCTION__);
5656

57-
lock_.ExpectsUnlock("Target::Build");
58-
lock_.Lock();
59-
6057
// PCH state
6158
if (!user_.pchs.empty()) {
6259
state_.PchDetected();

buildcc/lib/target/src/target_info/target_info.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@ namespace buildcc {
2121
// PRIVATE
2222

2323
void TargetInfo::Initialize() {
24-
// TODO, Update this later
25-
// toolchain_.GetLockInfo().ExpectsLock(
26-
// "Toolchain should be locked before usage through `Toolchain::Lock`");
27-
2824
std::for_each(toolchain_.GetPreprocessorFlags().begin(),
2925
toolchain_.GetPreprocessorFlags().end(),
3026
[&](const std::string &flag) { AddPreprocessorFlag(flag); });

buildcc/lib/target/test/target/CMakeLists.txt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,6 @@ add_executable(test_target_user_deps
136136
)
137137
target_link_libraries(test_target_user_deps PRIVATE target_interface)
138138

139-
add_executable(test_target_lock
140-
test_target_lock.cpp
141-
)
142-
target_link_libraries(test_target_lock PRIVATE target_interface)
143-
144139
add_executable(test_target_sync
145140
test_target_sync.cpp
146141
)
@@ -162,7 +157,6 @@ add_test(NAME test_target_external_lib COMMAND test_target_external_lib)
162157

163158
add_test(NAME test_target_flags COMMAND test_target_flags)
164159
add_test(NAME test_target_user_deps COMMAND test_target_user_deps)
165-
add_test(NAME test_target_lock COMMAND test_target_lock)
166160

167161
add_test(NAME test_target_sync COMMAND test_target_sync)
168162

buildcc/lib/target/test/target/constants.h.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ inline constexpr char const * BUILD_TARGET_FLAG_INTERMEDIATE_DIR = "@CMAKE_CURRE
1717

1818
inline constexpr char const * BUILD_TARGET_USER_DEPS_INTERMEDIATE_DIR = "@CMAKE_CURRENT_SOURCE_DIR@/intermediate/target_user_deps";
1919

20-
inline constexpr char const * BUILD_TARGET_LOCK_INTERMEDIATE_DIR = "@CMAKE_CURRENT_SOURCE_DIR@/intermediate/target_lock";
21-
2220
inline constexpr char const * BUILD_TARGET_SYNC_INTERMEDIATE_DIR = "@CMAKE_CURRENT_SOURCE_DIR@/intermediate/target_sync";
2321

2422
inline constexpr char const * BUILD_TARGET_FAILURE_STATES_BUILD_DIR = "@CMAKE_CURRENT_SOURCE_DIR@/intermediate/target_failure_states";

buildcc/lib/target/test/target/test_target_lock.cpp

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

buildcc/lib/target/test/target/test_target_source.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ TEST(TargetTestSourceGroup, Target_CompileCommand_Throws) {
243243

244244
// Throws when you call CompileCommand before Build
245245
CHECK_THROWS(std::exception, simple.GetCompileCommand(p));
246+
// Link Command will be empty before Build
247+
STRCMP_EQUAL(simple.GetLinkCommand().c_str(), "");
246248
}
247249
}
248250

0 commit comments

Comments
 (0)