require "ecc/ecc"
require "ninja/ninja"

workspace "snake"
	architecture "x64"
	startproject"snake"
	configurations
	{
		"Debug",
		"Release"
	}

	filter "action:vs*"
		project_dir = "$(SolutionDir)"

	filter "system:windows"
		project_dir = "%{wks.location}/"

	group "Dependencies"
		include "vendor/ogg/build-ogg.lua"
		include "vendor/vorbis/build-vorbis.lua"
		include "vendor/flac/build-flac.lua"
		include "vendor/freetype/build-freetype.lua"
		include "vendor/sfml/build-sfml.lua"

	group""

	project "snake"
		output_dir = "%{cfg.buildcfg}-%{cfg.system}-%{cfg.architecture}"
		intdir = project_dir .. "intermediate-files/" .. output_dir
		bindir = project_dir .. "bin/" .. output_dir
		sfmldir = project_dir .. "vendor/SFML"
		imguidir = project_dir .. "vendor/imgui"
		include_dir = project_dir .. "include"

		language "C++"
		cppdialect "C++20"
		systemversion "latest"
		kind "WindowedApp"
		targetname "snake"
		targetdir (bindir)
		objdir (intdir)
		debugdir (project_dir)
		links {"sfml"}
		includedirs
		{
			"src",
			include_dir,
			sfmldir .. "/include",
			imguidir
		}

		libdirs (sfmldir .. "/build/lib")

		files 
		{
			"src/**.cpp",
			"include/**.h",
			"include/**.hpp",
			"vendor/imgui/imgui.cpp",
			"vendor/imgui/imgui_draw.cpp",
			"vendor/imgui/imgui_tables.cpp",
			"vendor/imgui/imgui_widgets.cpp",
			"vendor/imgui/imgui-SFML.cpp"
		}

		--windows specific settings--
		filter{"system:windows"}
			defines {"PLATFORM_WINDOWS", "SFML_STATIC"}
			staticruntime "off"

		filter {"system:windows", "configurations:debug"}
			defines{"_DEBUG", "_CONSOLE"}
			links 
			{
				"legacy_stdio_definitions",
				"opengl32",
				"gdi32",
				"winmm",
				"ws2_32"
			}
			
		filter {"system:windows", "configurations:release"}
			defines{"NDEBUG"}
			links 
			{
				"opengl32",
				"gdi32",
				"winmm"
			}


		--linux specific settings--
		filter {"system:linux"}
			defines {"PLATFORM_LINUX"}
			
			links 
			{
				"sfml-graphics-s",
				"sfml-window-s",
				"sfml-audio-s",
				"sfml-system-s",
				"Xi",
				"Xrandr",
				"Xcursor",
				"freetype",
				"X11",
				"udev",
				"FLAC",
				"ogg",
				"vorbis",
				"vorbisenc",
				"vorbisfile",
				"pthread",
				"OpenGL",
			}

			
		--config settings--
		filter "configurations:debug"
			defines {"LOG_ENABLE", "GAME_DEBUG"}
			symbols "on"
			runtime "Debug"
			warnings "Extra"
			
		filter "configurations:release"
			defines {"GAME_RELEASE"}
			optimize "Speed"
			inlining "Auto"
			symbols "off"
			runtime "Release"