diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2020-03-30 08:28:32 +0200 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2020-03-30 09:05:53 +0200 |
commit | cd4e46ee65dab6baa6a143bf3b3f64244be36712 (patch) | |
tree | 689e53265691e782ae35a961445c975219e1155d /drivers/vulkan/SCsub | |
parent | 0168709978154a89f137b44f33647e5d28a46250 (diff) |
SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.
psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:
- Manually wrapped strings will be reflowed, so by using a line length
of 120 for the sake of preserving readability for our long command
calls, it also means that some manually wrapped strings are back on
the same line and should be manually merged again.
- Code generators using string concatenation extensively look awful,
since black puts each operand on a single line. We need to refactor
these generators to use more pythonic string formatting, for which
many options are available (`%`, `format` or f-strings).
- CI checks and a pre-commit hook will be added to ensure that future
buildsystem changes are well-formatted.
Diffstat (limited to 'drivers/vulkan/SCsub')
-rw-r--r-- | drivers/vulkan/SCsub | 88 |
1 files changed, 48 insertions, 40 deletions
diff --git a/drivers/vulkan/SCsub b/drivers/vulkan/SCsub index de776b19b2..7ffdac27d5 100644 --- a/drivers/vulkan/SCsub +++ b/drivers/vulkan/SCsub @@ -1,10 +1,10 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.drivers_sources, "*.cpp") -if env['builtin_vulkan']: +if env["builtin_vulkan"]: # Use bundled Vulkan headers thirdparty_dir = "#thirdparty/vulkan" env.Prepend(CPPPATH=[thirdparty_dir, thirdparty_dir + "/include", thirdparty_dir + "/loader"]) @@ -27,48 +27,56 @@ if env['builtin_vulkan']: ] vma_sources = [thirdparty_dir + "/vk_mem_alloc.cpp"] - if env['platform'] == "windows": + if env["platform"] == "windows": loader_sources.append("dirent_on_windows.c") loader_sources.append("dxgi_loader.c") - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_WIN32_KHR', - 'VULKAN_NON_CMAKE_BUILD', - 'WIN32_LEAN_AND_MEAN', - 'API_NAME=\\"%s\\"' % 'Vulkan' - ]) - if not env.msvc: # Windows 7+, missing in mingw headers - env_thirdparty.AppendUnique(CPPDEFINES=[ - "CM_GETIDLIST_FILTER_CLASS=0x00000200", - "CM_GETIDLIST_FILTER_PRESENT=0x00000100" - ]) - elif env['platform'] == "osx": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_MACOS_MVK', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) - elif env['platform'] == "iphone": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_IOS_MVK', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) - elif env['platform'] == "linuxbsd": - env_thirdparty.AppendUnique(CPPDEFINES=[ - 'VK_USE_PLATFORM_XLIB_KHR', - 'VULKAN_NON_CMAKE_BUILD', - 'SYSCONFDIR=\\"%s\\"' % '/etc', - 'FALLBACK_DATA_DIRS=\\"%s\\"' % '/usr/local/share:/usr/share', - 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % '/etc/xdg' - ]) + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_WIN32_KHR", + "VULKAN_NON_CMAKE_BUILD", + "WIN32_LEAN_AND_MEAN", + 'API_NAME=\\"%s\\"' % "Vulkan", + ] + ) + if not env.msvc: # Windows 7+, missing in mingw headers + env_thirdparty.AppendUnique( + CPPDEFINES=["CM_GETIDLIST_FILTER_CLASS=0x00000200", "CM_GETIDLIST_FILTER_PRESENT=0x00000100"] + ) + elif env["platform"] == "osx": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_MACOS_MVK", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) + elif env["platform"] == "iphone": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_IOS_MVK", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) + elif env["platform"] == "linuxbsd": + env_thirdparty.AppendUnique( + CPPDEFINES=[ + "VK_USE_PLATFORM_XLIB_KHR", + "VULKAN_NON_CMAKE_BUILD", + 'SYSCONFDIR=\\"%s\\"' % "/etc", + 'FALLBACK_DATA_DIRS=\\"%s\\"' % "/usr/local/share:/usr/share", + 'FALLBACK_CONFIG_DIRS=\\"%s\\"' % "/etc/xdg", + ] + ) import platform - if (platform.system() == "Linux"): + + if platform.system() == "Linux": # In glibc since 2.17 and musl libc since 1.1.24. Used by loader.c. - env_thirdparty.AppendUnique(CPPDEFINES=['HAVE_SECURE_GETENV']) + env_thirdparty.AppendUnique(CPPDEFINES=["HAVE_SECURE_GETENV"]) loader_sources = [thirdparty_dir + "/loader/" + file for file in loader_sources] env_thirdparty.add_source_files(env.drivers_sources, loader_sources) |