about summary refs log tree commit diff stats
path: root/premake5.lua
diff options
context:
space:
mode:
Diffstat (limited to 'premake5.lua')
-rw-r--r--premake5.lua80
1 files changed, 80 insertions, 0 deletions
diff --git a/premake5.lua b/premake5.lua
new file mode 100644
index 0000000..1f312d1
--- /dev/null
+++ b/premake5.lua
@@ -0,0 +1,80 @@
+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 {RaylibStaticLibrary}
+
+    -- 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.")
+        -- Which BSD?
+        BSD_OS = io.popen("uname")
+        BSD_OS_NAME = BSD_OS:read("*a")
+        BSD_OS:close()
+        -- Check Result
+        if(BSD_OS_NAME == "netbsd") then
+            links {RaylibStaticLibrary, "m", "pthread", "glfw"}
+        elseif(BSD_OS_NAME == "freebsd") then
+            links {RaylibStaticLibrary, "m", "glfw", "stdthreads"}
+        elseif(BSD_OS_NAME == "openbsd") then
+            print("Openbsd doesn't work currently due to lack of c11 threads support.")
+            links {RaylibStaticLibrary, "m", "glfw", "pthread"}
+        else
+            print("Couldn't figure out BSD, assuming freebsd.")
+            links {RaylibStaticLibrary, "m", "glfw", "stdthreads"}
+        end
+    elseif(os.ishost("windows") == true) then
+        print("This script is expecting a MSYS2 or Cygwin environment. You've been warned.")
+    else
+        links {RaylibStaticLibrary, "m", "pthread", "dl"}
+    end
+    newaction {
+        trigger = "install",
+        description = "Install the game to prefix.",
+        execute = function()
+            os.executef("mkdir -pv %s/Pong", prefix)
+            os.executef("cp -rv resources/ %s/Pong/", prefix)
+            os.executef("install -Dvm755 bin/*/Pong %s/Pong/pong", prefix)
+            if(flatpak == true) then
+                os.executef("install -Dvm755 src/flatpak_launch.sh %s/bin/launch.sh", prefix)
+            end
+        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)
+        end
+    }
\ No newline at end of file