Skip to content

Commit 145367d

Browse files
committed
Transformed FailIfImportedLibraryIsWrong into a functon
There was no need to have it encapsulated in a Command
1 parent 3c86c76 commit 145367d

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
@@ -39,7 +39,6 @@ const FOLDER_TOOLS = "tools"
3939
const FOLDER_LIBRARIES = "libraries"
4040
const LIBRARY_ALL_ARCHS = "*"
4141
const LIBRARY_EMAIL = "email"
42-
const LIBRARY_FOLDER_ARCH = "arch"
4342
const LIBRARY_FOLDER_SRC = "src"
4443
const LOG_LEVEL_DEBUG = "debug"
4544
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
@@ -175,7 +175,7 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
175175
}
176176
}
177177

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

@@ -198,15 +198,6 @@ func appendIncludeFolder(ctx *types.Context, cache *includeCache, sourceFilePath
198198
cache.ExpectEntry(sourceFilePath, include, folder)
199199
}
200200

201-
func runCommand(ctx *types.Context, command types.Command) error {
202-
PrintRingNameIfDebug(ctx, command)
203-
err := command.Run(ctx)
204-
if err != nil {
205-
return errors.WithStack(err)
206-
}
207-
return nil
208-
}
209-
210201
type includeCacheEntry struct {
211202
Sourcefile *paths.Path
212203
Include string
@@ -500,3 +491,29 @@ func ResolveLibrary(ctx *types.Context, header string) *libraries.Library {
500491

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

legacy/builder/fail_if_imported_library_is_wrong.go

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

0 commit comments

Comments
 (0)