From a2a232a0450e6eeddfbb1570f09f2ebf94b16c4b Mon Sep 17 00:00:00 2001 From: Egor Pugin Date: Fri, 26 Apr 2024 17:08:53 +0300 Subject: [PATCH] Add generic FilesTarget for files only packages. --- src/sw/driver/sw.h | 2 ++ src/sw/driver/target/other.h | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/src/sw/driver/sw.h b/src/sw/driver/sw.h index 25dc330a..e21e3a5e 100644 --- a/src/sw/driver/sw.h +++ b/src/sw/driver/sw.h @@ -115,6 +115,8 @@ using sw::ValaExecutable; using sw::PythonLibrary; +using sw::FilesTarget; + // using sw::ConfigureFlags; using sw::PrecompiledHeader; diff --git a/src/sw/driver/target/other.h b/src/sw/driver/target/other.h index e46262ff..9858f883 100644 --- a/src/sw/driver/target/other.h +++ b/src/sw/driver/target/other.h @@ -330,4 +330,27 @@ struct SW_DRIVER_CPP_API PythonLibrary : Target SW_TARGET_ADD_DEPENDENCIES(PythonLibrary, addSourceDependency) }; +struct FilesTarget : Target, SourceFileTargetOptions +{ + FilesTarget(TargetBase &parent, const PackageId &id) + : Target(parent, id), SourceFileTargetOptions(static_cast(*this)) + { + } + + using Target::operator+=; + using Target::operator=; + using Target::add; + SW_TARGET_USING_ASSIGN_OPS(SourceFileTargetOptions); + + Files gatherAllFiles() const override + { + Files files; + for (auto &f : *this) + files.insert(f.first); + return files; + } + + SW_TARGET_ADD_DEPENDENCIES(FilesTarget, addSourceDependency) +}; + }