about summary refs log blame commit diff stats
path: root/premake5.lua
blob: a24e05682af08260d612fcfc453fba4a5e79b7c3 (plain) (tree)




























                                                                           
                                    





                                                                                         
                                              




                                       
                                          
                                                       
                                             
                                                          

                                                                                       
                                                       

                                                               
                                                          


                                                                                            

                                                                                           


                                                         
 



                                                    
                                                   

                                                                          

           
 








                                                                


                                                                        

           
workspace("Pong")
    configurations {"Debug", "Release"}

project("Pong")
    kind("WindowedApp")
    language("C")
    files {"src/*.c", "src/*.h", }
    includedirs {"raylib/src"}
    -- Prefix Option
    newoption {
        trigger     = "prefix",
        value       = "path",
        description = "Prefix for where the game is to be installed."
    }
    prefix = _OPTIONS["prefix"] or "app"

    -- Flatpak
    newoption {
        trigger     = "flatpak",
        value       = "bool",
        description = "Build a flatpak."
    }
    flatpak = _OPTIONS["flatpak"] or "false"

    -- Find raylib
    RaylibStaticLibrary = os.findlib("libraylib.a", "raylib", "raylib/src")
    if(RaylibStaticLibrary == nil) then
        os.exit(1)
    end
    libdirs {"raylib", "raylib/src"}

    -- Detect OS
    if(os.ishost("linux") == true) then
        links {RaylibStaticLibrary, "m", "pthread", "dl"}
    elseif(os.ishost("bsd") == true) then
        print("It is required you build raylib to an external glfw library when on bsd.")
        linkoptions {"`pkgconf --libs glfw3`"}
        -- Which BSD?
        BSD_OS = io.popen("uname")
        BSD_OS_NAME = BSD_OS:read("*a")
        BSD_OS:close()
        -- Check Result
        if(BSD_OS_NAME == "NetBSD\n") then
            links {RaylibStaticLibrary, "m", "pthread"}
        elseif(BSD_OS_NAME == "freebsd") then
            links {RaylibStaticLibrary, "m", "stdthreads"}
        elseif(BSD_OS_NAME == "openbsd") then
            print("Openbsd doesn't work currently due to lack of c11 threads support.")
            links {RaylibStaticLibrary, "m", "pthread"}
        else
            print("Couldn't figure out BSD, assuming freebsd.")
            links {RaylibStaticLibrary, "m", "stdthreads"}
        end
    elseif(os.ishost("windows") == true) then
        print("This script is expecting a MSYS2 or Cygwin environment. You've been warned.")
        links {RaylibStaticLibrary, "-lopengl32", "-lgdi32", "-lwinmm", "-lpthread", "-lm"}
        includedirs {"raylib/src", "src/windows"}
    else
        links {RaylibStaticLibrary, "m", "pthread", "dl"}
    end

    newaction {
        trigger = "install",
        description = "Install the game to prefix.",
        execute = function()
            os.executef("mkdir -p %s/Pong", prefix)
            os.executef("cp -rv resources/ %s/Pong/", prefix)
            os.executef("install -Dvm755 bin/*/Pong %s/Pong/pong", prefix)
        end
    }

    newaction {
        trigger = "clean",
        description = "Clean the work environment.",
        execute = function()
            os.executef("rm -rvf %s/obj", _MAIN_SCRIPT_DIR)
            os.executef("rm -rvf %s/bin", _MAIN_SCRIPT_DIR)
            os.executef("rm -rvf %s/app", _MAIN_SCRIPT_DIR)
            os.executef("rm -vf %s/Makefile", _MAIN_SCRIPT_DIR)
            os.executef("rm -vf %s/Pong.make", _MAIN_SCRIPT_DIR)
            os.executef("rm -rvf %s/flatpak_repo", _MAIN_SCRIPT_DIR)
            os.executef("rm -rvf %s/.flatpak-builder", _MAIN_SCRIPT_DIR)
            os.executef("rm -rvf %s/build-dir", _MAIN_SCRIPT_DIR)
        end
    }