mirror of https://github.com/libsdl-org/SDL
Add SDL_migration.cocci for SDL2 to 3 migration (#7042)
* Add SDL_migration.cocci for SDL2 to 3 migration
This commit is contained in:
parent
413af2f5f1
commit
5066fcde69
File diff suppressed because it is too large
Load Diff
|
@ -14,6 +14,7 @@ from rename_symbols import create_regex_from_replacements, replace_symbols_in_pa
|
|||
SDL_ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
|
||||
SDL_INCLUDE_DIR = SDL_ROOT / "include/SDL3"
|
||||
SDL_BUILD_SCRIPTS = SDL_ROOT / "build-scripts"
|
||||
|
||||
|
||||
def main():
|
||||
|
@ -63,6 +64,7 @@ def main():
|
|||
|
||||
add_symbol_to_oldnames(header.name, oldname, newname)
|
||||
add_symbol_to_migration(header.name, args.type, oldname, newname)
|
||||
add_symbol_to_coccinelle(args.type, oldname, newname)
|
||||
i += 2
|
||||
|
||||
|
||||
|
@ -83,6 +85,18 @@ def add_content(lines, i, content, add_trailing_line):
|
|||
return i
|
||||
|
||||
|
||||
def add_symbol_to_coccinelle(symbol_type, oldname, newname):
|
||||
file = open(SDL_BUILD_SCRIPTS / "SDL_migration.cocci", "a")
|
||||
# Append-adds at last
|
||||
file.write("@@\n")
|
||||
file.write("@@\n")
|
||||
file.write("- %s\n" % oldname)
|
||||
file.write("+ %s\n" % newname)
|
||||
if symbol_type == "function":
|
||||
file.write(" (...)\n")
|
||||
file.close()
|
||||
|
||||
|
||||
def add_symbol_to_oldnames(header, oldname, newname):
|
||||
file = (SDL_INCLUDE_DIR / "SDL_oldnames.h")
|
||||
lines = file.read_text().splitlines()
|
||||
|
|
|
@ -9,6 +9,9 @@ Many functions and symbols have been renamed. We have provided a handy Python sc
|
|||
rename_symbols.py --all-symbols source_code_path
|
||||
```
|
||||
|
||||
It's also possible to apply a semantic patch to migrate more easily to SDL3: [SDL_migration.cocci](https://github.com/libsdl-org/SDL/blob/main/build-scripts/SDL_migration.cocci)
|
||||
|
||||
|
||||
SDL headers should now be included as `#include <SDL3/SDL.h>`. Typically that's the only header you'll need in your application unless you are using OpenGL or Vulkan functionality. We have provided a handy Python script [rename_headers.py](https://github.com/libsdl-org/SDL/blob/main/build-scripts/rename_headers.py) to rename SDL2 headers to their SDL3 counterparts:
|
||||
```sh
|
||||
rename_headers.py source_code_path
|
||||
|
|
Loading…
Reference in New Issue