diff options
-rw-r--r-- | src/luarocks/build/cmake.tl (renamed from src/luarocks/build/cmake.lua) | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/src/luarocks/build/cmake.lua b/src/luarocks/build/cmake.tl index b7a4786e..9a512d1e 100644 --- a/src/luarocks/build/cmake.lua +++ b/src/luarocks/build/cmake.tl | |||
@@ -1,18 +1,30 @@ | |||
1 | 1 | ||
2 | local type Build = require("luarocks.core.types.build").Build | ||
3 | |||
2 | --- Build back-end for CMake-based modules. | 4 | --- Build back-end for CMake-based modules. |
3 | local cmake = {} | 5 | local record cmake |
6 | record CMakeBuild | ||
7 | is Build where self.type == "cmake" | ||
8 | |||
9 | cmake: string | ||
10 | variables: {string: string} | ||
11 | build_pass: boolean | ||
12 | install_pass: boolean | ||
13 | end | ||
14 | end | ||
4 | 15 | ||
5 | local fs = require("luarocks.fs") | 16 | local fs = require("luarocks.fs") |
6 | local util = require("luarocks.util") | 17 | local util = require("luarocks.util") |
7 | local cfg = require("luarocks.core.cfg") | 18 | local cfg = require("luarocks.core.cfg") |
8 | 19 | ||
20 | local type Rockspec = require("luarocks.core.types.rockspec").Rockspec | ||
21 | |||
9 | --- Driver function for the "cmake" build back-end. | 22 | --- Driver function for the "cmake" build back-end. |
10 | -- @param rockspec table: the loaded rockspec. | 23 | -- @param rockspec table: the loaded rockspec. |
11 | -- @return boolean or (nil, string): true if no errors occurred, | 24 | -- @return boolean or (nil, string): true if no errors occurred, |
12 | -- nil and an error message otherwise. | 25 | -- nil and an error message otherwise. |
13 | function cmake.run(rockspec, no_install) | 26 | function cmake.run(rockspec: Rockspec, no_install: boolean): boolean, string, string |
14 | assert(rockspec:type() == "rockspec") | 27 | local build = rockspec.build as cmake.CMakeBuild |
15 | local build = rockspec.build | ||
16 | local variables = build.variables or {} | 28 | local variables = build.variables or {} |
17 | 29 | ||
18 | -- Pass Env variables | 30 | -- Pass Env variables |
@@ -28,8 +40,9 @@ function cmake.run(rockspec, no_install) | |||
28 | end | 40 | end |
29 | 41 | ||
30 | -- If inline cmake is present create CMakeLists.txt from it. | 42 | -- If inline cmake is present create CMakeLists.txt from it. |
31 | if type(build.cmake) == "string" then | 43 | local build_cmake = build.cmake |
32 | local cmake_handler = assert(io.open(fs.current_dir().."/CMakeLists.txt", "w")) | 44 | if build_cmake is string then |
45 | local cmake_handler = assert((io.open(fs.current_dir().."/CMakeLists.txt", "w"))) | ||
33 | cmake_handler:write(build.cmake) | 46 | cmake_handler:write(build.cmake) |
34 | cmake_handler:close() | 47 | cmake_handler:close() |
35 | end | 48 | end |
@@ -52,7 +65,7 @@ function cmake.run(rockspec, no_install) | |||
52 | return nil, "Failed cmake." | 65 | return nil, "Failed cmake." |
53 | end | 66 | end |
54 | 67 | ||
55 | local do_build, do_install | 68 | local do_build, do_install: boolean, boolean |
56 | if rockspec:format_is_at_least("3.0") then | 69 | if rockspec:format_is_at_least("3.0") then |
57 | do_build = (build.build_pass == nil) and true or build.build_pass | 70 | do_build = (build.build_pass == nil) and true or build.build_pass |
58 | do_install = (build.install_pass == nil) and true or build.install_pass | 71 | do_install = (build.install_pass == nil) and true or build.install_pass |