@@ -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-
210201type includeCacheEntry struct {
211202 Sourcefile * paths.Path
212203 Include string
@@ -318,10 +309,10 @@ func writeCache(cache *includeCache, path *paths.Path) error {
318309
319310func findIncludesUntilDone (ctx * types.Context , cache * includeCache , sourceFileQueue * types.UniqueSourceFileQueue ) error {
320311 sourceFile := sourceFileQueue .Pop ()
321- sourcePath := sourceFile .SourcePath (ctx )
312+ sourcePath := sourceFile .SourcePath ()
322313 targetFilePath := paths .NullPath ()
323- depPath := sourceFile .DepfilePath (ctx )
324- objPath := sourceFile .ObjectPath (ctx )
314+ depPath := sourceFile .DepfilePath ()
315+ objPath := sourceFile .ObjectPath ()
325316
326317 // TODO: This should perhaps also compare against the
327318 // include.cache file timestamp. Now, it only checks if the file
@@ -342,28 +333,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
342333
343334 first := true
344335 for {
345- var missingIncludeH string
346336 cache .ExpectFile (sourcePath )
347337
338+ // Libraries may require the "utility" directory to be added to the include
339+ // search path, but only for the source code of the library, so we temporary
340+ // copy the current search path list and add the library' utility directory
341+ // if needed.
348342 includeFolders := ctx .IncludeFolders
349- if library , ok := sourceFile .Origin .(* libraries.Library ); ok && library .UtilityDir != nil {
350- includeFolders = append (includeFolders , library .UtilityDir )
351- }
352-
353- if library , ok := sourceFile .Origin .(* libraries.Library ); ok {
354- if library .Precompiled && library .PrecompiledWithSources {
355- // Fully precompiled libraries should have no dependencies
356- // to avoid ABI breakage
357- if ctx .Verbose {
358- ctx .Info (tr ("Skipping dependencies detection for precompiled library %[1]s" , library .Name ))
359- }
360- return nil
361- }
343+ if extraInclude := sourceFile .ExtraIncludePath (); extraInclude != nil {
344+ includeFolders = append (includeFolders , extraInclude )
362345 }
363346
364347 var preprocErr error
365348 var preprocStderr []byte
366349
350+ var missingIncludeH string
367351 if unchanged && cache .valid {
368352 missingIncludeH = cache .Next ().Include
369353 if first && ctx .Verbose {
@@ -376,14 +360,11 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
376360 ctx .WriteStdout (preprocStdout )
377361 }
378362 // Unwrap error and see if it is an ExitError.
379- _ , isExitErr := errors .Cause (preprocErr ).(* exec.ExitError )
380363 if preprocErr == nil {
381364 // Preprocessor successful, done
382365 missingIncludeH = ""
383- } else if ! isExitErr || preprocStderr == nil {
384- // Ignore ExitErrors (e.g. gcc returning
385- // non-zero status), but bail out on
386- // other errors
366+ } else if _ , isExitErr := errors .Cause (preprocErr ).(* exec.ExitError ); ! isExitErr || preprocStderr == nil {
367+ // Ignore ExitErrors (e.g. gcc returning non-zero status), but bail out on other errors
387368 return errors .WithStack (preprocErr )
388369 } else {
389370 missingIncludeH = IncludesFinderWithRegExp (string (preprocStderr ))
@@ -426,9 +407,16 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
426407 // include scanning
427408 ctx .ImportedLibraries = append (ctx .ImportedLibraries , library )
428409 appendIncludeFolder (ctx , cache , sourcePath , missingIncludeH , library .SourceDir )
429- sourceDirs := library .SourceDirs ()
430- for _ , sourceDir := range sourceDirs {
431- queueSourceFilesFromFolder (ctx , sourceFileQueue , library , sourceDir .Dir , sourceDir .Recurse )
410+
411+ if library .Precompiled && library .PrecompiledWithSources {
412+ // Fully precompiled libraries should have no dependencies to avoid ABI breakage
413+ if ctx .Verbose {
414+ ctx .Info (tr ("Skipping dependencies detection for precompiled library %[1]s" , library .Name ))
415+ }
416+ } else {
417+ for _ , sourceDir := range library .SourceDirs () {
418+ queueSourceFilesFromFolder (ctx , sourceFileQueue , library , sourceDir .Dir , sourceDir .Recurse )
419+ }
432420 }
433421 first = false
434422 }
@@ -499,3 +487,29 @@ func ResolveLibrary(ctx *types.Context, header string) *libraries.Library {
499487
500488 return selected
501489}
490+
491+ func failIfImportedLibraryIsWrong (ctx * types.Context ) error {
492+ if len (ctx .ImportedLibraries ) == 0 {
493+ return nil
494+ }
495+
496+ for _ , library := range ctx .ImportedLibraries {
497+ if ! library .IsLegacy {
498+ if library .InstallDir .Join ("arch" ).IsDir () {
499+ return errors .New (tr ("%[1]s folder is no longer supported! See %[2]s for more information" , "'arch'" , "http://goo.gl/gfFJzU" ))
500+ }
501+ for _ , propName := range libraries .MandatoryProperties {
502+ if ! library .Properties .ContainsKey (propName ) {
503+ return errors .New (tr ("Missing '%[1]s' from library in %[2]s" , propName , library .InstallDir ))
504+ }
505+ }
506+ if library .Layout == libraries .RecursiveLayout {
507+ if library .UtilityDir != nil {
508+ return errors .New (tr ("Library can't use both '%[1]s' and '%[2]s' folders. Double check in '%[3]s'." , "src" , "utility" , library .InstallDir ))
509+ }
510+ }
511+ }
512+ }
513+
514+ return nil
515+ }
0 commit comments