Lua formatting

In one of the last viewer PRs I added in a lua formatter config file.

It works off of [LuaFormatter](https://github.com/Koihik/LuaFormatter) (think clang-format for lua).

It helps our premake5.lua files look more consistent and auto formats them for us.

The only trick to "help it along" is to scope filter, project, etc sections with lua do end blocks. This is purely cosmetic but I find it keeps the scope of the filter really clear. Similar to adding commas in dart to help the formatter reflow indentation.

Open to suggestions, I already I applied this style to the premake5_viewer.lua config file, but I included an example of the newly formatted premake5_tess.lua file with this PR.

Diffs=
412ab8f4d Lua formatting
This commit is contained in:
luigi-rosso
2022-07-19 18:43:35 +00:00
parent 5506f4dd56
commit 6cddb4f519
2 changed files with 82 additions and 64 deletions

View File

@@ -1,86 +1,104 @@
workspace "rive"
configurations {"debug", "release"}
workspace 'rive'
configurations {'debug', 'release'}
dependencies = os.getenv("DEPENDENCIES")
dependencies = os.getenv('DEPENDENCIES')
rive = "../../";
rive = '../../'
dofile(path.join(path.getabsolute(rive) .. "/build", "premake5.lua"))
dofile(path.join(path.getabsolute(rive) .. '/build', 'premake5.lua'))
project "rive_tess_renderer"
kind "StaticLib"
language "C++"
cppdialect "C++17"
toolset "clang"
targetdir "%{cfg.system}/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/obj/%{cfg.buildcfg}"
project 'rive_tess_renderer'
do
kind 'StaticLib'
language 'C++'
cppdialect 'C++17'
toolset 'clang'
targetdir '%{cfg.system}/bin/%{cfg.buildcfg}'
objdir '%{cfg.system}/obj/%{cfg.buildcfg}'
includedirs {
"../include",
rive .. "/include",
dependencies .. "/sokol"
'../include',
rive .. '/include',
dependencies .. '/sokol'
}
files {
"../src/**.cpp",
'../src/**.cpp'
}
buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti", "-Werror=format"}
defines {"CONTOUR_RECURSIVE"}
buildoptions {'-Wall', '-fno-exceptions', '-fno-rtti', '-Werror=format'}
defines {'CONTOUR_RECURSIVE'}
filter "configurations:debug"
buildoptions {"-g"}
defines {"DEBUG"}
symbols "On"
filter 'configurations:debug'
do
buildoptions {'-g'}
defines {'DEBUG'}
symbols 'On'
end
filter "configurations:release"
buildoptions {"-flto=full"}
defines {"RELEASE", "NDEBUG"}
optimize "On"
filter 'configurations:release'
do
buildoptions {'-flto=full'}
defines {'RELEASE', 'NDEBUG'}
optimize 'On'
end
filter { "options:graphics=gl" }
defines {"SOKOL_GLCORE33"}
filter { "options:graphics=metal" }
defines {"SOKOL_METAL"}
filter { "options:graphics=d3d" }
defines {"SOKOL_D3D11"}
filter {'options:graphics=gl'}
do
defines {'SOKOL_GLCORE33'}
end
filter {'options:graphics=metal'}
do
defines {'SOKOL_METAL'}
end
filter {'options:graphics=d3d'}
do
defines {'SOKOL_D3D11'}
end
newoption {
trigger = "graphics",
value = "gl",
description = "The graphics api to use.",
trigger = 'graphics',
value = 'gl',
description = 'The graphics api to use.',
allowed = {
{ "gl" },
{ "metal" },
{ "d3d" }
{'gl'},
{'metal'},
{'d3d'}
}
}
end
project "rive_tess_tests"
kind "ConsoleApp"
language "C++"
cppdialect "C++17"
toolset "clang"
targetdir "%{cfg.system}/bin/%{cfg.buildcfg}"
objdir "%{cfg.system}/obj/%{cfg.buildcfg}"
project 'rive_tess_tests'
do
kind 'ConsoleApp'
language 'C++'
cppdialect 'C++17'
toolset 'clang'
targetdir '%{cfg.system}/bin/%{cfg.buildcfg}'
objdir '%{cfg.system}/obj/%{cfg.buildcfg}'
includedirs {
"../../dev/test/include",
"../include",
rive .. "/include",
dependencies .. "/sokol"
'../../dev/test/include',
'../include',
rive .. '/include',
dependencies .. '/sokol'
}
files {
"../test/**.cpp",
'../test/**.cpp'
}
links { "rive_tess_renderer" }
buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti", "-Werror=format"}
defines {"TESTING"}
links {'rive_tess_renderer'}
buildoptions {'-Wall', '-fno-exceptions', '-fno-rtti', '-Werror=format'}
defines {'TESTING'}
filter "configurations:debug"
buildoptions {"-g"}
defines {"DEBUG"}
symbols "On"
filter 'configurations:debug'
do
buildoptions {'-g'}
defines {'DEBUG'}
symbols 'On'
end
filter "configurations:release"
buildoptions {"-flto=full"}
defines {"RELEASE", "NDEBUG"}
optimize "On"
filter 'configurations:release'
do
buildoptions {'-flto=full'}
defines {'RELEASE', 'NDEBUG'}
optimize 'On'
end
end