depot/third_party/nixpkgs/pkgs/development/compilers/swift/wrapper/setup-hook.sh
Default email a0cb138ada Project import generated by Copybara.
GitOrigin-RevId: a100acd7bbf105915b0004427802286c37738fef
2023-02-02 18:25:31 +00:00

28 lines
1,003 B
Bash

# Add import paths for build inputs.
swiftWrapper_addImports () {
# Include subdirectories following both the Swift platform convention, and
# a simple `lib/swift` for Nix convenience.
for subdir in @swiftModuleSubdir@ @swiftStaticModuleSubdir@ lib/swift; do
if [[ -d "$1/$subdir" ]]; then
export NIX_SWIFTFLAGS_COMPILE+=" -I $1/$subdir"
fi
done
for subdir in @swiftLibSubdir@ @swiftStaticLibSubdir@ lib/swift; do
if [[ -d "$1/$subdir" ]]; then
export NIX_LDFLAGS+=" -L $1/$subdir"
fi
done
}
addEnvHooks "$targetOffset" swiftWrapper_addImports
# Use a postHook here because we rely on NIX_CC, which is set by the cc-wrapper
# setup hook, so delay until we're sure it was run.
swiftWrapper_postHook () {
# On Darwin, libc also contains Swift modules.
if [[ -e "$NIX_CC/nix-support/orig-libc" ]]; then
swiftWrapper_addImports "$(<$NIX_CC/nix-support/orig-libc)"
fi
}
postHooks+=(swiftWrapper_postHook)