[bazel] Add subpackages for libc/src/... (#242489)
This PR creates subpackages for `libc/src/...` as part of
https://github.com/llvm/llvm-project/issues/238076.
`alias` targets are left for compatibility so that downstream targets do
not need to be updated in lock step w/ this PR.
The refactor was almost entirely generated by a one-off tool
[jtstogel/bazel-move-targets](https://github.com/jtstogel/bazel-move-targets)@1e51f7f
(LLM-written), since I couldn't find any standard tooling for this kind
of thing.
Generated with commands:
```
function new-pkg() {
pkg=$1
shift
local args
if [[ $# -gt 0 ]]; then
# If there's more than just a package name, pass the args verbatim.
args=("${@}")
else
# Derive the target prefix that LLVM-libc conventionally uses.
# libc/src/__support/CPP -> __support_cpp
prefix=$(tr '[:upper:]/' '[:lower:]_' <<< "${pkg#libc/src/}")
args=(--rename_strip_package_prefix="${prefix}_")
fi
bazel-move-targets move \
--workspace_root=utils/bazel/llvm-project-overlay \
--alias_for_rule_kind=libc_function \
--src_package=libc \
--dst_package=$pkg \
"${args[@]}"
jj commit -m "[bazel] Add subpackage for $pkg"
}
new-pkg libc/src/arpa/inet
new-pkg libc/src/compiler
new-pkg libc/src/complex
new-pkg libc/src/ctype
new-pkg libc/src/errno
new-pkg libc/src/fcntl
new-pkg libc/src/fenv
new-pkg libc/src/link
new-pkg libc/src/poll
new-pkg libc/src/sched --rename_strip_package_prefix=
new-pkg libc/src/signal
new-pkg libc/src/stdio
new-pkg libc/src/stdlib
new-pkg libc/src/string/memory_utils --rename_strip_package_prefix=string_
new-pkg libc/src/string
new-pkg libc/src/strings
new-pkg libc/src/sys/epoll
new-pkg libc/src/sys/mman
new-pkg libc/src/sys/prctl
new-pkg libc/src/sys/random
new-pkg libc/src/sys/resource
new-pkg libc/src/sys/sem
new-pkg libc/src/sys/sendfile
new-pkg libc/src/sys/socket
new-pkg libc/src/sys/stat
new-pkg libc/src/sys/uio
new-pkg libc/src/sys/utsname
new-pkg libc/src/sys/wait
new-pkg libc/src/time
new-pkg libc/src/unistd
new-pkg libc/src/wchar
```