Skip to content

Commit 2cbd753

Browse files
committed
Precompiled libraries: only select a folder if it contains files
1 parent 50eef88 commit 2cbd753

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

Diff for: legacy/builder/phases/libraries_builder.go

+14-2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,18 @@ func (s *LibrariesBuilder) Run(ctx *types.Context) error {
5353
return nil
5454
}
5555

56+
func containsFile(folder *paths.Path) bool {
57+
res, _ := folder.ReadDir()
58+
hasfiles := false
59+
for _, el := range res {
60+
if !el.IsDir() {
61+
hasfiles = true
62+
break
63+
}
64+
}
65+
return hasfiles
66+
}
67+
5668
func findExpectedPrecompiledLibFolder(ctx *types.Context, library *libraries.Library) *paths.Path {
5769
mcu := ctx.BuildProperties.Get(constants.BUILD_PROPERTIES_BUILD_MCU)
5870
// Add fpu specifications if they exist
@@ -86,15 +98,15 @@ func findExpectedPrecompiledLibFolder(ctx *types.Context, library *libraries.Lib
8698
if len(fpuSpecs) > 0 {
8799
fpuSpecs = strings.TrimRight(fpuSpecs, "-")
88100
fullPrecompDir := library.SourceDir.Join(mcu).Join(fpuSpecs)
89-
if fullPrecompDir.Exist() {
101+
if fullPrecompDir.Exist() && containsFile(fullPrecompDir) {
90102
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_INFO, "Using precompiled library in {0}", fullPrecompDir)
91103
return fullPrecompDir
92104
}
93105
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_INFO, "Precompiled library in \"{0}\" not found", fullPrecompDir)
94106
}
95107

96108
precompDir := library.SourceDir.Join(mcu)
97-
if precompDir.Exist() {
109+
if precompDir.Exist() && containsFile(precompDir) {
98110
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_INFO, "Using precompiled library in {0}", precompDir)
99111
return precompDir
100112
}

0 commit comments

Comments
 (0)