Skip to content

Commit a623b99

Browse files
committed
Transformed FailIfImportedLibraryIsWrong into a functon
There was no need to have it encapsulated in a Command
1 parent f55fe64 commit a623b99

File tree

3 files changed

+27
-63
lines changed

3 files changed

+27
-63
lines changed

legacy/builder/constants/constants.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ const FOLDER_SKETCH = "sketch"
4949
const FOLDER_TOOLS = "tools"
5050
const LIBRARY_ALL_ARCHS = "*"
5151
const LIBRARY_EMAIL = "email"
52-
const LIBRARY_FOLDER_ARCH = "arch"
5352
const LIBRARY_FOLDER_SRC = "src"
5453
const LOG_LEVEL_DEBUG = "debug"
5554
const LOG_LEVEL_ERROR = "error"

legacy/builder/container_find_includes.go

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
173173
}
174174
}
175175

176-
if err := runCommand(ctx, &FailIfImportedLibraryIsWrong{}); err != nil {
176+
if err := failIfImportedLibraryIsWrong(ctx); err != nil {
177177
return errors.WithStack(err)
178178
}
179179

@@ -196,15 +196,6 @@ func appendIncludeFolder(ctx *types.Context, cache *includeCache, sourceFilePath
196196
cache.ExpectEntry(sourceFilePath, include, folder)
197197
}
198198

199-
func runCommand(ctx *types.Context, command types.Command) error {
200-
PrintRingNameIfDebug(ctx, command)
201-
err := command.Run(ctx)
202-
if err != nil {
203-
return errors.WithStack(err)
204-
}
205-
return nil
206-
}
207-
208199
type includeCacheEntry struct {
209200
Sourcefile *paths.Path
210201
Include string
@@ -490,3 +481,29 @@ func ResolveLibrary(ctx *types.Context, header string) *libraries.Library {
490481

491482
return selected
492483
}
484+
485+
func failIfImportedLibraryIsWrong(ctx *types.Context) error {
486+
if len(ctx.ImportedLibraries) == 0 {
487+
return nil
488+
}
489+
490+
for _, library := range ctx.ImportedLibraries {
491+
if !library.IsLegacy {
492+
if library.InstallDir.Join("arch").IsDir() {
493+
return errors.New(tr("%[1]s folder is no longer supported! See %[2]s for more information", "'arch'", "http://goo.gl/gfFJzU"))
494+
}
495+
for _, propName := range libraries.MandatoryProperties {
496+
if !library.Properties.ContainsKey(propName) {
497+
return errors.New(tr("Missing '%[1]s' from library in %[2]s", propName, library.InstallDir))
498+
}
499+
}
500+
if library.Layout == libraries.RecursiveLayout {
501+
if library.UtilityDir != nil {
502+
return errors.New(tr("Library can't use both '%[1]s' and '%[2]s' folders. Double check in '%[3]s'.", "src", "utility", library.InstallDir))
503+
}
504+
}
505+
}
506+
}
507+
508+
return nil
509+
}

legacy/builder/fail_if_imported_library_is_wrong.go

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

0 commit comments

Comments
 (0)