[Adaptation Layer] Added rive-tizen adaptation layer class.
[platform/core/uifw/rive-tizen.git] / submodule / dev / test / premake5.lua
1 -- require "lfs"
2 -- Clean Function --
3 newaction {
4     trigger = "clean",
5     description = "clean the build",
6     execute = function()
7         print("clean the build...")
8         os.rmdir("build")
9         os.remove("Makefile")
10         -- no wildcards in os.remove, so use shell
11         os.execute("rm *.make")
12         print("build cleaned")
13     end
14 }
15
16 workspace "rive_tests"
17 configurations {"debug"}
18
19 project("tests")
20 kind "ConsoleApp"
21 language "C++"
22 cppdialect "C++17"
23 targetdir "build/bin/%{cfg.buildcfg}"
24 objdir "build/obj/%{cfg.buildcfg}"
25
26 buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti"}
27
28 includedirs {"./include", "../../include"}
29
30 files {"../../src/**.cpp", -- the Rive runtime source
31 "../../test/**.cpp" -- the tests
32 }
33
34 defines {"TESTING", "ENABLE_QUERY_FLAT_VERTICES"}
35
36 filter "configurations:debug"
37 defines {"DEBUG"}
38 symbols "On"
39
40 --[[
41
42 -- Recursively iterate through all files in a dir
43 function dirtree(dir)
44
45     assert(dir and dir ~= "", "Provide a directory")
46     if string.sub(dir, -1) == "/" then
47         dir = string.sub(dir, 1, -2)
48     end
49
50     local function yieldtree(dir)
51         for entry in lfs.dir(dir) do
52             if entry ~= "." and entry ~= ".." then
53                 entry = dir .. "/" .. entry
54                 local attr = lfs.attributes(entry)
55                 coroutine.yield(entry, attr)
56                 if attr.mode == "directory" then
57                     yieldtree(entry)
58                 end
59             end
60         end
61     end
62     return coroutine.wrap(function()
63         yieldtree(dir)
64     end)
65 end
66
67 -- Get the file extension from a string
68 function getFileExtension(path)
69     return path:match("^.+(%..+)$")
70 end
71
72 -- Get file paths to all files ending in the given file extension in a given dir
73 -- This will recurse through subdirs
74 function getFilesByExtension(extension, dir)
75     local function yieldfile(dir)
76         for filename, attr in dirtree(dir) do
77             if attr.mode == "file" and getFileExtension(filename) == extension then
78                 coroutine.yield(filename)
79             end
80         end
81     end
82     return coroutine.wrap(function()
83         yieldfile(dir)
84     end)
85 end
86
87 -- Build test executable for a cpp file
88 local function test(filepath)
89
90     local filename = filepath:match("([^/]+)$")
91     local projectname = filename:match("^[^%.]+")
92     -- print("Filepath: " .. filepath)
93     -- print("Filename: " .. filename)
94     -- print("Projectname: " .. projectname)
95
96     project(projectname)
97     kind "ConsoleApp"
98     language "C++"
99     cppdialect "C++17"
100     targetdir "build/bin/%{cfg.buildcfg}"
101     objdir "build/obj/%{cfg.buildcfg}"
102     
103     buildoptions {
104         "-Wall", 
105         "-fno-exceptions", 
106         "-fno-rtti"
107     }
108
109     includedirs {
110         "./include",
111         "../../rive/include"
112     }
113
114     files {
115         "../../rive/src/**.cpp",
116         filepath
117     }
118
119     filter "configurations:debug"
120         defines { "DEBUG" }
121         symbols "On"
122 end
123
124 -- Build all cpp test files in Rive's test directory
125 for cppFile in getFilesByExtension(".cpp", "../../rive/test/") do
126     test(cppFile)
127 end
128
129 -- Build test executable for a cpp file and link to the precompiled rive lib
130 local function test_precompiled(filepath)
131
132     local filename = filepath:match("([^/]+)$") .. "_linked"
133     local projectname = filename:match("^[^%.]+") .. "_linked"
134     -- print("Filepath: " .. filepath)
135     -- print("Filename: " .. filename)
136     -- print("Projectname: " .. projectname)
137
138     project(projectname)
139     kind "ConsoleApp"
140     language "C++"
141     cppdialect "C++17"
142     targetdir "build/bin/%{cfg.buildcfg}"
143     objdir "build/obj/%{cfg.buildcfg}"
144     
145     buildoptions {
146         "-Wall", 
147         "-fno-exceptions", 
148         "-fno-rtti"
149     }
150
151     includedirs {
152         "./include",
153         "../../rive/include"
154     }
155
156     files { filepath }
157
158     links
159     {
160         "../../rive/build/bin/debug/librive.a"
161     }
162
163     filter "configurations:debug"
164         defines { "DEBUG" }
165         symbols "On"
166 end
167
168 -- Build all cpp test files in Rive's test directory
169 for cppFile in getFilesByExtension(".cpp", "../../rive/test/") do
170     test_precompiled(cppFile)
171 end
172
173 --]]