Skip to content

Commit fe00008

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

File tree

3 files changed

+27
-64
lines changed

3 files changed

+27
-64
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -159,8 +159,7 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
159159
return errors.WithStack(err)
160160
}
161161

162-
err = runCommand(ctx, &FailIfImportedLibraryIsWrong{})
163-
if err != nil {
162+
if err := failIfImportedLibraryIsWrong(ctx); err != nil {
164163
return errors.WithStack(err)
165164
}
166165

@@ -177,15 +176,6 @@ func appendIncludeFolder(ctx *types.Context, cache *includeCache, sourceFilePath
177176
cache.ExpectEntry(sourceFilePath, include, folder)
178177
}
179178

180-
func runCommand(ctx *types.Context, command types.Command) error {
181-
PrintRingNameIfDebug(ctx, command)
182-
err := command.Run(ctx)
183-
if err != nil {
184-
return errors.WithStack(err)
185-
}
186-
return nil
187-
}
188-
189179
type includeCacheEntry struct {
190180
Sourcefile *paths.Path
191181
Include string
@@ -471,3 +461,29 @@ func ResolveLibrary(ctx *types.Context, header string) *libraries.Library {
471461

472462
return selected
473463
}
464+
465+
func failIfImportedLibraryIsWrong(ctx *types.Context) error {
466+
if len(ctx.ImportedLibraries) == 0 {
467+
return nil
468+
}
469+
470+
for _, library := range ctx.ImportedLibraries {
471+
if !library.IsLegacy {
472+
if library.InstallDir.Join("arch").IsDir() {
473+
return errors.New(tr("%[1]s folder is no longer supported! See %[2]s for more information", "'arch'", "http://goo.gl/gfFJzU"))
474+
}
475+
for _, propName := range libraries.MandatoryProperties {
476+
if !library.Properties.ContainsKey(propName) {
477+
return errors.New(tr("Missing '%[1]s' from library in %[2]s", propName, library.InstallDir))
478+
}
479+
}
480+
if library.Layout == libraries.RecursiveLayout {
481+
if library.UtilityDir != nil {
482+
return errors.New(tr("Library can't use both '%[1]s' and '%[2]s' folders. Double check in '%[3]s'.", "src", "utility", library.InstallDir))
483+
}
484+
}
485+
}
486+
}
487+
488+
return nil
489+
}

legacy/builder/fail_if_imported_library_is_wrong.go

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

0 commit comments

Comments
 (0)