@@ -142,6 +142,41 @@ utils::error::Result<void> pullDependency(const package::Reference &ref,
142142
143143} // namespace
144144
145+ namespace detail {
146+ void mergeOutput (const std::vector<std::filesystem::path> &src,
147+ const std::filesystem::path &dest,
148+ const std::vector<std::string> &targets)
149+ {
150+ for (const auto &dir : src) {
151+ LogD (" merge {} to {}" , dir, dest);
152+ auto matcher = [&dir, &targets](const std::filesystem::path &path) {
153+ if (common::strings::starts_with (path.filename ().string (), " .wh." )) {
154+ return false ;
155+ }
156+
157+ struct stat st;
158+ if (-1 == lstat ((dir / path).c_str (), &st)) {
159+ return false ;
160+ }
161+ if (st.st_size == 0 && st.st_rdev == 0 && st.st_mode == S_IFCHR) {
162+ return false ;
163+ }
164+
165+ for (const auto &target : targets) {
166+ if (common::strings::starts_with (path.string (), target)) {
167+ return true ;
168+ }
169+ }
170+
171+ return false ;
172+ };
173+
174+ utils::copyDirectory (dir, dest, matcher);
175+ }
176+ }
177+
178+ } // namespace detail
179+
145180// install module files by rules
146181// files will be moved from buildOutput to moduleOutput
147182utils::error::Result<std::vector<std::filesystem::path>>
@@ -904,7 +939,7 @@ utils::error::Result<void> Builder::buildStagePreCommit() noexcept
904939 src.push_back (runtimeOverlay->upperDirPath ());
905940 }
906941 }
907- mergeOutput (src, buildOutput, { " bin/" , " sbin/" , " lib/" });
942+ detail:: mergeOutput (src, buildOutput, { " bin/" , " sbin/" , " lib/" });
908943
909944 return LINGLONG_OK;
910945}
@@ -2189,38 +2224,6 @@ void Builder::takeTerminalForeground()
21892224 }
21902225}
21912226
2192- void Builder::mergeOutput (const std::vector<std::filesystem::path> &src,
2193- const std::filesystem::path &dest,
2194- const std::vector<std::string> &targets)
2195- {
2196-
2197- for (const auto &dir : src) {
2198- auto matcher = [&dir, &targets](const std::filesystem::path &path) {
2199- if (path.filename ().string ().rfind (" .wh." , 0 ) == 0 ) {
2200- return false ;
2201- }
2202-
2203- struct stat st;
2204- if (-1 == lstat (path.c_str (), &st)) {
2205- return false ;
2206- }
2207- if (st.st_size == 0 && st.st_rdev == 0 && st.st_mode == S_IFCHR) {
2208- return false ;
2209- }
2210-
2211- for (const auto &target : targets) {
2212- if (path.lexically_relative (dir).string ().rfind (target, 0 ) == 0 ) {
2213- return true ;
2214- }
2215- }
2216-
2217- return false ;
2218- };
2219-
2220- utils::copyDirectory (dir, dest, matcher);
2221- }
2222- }
2223-
22242227void Builder::printBasicInfo ()
22252228{
22262229 printMessage (" [Builder info]" );
0 commit comments