Last active
September 10, 2020 09:39
-
-
Save cdlm/10d5872f6a310586188bcb559743215e to your computer and use it in GitHub Desktop.
Resolve C includes and header files.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
function list-headers() { | |
local source="${1:--}" | |
cc -E -H "$source" 2>&1 1>/dev/null \ | |
| sed ' | |
# ignore recursive includes | |
/^\.\./d | |
# remove depth indication from 1st level includes | |
s/^\. \(.*\)/\1/ | |
' | |
} | |
list-headers "$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
function find-include() { | |
local include="${1?Missing include name}" | |
echo "#include <${include}>" | headers - | |
} | |
find-include "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment