1 Project
:= Object clone do(
2 cc
:= method(System
getenv("CC") ifNilEval(return "cc"))
3 cxx
:= method(System
getenv("CXX") ifNilEval(return "g++"))
4 platform
:= System platform split
at(0) asLowercase
6 systemCall
:= method(s
,
8 if(r
== 256, System
exit(1))
12 trySystemCall
:= method(s
,
13 result
:= System
system("sh -c '" .. s
.. "'")
17 modulesInFolder
:= method(name
,
18 folder
:= Directory clone setPath(name
)
19 if(folder exists not
, return List clone)
20 subfolders
:= folder folders
21 subfolders
selectInPlace(fileNamedOrNil("build.io"))
23 module
:= Lobby doString(f
fileNamedOrNil("build.io") contents
)
24 module folder
setPath(f path
)
30 self addons
:= modulesInFolder("addons") sortInPlaceBy(block(x
, y
, x name
< y name
))
33 buildAddon
:= method(name
,
34 addons
detect(addon
, addon name
== name
) build(options
)
37 availableAddon
:= method(addon
,
38 if(addon
hasSlot("isAvailable"), return addon isAvailable
)
40 addon isAvailable
:= false
43 if(addon
supportedOnPlatform(platform
) not
,
44 error
:= (addon name
.. " is not supported on " .. platform
.. "\n") print
45 File clone openForAppending("errors") write(error
) close
46 addon isAvailable
:= false
49 if(addon hasDepends not
, return false
)
50 addon depends addons
foreach(addonName
,
51 dependancy
:= addons
detect(name
== addonName
)
53 error
:= (addon name
.. " is missing " .. addonName
.. " addon\n") print
54 File clone openForAppending("errors") write(error
) close
55 addon isAvailable
:= false
58 if(availableAddon(dependancy
) not
,
59 error
:= (addon name
.. " is missing " .. addonName
.. " addon\n") print
60 File clone openForAppending("errors") write(error
) close
61 addon isAvailable
:= false
65 addon isAvailable
:= true
69 availableAddons
:= method(
70 addons
selectInPlace(addon
, availableAddon(addon
))
74 if (platform
== "windows",
75 "-MD -DWIN32 -DNDEBUG -DIOBINDINGS"
77 "-Os -g -Wall -DSANE_POPEN -DIOBINDINGS"
82 File clone with("errors") remove close
84 writeln("\n--- build complete ---\n")
87 orderedAddons
:= method(
89 dependencies
:= availableAddons
clone
90 while(0 < dependencies size
,
91 ordered
= dependencies
clone appendSeq(ordered
) unique
92 dependencies
= dependencies
map(depends addons
map(a
, addons
detect(name
== a
))) flatten unique
97 buildAddons
:= method(
98 writeln("\n--- building addons ---\n")
100 orderedAddons
foreach(build(options
))
104 libPaths
:= Directory with("libs") folders
map(path
)
106 otherLibPaths
:= method(libtype
,
107 if(libtype
== nil
, libtype
= "_build/dll")
108 addons
:= availableAddons
110 l
appendSeq(addons
map(a
, "-Laddons/" .. a name
.. "/" .. libtype
))
115 libPaths
map(s
, "-I" .. s
.. "/_build/headers")
118 cleanAddons
:= method(
119 writeln("--- Project cleanAddons ---")
120 addons
foreach(clean
)
124 writeln("--- Project clean ---")
126 trySystemCall("rm -rf projects/*/build")
127 trySystemCall("rm -f IoAddonsInit.*")
131 writeln("--- Project generate embedded docs ---")
132 systemCall("cd libs/iovm; ../../_build/binaries/io ../../tools/io/DocsExtractor.io .")
133 addons
foreach(generateDocs
)
137 writeln("--- Project clean embedded docs ---")
138 systemCall("cd vm; make cleanDocs")
139 addons
foreach(cleanDocs
)
142 runUnitTests
:= method(
145 availableAddons
foreach(addon
,
146 path
:= Path
with(addon folder path
, "tests/run.io")
147 if(File clone setPath(path
) exists
,
148 write(addon name
alignLeft(10), " - ")
149 File standardOutput flush
150 r
:= System
system("./_build/binaries/io " .. path
)
151 if(r
== 0, writeln("PASSED"), writeln("FAILED ", r
, " TESTS"))
152 failures
= failures
+ r
156 if(failures
== 0, writeln("ALL TESTS PASSED"), writeln("FAILED ", failures
, " tests"))
160 installDependenciesFor
:= method(name
,
161 addons
map(installCommands
) map(at(name
)) select(!=nil
) foreach(c
,
167 aptget
:= method(installDependenciesFor("aptget"))
168 emerge
:= method(installDependenciesFor("emerge"))
169 port
:= method(installDependenciesFor("port"))
170 urpmi
:= method(installDependenciesFor("urpmi"))