-
Notifications
You must be signed in to change notification settings - Fork 1
/
adjust-angle-include-paths-rule
executable file
·38 lines (35 loc) · 1.75 KB
/
adjust-angle-include-paths-rule
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/bin/sh
# WebKit builds ANGLE as a static library, and exports some of the
# internal header files as "public headers" in the Xcode project for
# consumption by other build targets - e.g. WebCore.
#
# The build phase which copies these headers also flattens the
# directory structure (so that "ANGLE" is the top-level directory
# containing all of them - e.g., "#include <ANGLE/gl2.h>").
#
# It isn't practical to override the include paths so drastically for
# the other build targets (like WebCore) that we could make the
# original include paths, like <GLES2/gl2.h> work. Changing them so
# their namespace is "ANGLE", which implicitly occurs during the "copy
# headers" phase, is a reasonable solution.
#
# This script processes the header files after they're copied during
# the Copy Header Files build phase, and adjusts their #includes so
# that they refer to each other. This avoids modifying the ANGLE
# sources, and allows WebCore to more easily call ANGLE APIs directly.
if [[ -n "${SCRIPT_HEADER_VISIBILITY}" ]]
then
SOURCE_FILE="${SCRIPT_INPUT_FILE}"
WORK_FILE="${SCRIPT_OUTPUT_FILE_0}.tmp"
DEST_FILE="${SCRIPT_OUTPUT_FILE_0}"
sed \
-e 's/^#include [<"]EGL\/\(.*\)[>"]/#include <ANGLE\/\1>/' \
-e 's/^#include [<"]\(\.\.\/\)*GLES[23]*\/\(.*\)[>"]/#include <ANGLE\/\2>/' \
-e 's/^#include [<"]KHR\/\(.*\)[>"]/#include <ANGLE\/\1>/' \
-e 's/^#include [<"]export.h[>"]/#include <ANGLE\/export.h>/' \
-e 's/^#include "\(eglext_angle\|gl2ext_angle\|ShaderVars\).h"/#include <ANGLE\/\1.h>/' \
"${SOURCE_FILE}" > "${WORK_FILE}"
cmp -s "${WORK_FILE}" "${DEST_FILE}" && rm -f "${WORK_FILE}" || mv "${WORK_FILE}" "${DEST_FILE}"
[[ "${SOURCE_FILE}" -nt "${DEST_FILE}" ]] && touch "${DEST_FILE}" || true
fi
exit 0