diff options
| author | charles seizilles <[email protected]> | 2022-09-06 16:09:23 +0200 |
|---|---|---|
| committer | charles seizilles <[email protected]> | 2022-09-06 16:09:23 +0200 |
| commit | c04d020691876cc40b37c682aecf9d174f2dd2b7 (patch) | |
| tree | ebcd590df279fc50ca41ec7a8ce0049f6ed25b7f | |
| parent | cbc2d55f916ed91802222501df8abd4f4820693a (diff) | |
Partial resolve
| -rw-r--r-- | xmake/modules/detect/sdks/find_matlab.lua | 70 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/find_matlab_runtime.lua | 79 | ||||
| -rw-r--r-- | xmake/modules/detect/sdks/matlab.lua | 89 |
3 files changed, 120 insertions, 118 deletions
diff --git a/xmake/modules/detect/sdks/find_matlab.lua b/xmake/modules/detect/sdks/find_matlab.lua index f3916d950..1980ea960 100644 --- a/xmake/modules/detect/sdks/find_matlab.lua +++ b/xmake/modules/detect/sdks/find_matlab.lua @@ -18,55 +18,8 @@ -- @file find_matlab.lua -- --- see https://www.mathworks.com/products/compiler/matlab-runtime.html -local matlabvers = { - ["9.12"] = "R2022a" -, ["9.11"] = "R2021b" -, ["9.10"] = "R2021a" -, ["9.9"] = "R2020b" -, ["9.8"] = "R2020a" -, ["9.7"] = "R2019b" -, ["9.6"] = "R2019a" -, ["9.5"] = "R2018b" -, ["9.4"] = "R2018a" -, ["9.3"] = "R2017b" -, ["9.2"] = "R2017a" -, ["9.1"] = "R2016b" -, ["9.0.1"] = "R2016a" -, ["9.0"] = "R2015b" -, ["8.5.1"] = "R2015aSP1" -, ["8.5"] = "R2015a" -, ["8.4"] = "R2014b" -, ["8.3"] = "R2014a" -, ["8.2"] = "R2013b" -, ["8.1"] = "R2013a" -, ["8.0"] = "R2012b" -, ["7.17"] = "R2012a" -} -local invmatlabvers = { - r2022a = "9.12", - r2021b = "9.11", - r2021a = "9.10", - r2020b = "9.9", - r2020a = "9.8", - r2019b = "9.7", - r2019a = "9.6", - r2018b = "9.5", - r2018a = "9.4", - r2017b = "9.3", - r2017a = "9.2", - r2016b = "9.1", - r2016a = "9.0.1", - r2015b = "9.0", - r2015asp1 = "8.5.1", - r2015a = "8.5", - r2014b = "8.4", - r2014a = "8.3", - r2013b = "8.2", - r2013a = "8.1", - r2012b = "8.0", - r2012a = "7.17", -} +-- imports +import("detect.sdks.matlab") -- find matlab sdk toolchains -- @@ -74,11 +27,14 @@ local invmatlabvers = { -- -- @code -- --- local toolchains = find_matlab(runtimeversion) +-- local toolchains = find_matlab(opt) -- -- @endcode -- -function main(runtimeversion) +function main(opt) + opt = opt or {} + local runtime_version = opt.runtime_version and tostring(opt.runtime_version) or nil + local result = {sdkdir = "", includedirs = {}, linkdirs = {}, links = {}} if is_host("windows") then local matlabkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB" @@ -88,22 +44,22 @@ function main(runtimeversion) end local itemkey = nil - if runtimeversion == nil then + if runtime_version == nil then itemkey = valuekeys[1] .. ";MATLABROOT" else - local versionname = matlabvers[runtimeversion] + local versionname = matlab.versions()[runtime_version] if versionname ~= nil then - itemkey = matlabkey .. "\\" .. runtimeversion .. ";MATLABROOT" + itemkey = matlabkey .. "\\" .. runtime_version .. ";MATLABROOT" else - local versionvalue = invmatlabvers[runtimeversion:lower()] + local versionvalue = matlab.versions_names()[runtime_version:lower()] if versionvalue ~= nil then itemkey = matlabkey .. "\\" .. versionvalue .. ";MATLABROOT" else print("allowed values are:") - for k,v in pairs(matlabvers) do + for k, v in pairs(matlab.versions()) do print(" ", k, v) end - raise("MATLAB Runtime version does not exist: " .. runtimeversion) + raise("MATLAB Runtime version does not exist: " .. runtime_version) end end end diff --git a/xmake/modules/detect/sdks/find_matlab_runtime.lua b/xmake/modules/detect/sdks/find_matlab_runtime.lua index b45af960f..27852d2f0 100644 --- a/xmake/modules/detect/sdks/find_matlab_runtime.lua +++ b/xmake/modules/detect/sdks/find_matlab_runtime.lua @@ -18,55 +18,8 @@ -- @file find_matlab_runtime.lua -- --- see https://www.mathworks.com/products/compiler/matlab-runtime.html -local matlabvers = { - ["9.12"] = "R2022a" -, ["9.11"] = "R2021b" -, ["9.10"] = "R2021a" -, ["9.9"] = "R2020b" -, ["9.8"] = "R2020a" -, ["9.7"] = "R2019b" -, ["9.6"] = "R2019a" -, ["9.5"] = "R2018b" -, ["9.4"] = "R2018a" -, ["9.3"] = "R2017b" -, ["9.2"] = "R2017a" -, ["9.1"] = "R2016b" -, ["9.0.1"] = "R2016a" -, ["9.0"] = "R2015b" -, ["8.5.1"] = "R2015aSP1" -, ["8.5"] = "R2015a" -, ["8.4"] = "R2014b" -, ["8.3"] = "R2014a" -, ["8.2"] = "R2013b" -, ["8.1"] = "R2013a" -, ["8.0"] = "R2012b" -, ["7.17"] = "R2012a" -} -local invmatlabvers = { - r2022a = "9.12", - r2021b = "9.11", - r2021a = "9.10", - r2020b = "9.9", - r2020a = "9.8", - r2019b = "9.7", - r2019a = "9.6", - r2018b = "9.5", - r2018a = "9.4", - r2017b = "9.3", - r2017a = "9.2", - r2016b = "9.1", - r2016a = "9.0.1", - r2015b = "9.0", - r2015asp1 = "8.5.1", - r2015a = "8.5", - r2014b = "8.4", - r2014a = "8.3", - r2013b = "8.2", - r2013a = "8.1", - r2012b = "8.0", - r2012a = "7.17", -} +-- imports +import("detect.sdks.matlab") -- find matlab runtime sdk -- @@ -74,12 +27,14 @@ local invmatlabvers = { -- -- @code -- --- local sdk = find_matlab_runtime(runtimeversion) +-- local sdk = find_matlab_runtime(opt) -- -- @endcode -- -function main(runtimeversion) - runtimeversion = tostring(runtimeversion) +function main(opt) + opt = opt or {} + local runtime_version = opt.runtime_version and tostring(opt.runtime_version) or nil + local result = {sdkdir = "", includedirs = {}, linkdirs = {}, links = {}, bindirs = {}} if is_host("windows") then local matlabkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB Runtime" @@ -88,29 +43,31 @@ function main(runtimeversion) return nil end - local versionname = nil local versionvalue = nil local itemkey = nil - if runtimeversion == nil then + if runtime_version == nil then + local splitvaluekeys = valuekeys[1]:split("\\") + versionvalue = splitvaluekeys[#splitvaluekeys - 1] + versionname = matlab.versions()[versionvalue] itemkey = valuekeys[1] .. ";MATLABROOT" else - versionname = matlabvers[runtimeversion] + versionname = matlab.versions()[runtime_version] if versionname ~= nil then - versionvalue = invmatlabvers[versionname:lower()] - itemkey = matlabkey .. "\\" .. runtimeversion .. ";MATLABROOT" + versionvalue = matlab.versions_names()[versionname:lower()] + itemkey = matlabkey .. "\\" .. runtime_version .. ";MATLABROOT" else - versionvalue = invmatlabvers[runtimeversion:lower()] - versionname = matlabvers[versionvalue] + versionvalue = matlab.versions_names()[runtime_version:lower()] + versionname = matlab.versions()[versionvalue] if versionvalue ~= nil then itemkey = matlabkey .. "\\" .. versionvalue .. ";MATLABROOT" else print("allowed values are:") - for k,v in pairs(matlabvers) do + for k, v in pairs(matlab.versions()) do print(" ", k, v) end - raise("MATLAB Runtime version does not exist: " .. runtimeversion) + raise("MATLAB Runtime version does not exist: " .. runtime_version) end end end diff --git a/xmake/modules/detect/sdks/matlab.lua b/xmake/modules/detect/sdks/matlab.lua new file mode 100644 index 000000000..a42fca38c --- /dev/null +++ b/xmake/modules/detect/sdks/matlab.lua @@ -0,0 +1,89 @@ +--!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-present, TBOOX Open Source Group. +-- +-- @author WubiCookie +-- @file matlab.lua +-- + +-- define module +local matlab = matlab or {} + +-- get matlab versions +function matlab.versions() + + -- see https://www.mathworks.com/products/compiler/matlab-runtime.html + return + { + ["9.12"] = "R2022a" + , ["9.11"] = "R2021b" + , ["9.10"] = "R2021a" + , ["9.9"] = "R2020b" + , ["9.8"] = "R2020a" + , ["9.7"] = "R2019b" + , ["9.6"] = "R2019a" + , ["9.5"] = "R2018b" + , ["9.4"] = "R2018a" + , ["9.3"] = "R2017b" + , ["9.2"] = "R2017a" + , ["9.1"] = "R2016b" + , ["9.0.1"] = "R2016a" + , ["9.0"] = "R2015b" + , ["8.5.1"] = "R2015aSP1" + , ["8.5"] = "R2015a" + , ["8.4"] = "R2014b" + , ["8.3"] = "R2014a" + , ["8.2"] = "R2013b" + , ["8.1"] = "R2013a" + , ["8.0"] = "R2012b" + , ["7.17"] = "R2012a" + } +end + +-- get matlab versions names +function matlab.versions_names() + + return + { + r2022a = "9.12" + , r2021b = "9.11" + , r2021a = "9.10" + , r2020b = "9.9" + , r2020a = "9.8" + , r2019b = "9.7" + , r2019a = "9.6" + , r2018b = "9.5" + , r2018a = "9.4" + , r2017b = "9.3" + , r2017a = "9.2" + , r2016b = "9.1" + , r2016a = "9.0.1" + , r2015b = "9.0" + , r2015asp1 = "8.5.1" + , r2015a = "8.5" + , r2014b = "8.4" + , r2014a = "8.3" + , r2013b = "8.2" + , r2013a = "8.1" + , r2012b = "8.0" + , r2012a = "7.17" + } +end + +print("inside matlab.lua") +print("matlab", matlab) + +-- return module +return matlab |
