From f7d5a6a8d54df807badc1e9ce29a4fe5103c362f Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Sun, 14 Apr 2019 12:48:45 +0300 Subject: Implemented package installation for clib --- .../modules/package/manager/clib/find_package.lua | 27 +++++++++ .../package/manager/clib/install_package.lua | 70 ++++++++++++++++++++++ xmake/modules/package/manager/install_package.lua | 2 +- 3 files changed, 98 insertions(+), 1 deletion(-) create mode 100644 xmake/modules/package/manager/clib/find_package.lua create mode 100644 xmake/modules/package/manager/clib/install_package.lua diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua new file mode 100644 index 000000000..414093e33 --- /dev/null +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -0,0 +1,27 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author Adel Vilkov (aka RaZeR-RBI) +-- @file find_package.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") + +function main(name, opt) +-- TODO: Implement clib package search +end \ No newline at end of file diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua new file mode 100644 index 000000000..b7f76cbce --- /dev/null +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -0,0 +1,70 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author Adel Vilkov (aka RaZeR-RBI) +-- @file install_package.lua +-- + +-- imports +import("core.base.option") +import("core.project.config") +import("lib.detect.find_tool") +-- install package +-- @param name the package name, e.g. clib::clibs/buffer@0.4.0 +-- @param opt the options, .e.g { verbose = true, out_dir = "deps", +-- save = false, save_dev = false } +-- +-- @return true or false +-- +function main(name, opt) + -- find clib + local clib = find_tool("clib") + if not clib then + raise("clib not found!") + end + -- default options + local all_opts = { + verbose = true, + out_dir = "deps", + save = false, + save_dev = false + } + -- copy specified options + if opt then + for k, v in ipairs(opt) do + all_opts[k] = v + end + end + + local argv = {"install", name} + + local abs_out = all_opts.out_dir + dprint("installing %s to %s", name, abs_out) + table.insert(argv, "-o " .. abs_out) + + if not all_opts.verbose then + table.insert(argv, "-q") + end + if all_opts.save then + table.insert(argv, "--save") + end + if all_opts.save_dev then + table.insert(argv, "--save-dev") + end + + -- do install + os.vrunv(clib.program, argv) +end \ No newline at end of file diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index b46062c42..62256ebb6 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -31,7 +31,7 @@ function _install_package(manager_name, package_name, opt) end -- get suitable package managers - local managers = {} + local managers = {"clib"} if is_host("windows") then table.insert(managers, "pacman") -- msys/mingw elseif is_host("linux") then -- cgit v1.3.1 From ba5f76ecdd4eb95ca942369fd9e52cf796beaa8b Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Sun, 14 Apr 2019 17:55:18 +0300 Subject: First implementation of find_package for clib --- xmake/core/sandbox/modules/io.lua | 10 ++++++++++ .../modules/package/manager/clib/find_package.lua | 22 +++++++++++++++++++++- .../package/manager/clib/install_package.lua | 18 ++++++++++++++---- 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/xmake/core/sandbox/modules/io.lua b/xmake/core/sandbox/modules/io.lua index 53d8399f4..7f93f020d 100644 --- a/xmake/core/sandbox/modules/io.lua +++ b/xmake/core/sandbox/modules/io.lua @@ -77,6 +77,16 @@ function sandbox_io.gsub(filepath, pattern, replace) return data, count end +-- check if file exists +function sandbox_io.exists(filepath) + local file, _ = io.open(filepath, "r") + if file then + file:close() + return true + end + return false +end + -- open file function sandbox_io.open(filepath, mode) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index 414093e33..d64884429 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -23,5 +23,25 @@ import("core.base.option") import("core.project.config") function main(name, opt) --- TODO: Implement clib package search + -- check if a package marker file with install directory exists + local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") + local marker_filename = string.gsub(name, "%/", "=") + local marker_path = path.join(cache_dir, marker_filename) + dprint("reading clib marker file for %s from %s", name, marker_filename) + + if not io.exists(marker_filename) then + return + end + + local marker_file = io.open(marker_path, "r") + if marker_file then + local install_path = marker_file:read("*all") + marker_file:close() + dprint("%s is installed to %s", name, install_path) + + return { + headerdirs = { install_path }, + includedirs = { install_path } + } + end end \ No newline at end of file diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index b7f76cbce..250ef8b66 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -23,8 +23,8 @@ import("core.base.option") import("core.project.config") import("lib.detect.find_tool") -- install package --- @param name the package name, e.g. clib::clibs/buffer@0.4.0 --- @param opt the options, .e.g { verbose = true, out_dir = "deps", +-- @param name the package name, e.g. clib::clibs/bytes@0.4.0 +-- @param opt the options, .e.g { verbose = true, out_dir = "myDir", -- save = false, save_dev = false } -- -- @return true or false @@ -35,10 +35,11 @@ function main(name, opt) if not clib then raise("clib not found!") end + -- default options local all_opts = { verbose = true, - out_dir = "deps", + out_dir = path.join(".xmake", "cache", "packages", ".clib"), save = false, save_dev = false } @@ -51,7 +52,7 @@ function main(name, opt) local argv = {"install", name} - local abs_out = all_opts.out_dir + local abs_out = path.join(os.projectdir(), all_opts.out_dir) dprint("installing %s to %s", name, abs_out) table.insert(argv, "-o " .. abs_out) @@ -67,4 +68,13 @@ function main(name, opt) -- do install os.vrunv(clib.program, argv) + + -- add a package marker file with install directory + local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") + local marker_filename = string.gsub(name, "%/", "=") + local marker_path = path.join(cache_dir, marker_filename) + dprint("writing clib marker file for %s to %s", name, marker_filename) + local marker_file = io.open(marker_path, "w") + marker_file:write(abs_out) + marker_file:close() end \ No newline at end of file -- cgit v1.3.1 From 3f990875386c52be7712d0e56debf4eab4c88b9a Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Sun, 14 Apr 2019 18:19:15 +0300 Subject: Edited clib package installation paths --- xmake/modules/package/manager/clib/find_package.lua | 2 -- xmake/modules/package/manager/clib/install_package.lua | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index d64884429..39b18834f 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -27,7 +27,6 @@ function main(name, opt) local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") local marker_filename = string.gsub(name, "%/", "=") local marker_path = path.join(cache_dir, marker_filename) - dprint("reading clib marker file for %s from %s", name, marker_filename) if not io.exists(marker_filename) then return @@ -40,7 +39,6 @@ function main(name, opt) dprint("%s is installed to %s", name, install_path) return { - headerdirs = { install_path }, includedirs = { install_path } } end diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index 250ef8b66..54bb49f14 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -24,7 +24,7 @@ import("core.project.config") import("lib.detect.find_tool") -- install package -- @param name the package name, e.g. clib::clibs/bytes@0.4.0 --- @param opt the options, .e.g { verbose = true, out_dir = "myDir", +-- @param opt the options, .e.g { verbose = true, out_dir = "clib", -- save = false, save_dev = false } -- -- @return true or false @@ -39,7 +39,7 @@ function main(name, opt) -- default options local all_opts = { verbose = true, - out_dir = path.join(".xmake", "cache", "packages", ".clib"), + out_dir = "clib", save = false, save_dev = false } -- cgit v1.3.1 From ab5fabf72e0f8cef831312683a2e7603c5269089 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Sun, 14 Apr 2019 18:19:15 +0300 Subject: Edited clib package installation paths --- xmake/modules/package/manager/clib/find_package.lua | 2 -- xmake/modules/package/manager/clib/install_package.lua | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index d64884429..39b18834f 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -27,7 +27,6 @@ function main(name, opt) local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") local marker_filename = string.gsub(name, "%/", "=") local marker_path = path.join(cache_dir, marker_filename) - dprint("reading clib marker file for %s from %s", name, marker_filename) if not io.exists(marker_filename) then return @@ -40,7 +39,6 @@ function main(name, opt) dprint("%s is installed to %s", name, install_path) return { - headerdirs = { install_path }, includedirs = { install_path } } end diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index 250ef8b66..54bb49f14 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -24,7 +24,7 @@ import("core.project.config") import("lib.detect.find_tool") -- install package -- @param name the package name, e.g. clib::clibs/bytes@0.4.0 --- @param opt the options, .e.g { verbose = true, out_dir = "myDir", +-- @param opt the options, .e.g { verbose = true, out_dir = "clib", -- save = false, save_dev = false } -- -- @return true or false @@ -39,7 +39,7 @@ function main(name, opt) -- default options local all_opts = { verbose = true, - out_dir = path.join(".xmake", "cache", "packages", ".clib"), + out_dir = "clib", save = false, save_dev = false } -- cgit v1.3.1 From 02b3bcfce1e24a8f4978519db1bf8bde415bdc41 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 12:30:01 +0300 Subject: Config options for clib, code cleanup and fixes, proper API usage --- xmake/core/sandbox/modules/io.lua | 10 ---- .../modules/package/manager/clib/find_package.lua | 23 ++++----- .../package/manager/clib/install_package.lua | 59 ++++++++++++---------- xmake/modules/package/manager/install_package.lua | 3 +- 4 files changed, 42 insertions(+), 53 deletions(-) diff --git a/xmake/core/sandbox/modules/io.lua b/xmake/core/sandbox/modules/io.lua index 7f93f020d..53d8399f4 100644 --- a/xmake/core/sandbox/modules/io.lua +++ b/xmake/core/sandbox/modules/io.lua @@ -77,16 +77,6 @@ function sandbox_io.gsub(filepath, pattern, replace) return data, count end --- check if file exists -function sandbox_io.exists(filepath) - local file, _ = io.open(filepath, "r") - if file then - file:close() - return true - end - return false -end - -- open file function sandbox_io.open(filepath, mode) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index 39b18834f..7aa9d6ad1 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -11,7 +11,7 @@ -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. --- +-- -- Copyright (C) 2015 - 2019, TBOOX Open Source Group. -- -- @author Adel Vilkov (aka RaZeR-RBI) @@ -24,22 +24,17 @@ import("core.project.config") function main(name, opt) -- check if a package marker file with install directory exists - local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") + local cache_dir = path.join(config.directory(), "clib", "cache", "packages") local marker_filename = string.gsub(name, "%/", "=") local marker_path = path.join(cache_dir, marker_filename) + dprint("looking for marker file for %s at %s", name, marker_path) - if not io.exists(marker_filename) then + if not os.isfile(marker_path) then + dprint("no marker file found for %s", name) return end - local marker_file = io.open(marker_path, "r") - if marker_file then - local install_path = marker_file:read("*all") - marker_file:close() - dprint("%s is installed to %s", name, install_path) - - return { - includedirs = { install_path } - } - end -end \ No newline at end of file + local install_path = io.readfile(marker_path) + dprint("%s is installed to %s", name, install_path) + return {includedirs = { install_path }} +end diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index 54bb49f14..9c2743cbb 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -11,7 +11,7 @@ -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. --- +-- -- Copyright (C) 2015 - 2019, TBOOX Open Source Group. -- -- @author Adel Vilkov (aka RaZeR-RBI) @@ -22,10 +22,23 @@ import("core.base.option") import("core.project.config") import("lib.detect.find_tool") + +-- get configurations +function configurations() + return + { + verbose = {description = "enable verbose output", default = "true", values = {"true", "false"}}, + save = {description = "save dependency in project's package.json", default = "false", values = {"true", "false"}}, + save_dev = {description = "save as development dependency in project's package.json", default = "false", values = {"true", "false"}}, + out_dir = {description = "package installation directory relative to project root", default = "clib"}, + } +end + -- install package -- @param name the package name, e.g. clib::clibs/bytes@0.4.0 --- @param opt the options, .e.g { verbose = true, out_dir = "clib", --- save = false, save_dev = false } +-- @param opt the options, .e.g { verbose = true, mode = "release", plat = , arch = , +-- remote = "", build = "all", options = {}, imports = {}, build_requires = {}, +-- settings = {verbose = "false", out_dir = "deps", save = "true", save_dev = "false"}} -- -- @return true or false -- @@ -36,45 +49,35 @@ function main(name, opt) raise("clib not found!") end - -- default options - local all_opts = { - verbose = true, - out_dir = "clib", - save = false, - save_dev = false - } - -- copy specified options - if opt then - for k, v in ipairs(opt) do - all_opts[k] = v - end - end - local argv = {"install", name} - - local abs_out = path.join(os.projectdir(), all_opts.out_dir) + local abs_out = path.join(os.projectdir(), opt.out_dir) dprint("installing %s to %s", name, abs_out) table.insert(argv, "-o " .. abs_out) - if not all_opts.verbose then + if opt.verbose ~= "true" then table.insert(argv, "-q") end - if all_opts.save then + if opt.save == "true" then table.insert(argv, "--save") end - if all_opts.save_dev then + if opt.save_dev == "true" then table.insert(argv, "--save-dev") end + -- save previous directory and cd to project directory + local old_dir = os.curdir() + os.cd(os.projectdir()) + -- do install os.vrunv(clib.program, argv) + -- restore old directory + os.cd(old_dir) + -- add a package marker file with install directory - local cache_dir = path.join(os.projectdir(), ".xmake", "cache", "packages") + local cache_dir = path.join(config.directory(), "clib", "cache", "packages") local marker_filename = string.gsub(name, "%/", "=") local marker_path = path.join(cache_dir, marker_filename) - dprint("writing clib marker file for %s to %s", name, marker_filename) - local marker_file = io.open(marker_path, "w") - marker_file:write(abs_out) - marker_file:close() -end \ No newline at end of file + dprint("writing clib marker file for %s to %s", name, marker_path) + io.writefile(marker_path, abs_out) +end diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index 62256ebb6..fdc68e7c3 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -31,7 +31,7 @@ function _install_package(manager_name, package_name, opt) end -- get suitable package managers - local managers = {"clib"} + local managers = {} if is_host("windows") then table.insert(managers, "pacman") -- msys/mingw elseif is_host("linux") then @@ -43,6 +43,7 @@ function _install_package(manager_name, package_name, opt) table.insert(managers, "vcpkg") table.insert(managers, "brew") end + table.insert(managers, "clib") assert(#managers > 0, "no suitable package manager!") -- install package from the given package managers -- cgit v1.3.1 From 072f9bfe34c02a9f855497e4f2b15602d2c6d9a3 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 12:35:10 +0300 Subject: Added find_clib.lua --- xmake/modules/detect/tools/find_clib.lua | 54 ++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 xmake/modules/detect/tools/find_clib.lua diff --git a/xmake/modules/detect/tools/find_clib.lua b/xmake/modules/detect/tools/find_clib.lua new file mode 100644 index 000000000..2464ec248 --- /dev/null +++ b/xmake/modules/detect/tools/find_clib.lua @@ -0,0 +1,54 @@ +--!A cross-platform build utility based on Lua +-- +-- Licensed under the Apache License, Version 2.0 (the "License"); +-- you may not use this file except in compliance with the License. +-- You may obtain a copy of the License at +-- +-- http://www.apache.org/licenses/LICENSE-2.0 +-- +-- Unless required by applicable law or agreed to in writing, software +-- distributed under the License is distributed on an "AS IS" BASIS, +-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +-- See the License for the specific language governing permissions and +-- limitations under the License. +-- +-- Copyright (C) 2015 - 2019, TBOOX Open Source Group. +-- +-- @author Adel Vilkov (aka RaZeR-RBI) +-- @file find_clib.lua +-- + +-- imports +import("lib.detect.find_program") +import("lib.detect.find_programver") + +-- find clib +-- +-- @param opt the argument options, .e.g {version = true} +-- +-- @return program, version +-- +-- @code +-- +-- local clib = find_clib() +-- local clib, version = find_clib({version = true}) +-- +-- @endcode +-- +function main(opt) + + -- init options + opt = opt or {} + + -- find program + local program = find_program(opt.program or "clib", opt) + + -- find program version + local version = nil + if program and opt and opt.version then + version = find_programver(program, opt) + end + + -- ok? + return program, version +end -- cgit v1.3.1 From 84ae318b8c8ab05919126acc596a3104314663c0 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 13:03:23 +0300 Subject: Removed redundant options, proper boolean config handling --- xmake/modules/package/manager/clib/install_package.lua | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index 9c2743cbb..d51164f02 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -27,18 +27,16 @@ import("lib.detect.find_tool") function configurations() return { - verbose = {description = "enable verbose output", default = "true", values = {"true", "false"}}, - save = {description = "save dependency in project's package.json", default = "false", values = {"true", "false"}}, - save_dev = {description = "save as development dependency in project's package.json", default = "false", values = {"true", "false"}}, + save = {description = "save dependency in project's package.json", default = false, type = "boolean"}, + save_dev = {description = "save as development dependency in project's package.json", default = false, type = "boolean"}, out_dir = {description = "package installation directory relative to project root", default = "clib"}, } end -- install package -- @param name the package name, e.g. clib::clibs/bytes@0.4.0 --- @param opt the options, .e.g { verbose = true, mode = "release", plat = , arch = , --- remote = "", build = "all", options = {}, imports = {}, build_requires = {}, --- settings = {verbose = "false", out_dir = "deps", save = "true", save_dev = "false"}} +-- @param opt the options, .e.g { verbose = true, +-- settings = {out_dir = "clib", save = false, save_dev = false}} -- -- @return true or false -- @@ -54,13 +52,13 @@ function main(name, opt) dprint("installing %s to %s", name, abs_out) table.insert(argv, "-o " .. abs_out) - if opt.verbose ~= "true" then + if not option.get("verbose") then table.insert(argv, "-q") end - if opt.save == "true" then + if opt.save then table.insert(argv, "--save") end - if opt.save_dev == "true" then + if opt.save_dev then table.insert(argv, "--save-dev") end -- cgit v1.3.1 From 5ba527330e2179fab1a1da86e84ada542926eae8 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 13:05:02 +0300 Subject: Removed "clib" from package/manager/install_package.lua --- xmake/modules/package/manager/install_package.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/xmake/modules/package/manager/install_package.lua b/xmake/modules/package/manager/install_package.lua index fdc68e7c3..b46062c42 100644 --- a/xmake/modules/package/manager/install_package.lua +++ b/xmake/modules/package/manager/install_package.lua @@ -43,7 +43,6 @@ function _install_package(manager_name, package_name, opt) table.insert(managers, "vcpkg") table.insert(managers, "brew") end - table.insert(managers, "clib") assert(#managers > 0, "no suitable package manager!") -- install package from the given package managers -- cgit v1.3.1 From a58d9e70433b5720f3cb314cf6e2463e465130c2 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 18:08:15 +0300 Subject: Replaced clib marker file contents with table for potential future improvements --- xmake/modules/package/manager/clib/find_package.lua | 4 ++-- xmake/modules/package/manager/clib/install_package.lua | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index 7aa9d6ad1..4caf6063d 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -35,6 +35,6 @@ function main(name, opt) end local install_path = io.readfile(marker_path) - dprint("%s is installed to %s", name, install_path) - return {includedirs = { install_path }} + dprint("found marker file for %s", name) + return io.load(marker_path) end diff --git a/xmake/modules/package/manager/clib/install_package.lua b/xmake/modules/package/manager/clib/install_package.lua index d51164f02..0fb057183 100644 --- a/xmake/modules/package/manager/clib/install_package.lua +++ b/xmake/modules/package/manager/clib/install_package.lua @@ -29,14 +29,14 @@ function configurations() { save = {description = "save dependency in project's package.json", default = false, type = "boolean"}, save_dev = {description = "save as development dependency in project's package.json", default = false, type = "boolean"}, - out_dir = {description = "package installation directory relative to project root", default = "clib"}, + outputdir = {description = "package installation directory relative to project root", default = "clib"}, } end -- install package -- @param name the package name, e.g. clib::clibs/bytes@0.4.0 -- @param opt the options, .e.g { verbose = true, --- settings = {out_dir = "clib", save = false, save_dev = false}} +-- settings = {outputdir = "clib", save = false, save_dev = false}} -- -- @return true or false -- @@ -48,7 +48,7 @@ function main(name, opt) end local argv = {"install", name} - local abs_out = path.join(os.projectdir(), opt.out_dir) + local abs_out = path.join(os.projectdir(), opt.outputdir) dprint("installing %s to %s", name, abs_out) table.insert(argv, "-o " .. abs_out) @@ -77,5 +77,5 @@ function main(name, opt) local marker_filename = string.gsub(name, "%/", "=") local marker_path = path.join(cache_dir, marker_filename) dprint("writing clib marker file for %s to %s", name, marker_path) - io.writefile(marker_path, abs_out) + io.save(marker_path, {includedirs = { abs_out }}) end -- cgit v1.3.1 From 0e3f93ad95a57e2dbc3360c26292dacb767f8f54 Mon Sep 17 00:00:00 2001 From: Adel Vilkov Date: Mon, 15 Apr 2019 21:40:33 +0300 Subject: Removed unused line --- xmake/modules/package/manager/clib/find_package.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/xmake/modules/package/manager/clib/find_package.lua b/xmake/modules/package/manager/clib/find_package.lua index 4caf6063d..ae8f55edc 100644 --- a/xmake/modules/package/manager/clib/find_package.lua +++ b/xmake/modules/package/manager/clib/find_package.lua @@ -34,7 +34,6 @@ function main(name, opt) return end - local install_path = io.readfile(marker_path) dprint("found marker file for %s", name) return io.load(marker_path) end -- cgit v1.3.1