5 description = "clean the build",
7 print("clean the build...")
10 -- no wildcards in os.remove, so use shell
11 os.execute("rm *.make")
12 print("build cleaned")
16 workspace "rive_tests"
17 configurations {"debug"}
23 targetdir "build/bin/%{cfg.buildcfg}"
24 objdir "build/obj/%{cfg.buildcfg}"
26 buildoptions {"-Wall", "-fno-exceptions", "-fno-rtti"}
28 includedirs {"./include", "../../include"}
30 files {"../../src/**.cpp", -- the Rive runtime source
31 "../../test/**.cpp" -- the tests
34 defines {"TESTING", "ENABLE_QUERY_FLAT_VERTICES"}
36 filter "configurations:debug"
42 -- Recursively iterate through all files in a dir
45 assert(dir and dir ~= "", "Provide a directory")
46 if string.sub(dir, -1) == "/" then
47 dir = string.sub(dir, 1, -2)
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
62 return coroutine.wrap(function()
67 -- Get the file extension from a string
68 function getFileExtension(path)
69 return path:match("^.+(%..+)$")
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)
82 return coroutine.wrap(function()
87 -- Build test executable for a cpp file
88 local function test(filepath)
90 local filename = filepath:match("([^/]+)$")
91 local projectname = filename:match("^[^%.]+")
92 -- print("Filepath: " .. filepath)
93 -- print("Filename: " .. filename)
94 -- print("Projectname: " .. projectname)
100 targetdir "build/bin/%{cfg.buildcfg}"
101 objdir "build/obj/%{cfg.buildcfg}"
115 "../../rive/src/**.cpp",
119 filter "configurations:debug"
124 -- Build all cpp test files in Rive's test directory
125 for cppFile in getFilesByExtension(".cpp", "../../rive/test/") do
129 -- Build test executable for a cpp file and link to the precompiled rive lib
130 local function test_precompiled(filepath)
132 local filename = filepath:match("([^/]+)$") .. "_linked"
133 local projectname = filename:match("^[^%.]+") .. "_linked"
134 -- print("Filepath: " .. filepath)
135 -- print("Filename: " .. filename)
136 -- print("Projectname: " .. projectname)
142 targetdir "build/bin/%{cfg.buildcfg}"
143 objdir "build/obj/%{cfg.buildcfg}"
160 "../../rive/build/bin/debug/librive.a"
163 filter "configurations:debug"
168 -- Build all cpp test files in Rive's test directory
169 for cppFile in getFilesByExtension(".cpp", "../../rive/test/") do
170 test_precompiled(cppFile)