@@ -175,7 +175,7 @@ func (s *ContainerFindIncludes) findIncludes(ctx *types.Context) error {
175
175
}
176
176
}
177
177
178
- if err := runCommand (ctx , & FailIfImportedLibraryIsWrong {} ); err != nil {
178
+ if err := failIfImportedLibraryIsWrong (ctx ); err != nil {
179
179
return errors .WithStack (err )
180
180
}
181
181
@@ -198,15 +198,6 @@ func appendIncludeFolder(ctx *types.Context, cache *includeCache, sourceFilePath
198
198
cache .ExpectEntry (sourceFilePath , include , folder )
199
199
}
200
200
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
-
210
201
type includeCacheEntry struct {
211
202
Sourcefile * paths.Path
212
203
Include string
@@ -318,10 +309,10 @@ func writeCache(cache *includeCache, path *paths.Path) error {
318
309
319
310
func findIncludesUntilDone (ctx * types.Context , cache * includeCache , sourceFileQueue * types.UniqueSourceFileQueue ) error {
320
311
sourceFile := sourceFileQueue .Pop ()
321
- sourcePath := sourceFile .SourcePath (ctx )
312
+ sourcePath := sourceFile .SourcePath ()
322
313
targetFilePath := paths .NullPath ()
323
- depPath := sourceFile .DepfilePath (ctx )
324
- objPath := sourceFile .ObjectPath (ctx )
314
+ depPath := sourceFile .DepfilePath ()
315
+ objPath := sourceFile .ObjectPath ()
325
316
326
317
// TODO: This should perhaps also compare against the
327
318
// include.cache file timestamp. Now, it only checks if the file
@@ -342,28 +333,21 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
342
333
343
334
first := true
344
335
for {
345
- var missingIncludeH string
346
336
cache .ExpectFile (sourcePath )
347
337
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.
348
342
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 )
362
345
}
363
346
364
347
var preprocErr error
365
348
var preprocStderr []byte
366
349
350
+ var missingIncludeH string
367
351
if unchanged && cache .valid {
368
352
missingIncludeH = cache .Next ().Include
369
353
if first && ctx .Verbose {
@@ -376,14 +360,11 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
376
360
ctx .WriteStdout (preprocStdout )
377
361
}
378
362
// Unwrap error and see if it is an ExitError.
379
- _ , isExitErr := errors .Cause (preprocErr ).(* exec.ExitError )
380
363
if preprocErr == nil {
381
364
// Preprocessor successful, done
382
365
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
387
368
return errors .WithStack (preprocErr )
388
369
} else {
389
370
missingIncludeH = IncludesFinderWithRegExp (string (preprocStderr ))
@@ -426,9 +407,16 @@ func findIncludesUntilDone(ctx *types.Context, cache *includeCache, sourceFileQu
426
407
// include scanning
427
408
ctx .ImportedLibraries = append (ctx .ImportedLibraries , library )
428
409
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
+ }
432
420
}
433
421
first = false
434
422
}
@@ -499,3 +487,29 @@ func ResolveLibrary(ctx *types.Context, header string) *libraries.Library {
499
487
500
488
return selected
501
489
}
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