diff options
Diffstat (limited to 'xmake.lua')
-rw-r--r-- | xmake.lua | 180 |
1 files changed, 144 insertions, 36 deletions
@@ -4,8 +4,6 @@ set_config("cc", "gcc") add_rules("mode.debug", "mode.release") -- we have two modes: debug & release -add_syslinks("m") -- these are must have when compiling - -- -Wall : base set of warnings -- -Wextra : additional warnings not covered by -Wall -- -Wundef : undefined macros @@ -14,6 +12,7 @@ add_cflags("-Wall", "-Wextra", "-Wundef", "-Wdouble-promotion") if is_mode("debug") then add_cflags("-g") -- Add debug symbols in debug mode + add_defines("CDEBUG") elseif is_mode("release") then add_defines("CRELEASE") end @@ -22,9 +21,13 @@ end -- Platform defines and system packages if is_plat("linux") then add_defines("CEL_PLATFORM_LINUX") - add_syslinks("dl", "X11", "pthread") + add_syslinks("vulkan", "dl", "X11", "pthread") elseif is_plat("windows") then add_defines("CEL_PLATFORM_WINDOWS") + add_syslinks("user32", "gdi32", "kernel32", "shell32") + add_requires("vulkansdk", {system=true}) + + -- add_links("pthreadVC2-w64") elseif is_plat("macosx") then add_defines("CEL_PLATFORM_MAC") add_frameworks("Cocoa", "IOKit", "CoreVideo", "OpenGL") @@ -53,8 +56,10 @@ add_requires("local_glfw") local core_sources = { "deps/glad/src/glad.c", "src/*.c", - "src/logos/*.c", + -- "src/logos/*.c", + "src/maths/*.c", "src/platform/*.c", + "src/physics/*.c", "src/renderer/*.c", "src/renderer/backends/*.c", "src/resources/*.c", @@ -63,10 +68,37 @@ local core_sources = { "src/systems/*.c", } +local unity_sources = { + "deps/Unity/src/unity.c", + "deps/Unity/extras/fixture/src/unity_fixture.c", + "deps/Unity/extras/memory/src/unity_memory.c", +} + +rule("compile_glsl_vert_shaders") + set_extensions(".vert") + on_buildcmd_file(function (target, batchcmds, sourcefile, opt) + local targetfile = path.join(target:targetdir(), path.basename(sourcefile) .. ".vert.spv") + + print("Compiling shader: %s to %s", sourcefile, targetfile) + batchcmds:vrunv('glslc', {sourcefile, "-o", targetfile}) + -- batchcmds:add_depfiles(sourcefile) +end) +rule("compile_glsl_frag_shaders") + set_extensions(".frag") + on_buildcmd_file(function (target, batchcmds, sourcefile, opt) + local targetfile = path.join(target:targetdir(), path.basename(sourcefile) .. ".frag.spv") + + print("Compiling shader: %s to %s", sourcefile, targetfile) + batchcmds:vrunv('glslc', {sourcefile, "-o", targetfile}) + -- batchcmds:add_depfiles(sourcefile) +end) +-- TODO: Metal shaders compilation + +-- + -- common configuration for both static and shared libraries target("core_config") set_kind("static") -- kind is required but you can ignore it since it's just for common settings - add_syslinks("dl") add_packages("local_glfw") add_includedirs("deps/cgltf", {public = true}) add_includedirs("deps/glfw-3.3.8/include/GLFW", {public = true}) @@ -75,9 +107,10 @@ target("core_config") add_includedirs("deps/stb_image_write", {public = true}) add_includedirs("deps/stb_truetype", {public = true}) add_includedirs("src/", {public = true}) - add_includedirs("src/logos/", {public = true}) + -- add_includedirs("src/logos/", {public = true}) add_includedirs("src/maths/", {public = true}) add_includedirs("src/platform/", {public = true}) + add_includedirs("src/physics/", {public = true}) add_includedirs("src/renderer/", {public = true}) add_includedirs("src/renderer/backends/", {public = true}) add_includedirs("src/resources/", {public = true}) @@ -85,6 +118,18 @@ target("core_config") add_includedirs("src/std/containers", {public = true}) add_includedirs("src/systems/", {public = true}) add_files("src/empty.c") -- for some reason we need this on Mac so it doesnt call 'ar' with no files and error + add_rules("compile_glsl_vert_shaders") + add_rules("compile_glsl_frag_shaders") + add_files("assets/shaders/triangle.vert") + add_files("assets/shaders/triangle.frag") + add_files("assets/shaders/cube.vert") + add_files("assets/shaders/cube.frag") + -- add_files("assets/shaders/*.frag") + if is_plat("windows") then + add_includedirs("$(env VULKAN_SDK)/Include", {public = true}) + add_linkdirs("$(env VULKAN_SDK)/Lib", {public = true}) + add_links("vulkan-1") + end set_default(false) -- prevents standalone building of this target target("core_static") @@ -92,50 +137,113 @@ target("core_static") add_deps("core_config") -- inherit common configurations set_policy("build.merge_archive", true) add_files(core_sources) + -- Link against static CRT + if is_plat("windows") then + add_links("libcmt", "legacy_stdio_definitions") -- for release builds + add_links("libcmtd", "legacy_stdio_definitions") -- for debug builds + end target("core_shared") set_kind("shared") add_deps("core_config") -- inherit common configurations add_files(core_sources) - -target("main_loop") - set_kind("binary") - set_group("examples") - add_deps("core_shared") - add_files("examples/main_loop/ex_main_loop.c") - set_rundir("$(projectdir)") - -target("std") + -- Link against dynamic CRT + if is_plat("windows") then + add_links("msvcrt", "legacy_stdio_definitions") -- for release builds + add_links("msvcrtd", "legacy_stdio_definitions") -- for debug builds + end + +-- target("main_loop") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/main_loop/ex_main_loop.c") +-- set_rundir("$(projectdir)") + +target("tri") set_kind("binary") set_group("examples") add_deps("core_static") - add_files("examples/standard_lib/ex_std.c") + add_files("examples/triangle/ex_triangle.c") set_rundir("$(projectdir)") -target("obj") +target("cube") set_kind("binary") set_group("examples") add_deps("core_static") - add_files("examples/obj_loading/ex_obj_loading.c") + add_files("examples/cube/ex_cube.c") set_rundir("$(projectdir)") -target("gltf") +-- target("std") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/standard_lib/ex_std.c") +-- set_rundir("$(projectdir)") + +-- target("obj") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/obj_loading/ex_obj_loading.c") +-- set_rundir("$(projectdir)") + +-- target("input") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/input/ex_input.c") +-- set_rundir("$(projectdir)") + +-- target("gltf") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/gltf_loading/ex_gltf_loading.c") +-- set_rundir("$(projectdir)") + +-- target("transforms") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_shared") +-- add_files("examples/transforms/ex_transforms.c") +-- set_rundir("$(projectdir)") + +-- target("animation") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_shared") +-- add_files("examples/property_animation/ex_property_animation.c") +-- set_rundir("$(projectdir)") + +-- target("skinned") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_shared") +-- add_files("examples/skinned_animation/ex_skinned_animation.c") +-- set_rundir("$(projectdir)") + +-- target("input") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/input/ex_input.c") +-- set_rundir("$(projectdir)") + +-- target("demo") +-- set_kind("binary") +-- set_group("examples") +-- add_deps("core_static") +-- add_files("examples/demo/demo.c") +-- set_rundir("$(projectdir)") + +target("pool_tests") set_kind("binary") - set_group("examples") + set_group("tests") add_deps("core_static") - add_files("examples/gltf_loading/ex_gltf_loading.c") - set_rundir("$(projectdir)") - -target("transforms") - set_kind("binary") - set_group("examples") - add_deps("core_shared") - add_files("examples/transforms/ex_transforms.c") - set_rundir("$(projectdir)") - -target("demo") - set_kind("binary") - set_group("examples") - add_deps("core_static") - add_files("examples/demo/demo.c") - set_rundir("$(projectdir)") + add_files(unity_sources) + add_includedirs("deps/Unity/src", {public = true}) + add_includedirs("deps/Unity/extras/fixture/src", {public = true}) + add_includedirs("deps/Unity/extras/memory/src", {public = true}) + add_files("tests/pool_tests.c") + add_files("tests/pool_test_runner.c") |