at master 1.0 kB view raw
1# Add import paths for build inputs. 2swiftWrapper_addImports () { 3 # Include subdirectories following both the Swift platform convention, and 4 # a simple `lib/swift` for Nix convenience. 5 for subdir in @swiftModuleSubdir@ @swiftStaticModuleSubdir@ lib/swift; do 6 if [[ -d "$1/$subdir" ]]; then 7 export NIX_SWIFTFLAGS_COMPILE+=" -I $1/$subdir" 8 fi 9 done 10 for subdir in @swiftLibSubdir@ @swiftStaticLibSubdir@ lib/swift; do 11 if [[ -d "$1/$subdir" ]]; then 12 export NIX_LDFLAGS+=" -L $1/$subdir" 13 fi 14 done 15} 16 17addEnvHooks "$targetOffset" swiftWrapper_addImports 18 19# Use a postHook here because we rely on NIX_CC, which is set by the cc-wrapper 20# setup hook, so delay until we're sure it was run. 21swiftWrapper_postHook () { 22 # On Darwin, libc also contains Swift modules. 23 if [[ -e "$NIX_CC/nix-support/orig-libc" ]]; then 24 swiftWrapper_addImports "$(<$NIX_CC/nix-support/orig-libc)" 25 fi 26} 27 28postHooks+=(swiftWrapper_postHook)