()
| 328 | } |
| 329 | |
| 330 | func (b *BuildConfig) setEnvFlags() { |
| 331 | rootfs := b.Ctx.Platform().GetRootFS() |
| 332 | tmpDepsDir := filepath.Join(dirs.TmpDepsDir, b.PortConfig.LibraryDir) |
| 333 | hostBuild := b.DevDep || b.HostDev |
| 334 | |
| 335 | // sysroot and tmp dir. |
| 336 | if rootfs != nil && !hostBuild { |
| 337 | // Set sysroot. |
| 338 | sysrootDir := rootfs.GetAbsDir() |
| 339 | b.envBackup.setenv("SYSROOT", sysrootDir) |
| 340 | |
| 341 | // Update CFLAGS/CXXFLAGS |
| 342 | b.appendIncludeDir(filepath.Join(tmpDepsDir, "include")) |
| 343 | for _, item := range rootfs.GetIncludeDirs() { |
| 344 | includeDir := filepath.Join(sysrootDir, item) |
| 345 | b.appendIncludeDir(includeDir) |
| 346 | } |
| 347 | |
| 348 | // Update LDFLAGS |
| 349 | // Add dependency lib dir first (so it takes higher priority than sysroot lib dirs). |
| 350 | b.appendLibDir(filepath.Join(tmpDepsDir, "lib")) |
| 351 | |
| 352 | // Add sysroot lib dirs. |
| 353 | for _, item := range rootfs.GetLibDirs() { |
| 354 | libDir := filepath.Join(sysrootDir, item) |
| 355 | if fileio.PathExists(libDir) { |
| 356 | b.appendLibDir(libDir) |
| 357 | } |
| 358 | } |
| 359 | } else { |
| 360 | // Update CFLAGS/CXXFLAGS/LDFLAGS |
| 361 | b.appendIncludeDir(filepath.Join(tmpDepsDir, "include")) |
| 362 | b.appendLibDir(filepath.Join(tmpDepsDir, "lib")) |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | func (b BuildConfig) rollbackEnvs() { |
| 367 | b.envBackup.rollback() |
no test coverage detected