Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IWYU support (part 5): Yet more SDL fixes #27810

Merged
merged 2 commits into from
Jan 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion doc/DEVELOPER_TOOLING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
## Astyle

Automatic formatting is performed by astyle. If you have make and astyle
installed then this can be done with 'make astyle'.
installed then this can be done with `make astyle`.

On Windows, there is an astyle extension for Visual Studio.

## JSON style

See the [JSON style guide](JSON_STYLE.md).

## include-what-you-use

[include-what-you-use](https://github.com/include-what-you-use/include-what-you-use)
Expand All @@ -28,6 +32,15 @@ Then run:
iwyu_tool.py -p $CMAKE_BUILD_DIR/compile_commands.json -- -Xiwyu --mapping_file=$PWD/tools/iwyu/cata.imp | fix_includes.py --nosafe_headers
```

There are mapping files in `tools/iwyu` intended to help IWYU pick the right
headers. Mostly they should be fairly obvious, but the SDL mappings might
warrant further explanation. We want to force most SDL includes to go via
`sdl_wrappers.h`, because that handles the platform-dependence issues (the
include paths are different on Windows). There are a couple of exceptions
(`SDL_version.h` and `SDL_mixer.h`). The former is because `main.cpp` can't
include all SDL headers, because they `#define WinMain`. All the mappings in
`sdl.imp` are designed to make this happen.

We have to use IWYU pragmas in some situations. Some of the reasons are:

* IWYU has a concept of [associated
Expand Down
19 changes: 19 additions & 0 deletions tools/iwyu/sdl.imp
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,23 @@
{ include: ["\"SDL_timer.h\"", "private", "<SDL.h>", "public"] },
{ include: ["\"SDL_version.h\"", "public", "<SDL.h>", "public"] },
{ include: ["\"SDL_video.h\"", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_Init", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_InitSubSystem", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_Quit", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_INIT_AUDIO", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_INIT_JOYSTICK", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_INIT_TIMER", "private", "<SDL.h>", "public"] },
{ symbol: ["SDL_INIT_VIDEO", "private", "<SDL.h>", "public"] },
{ symbol: ["TTF_OpenFontIndex", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_FontFaceStyleName", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_FontFaces", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_FontFaceFamilyName", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_FontHeight", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_Init", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_OpenFont", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_SetFontStyle", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_GetError", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_RenderUTF8_Blended", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_RenderUTF8_Solid", "private", "<SDL_ttf.h>", "public"] },
{ symbol: ["TTF_STYLE_NORMAL", "private", "<SDL_ttf.h>", "public"] },
]