Unnamed: 0
int64 0
0
| repo_id
stringlengths 5
186
| file_path
stringlengths 15
223
| content
stringlengths 1
32.8M
⌀ |
---|---|---|---|
0 | repos/xmake/xmake/modules | repos/xmake/xmake/modules/cli/extract.lua | --!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 ruki
-- @file extract.lua
--
-- imports
import("core.base.option")
import("utils.archive.extract")
-- the options
local options = {
{'w', "workdir", "kv", nil, "Set the working directory."},
{nil, "excludes", "kv", nil, "Set the excludes patterns.",
"e.g.",
" - xmake l cli.extract --excludes=\"*/dir/*|dir/*\" -o outputdir archivefile"},
{'o', "outputdir", "kv", nil, "The output directory."},
{nil, "archivefile","v", nil, "The archive file."}
}
function main(...)
local argv = table.pack(...)
local args = option.parse(argv, options, "Extract file.",
"",
"Usage: xmake l cli.extract [options]")
local archivefile = assert(args.archivefile, "please set archive file!")
local outputdir = assert(args.outputdir, "please set output directory!")
local opt = {}
opt.recurse = args.recurse
opt.curdir = args.workdir
if args.excludes then
opt.excludes = args.excludes:split("|")
end
extract(archivefile, outputdir, opt)
end
|
0 | repos/xmake/xmake/modules | repos/xmake/xmake/modules/cli/bisect.lua | --!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 ruki
-- @file bisect.lua
--
-- imports
import("core.base.option")
import("lib.detect.find_tool")
-- the options
local options = {
{'g', "good", "kv", nil, "Set the good commit."},
{'b', "bad", "kv", nil, "Set the bad commit."},
{nil, "gitdir", "kv", nil, "Set the git root directory."},
{'c', "commands", "kv" , nil, "Run the multiple commands instead of the default build command.",
"e.g.",
" $ xmake l cli.bisect -c 'xmake -rv' -g good -b bad",
" $ xmake l cli.bisect -c 'xmake -vD; xmake run hello' -g good -b bad"},
{'s', "script" , "kv" , nil, "Run the given lua script file.",
"e.g.",
" $ xmake l cli.bisect -s /tmp/test.lua -g good -b bad"},
{'-', "arbitrary", "vs", nil, "Run an arbitrary command.",
"e.g.",
" $ xmake l cli.bisect -g 90846dd -b ddb86e4 -- xmake -rv"}
}
-- run command
function _run_command(opt)
opt = opt or {}
local ok = try
{
function ()
local commands = opt.commands
local scriptfile = opt.script
local arbitrary = opt.arbitrary
if commands then
for _, command in ipairs(commands:split(";")) do
os.exec(command:trim())
end
elseif arbitrary then
local program = arbitrary[1]
local argv = #arbitrary > 1 and table.slice(arbitrary, 2) or {}
os.execv(program, argv)
elseif scriptfile and os.isfile(scriptfile) and path.extension(scriptfile) == ".lua" then
local script = import(path.basename(scriptfile),
{rootdir = path.directory(scriptfile), anonymous = true})
script(events)
end
return true
end,
catch
{
function (errors)
cprint(tostring(errors))
end
}
}
return ok
end
-- use `git bisect` to analyze problem
function main(...)
local argv = table.pack(...)
local args = option.parse(argv, options, "Analyze problem using `git bisect`.",
"",
"Usage: xmake l cli.bisect [options]")
local git = assert(find_tool("git"), "git not found!")
local good = assert(args.good, "please set `--good commit`")
local bad = assert(args.bad, "please set `--bad commit`")
local gitdir = args.gitdir or os.curdir()
os.execv(git.program, {"bisect", "start"}, {curdir = gitdir})
os.execv(git.program, {"bisect", "good", good}, {curdir = gitdir})
os.execv(git.program, {"bisect", "bad", bad}, {curdir = gitdir})
while true do
local output
if _run_command(args) then
output = os.iorunv(git.program, {"bisect", "good"}, {curdir = gitdir})
else
output = os.iorunv(git.program, {"bisect", "bad"}, {curdir = gitdir})
end
if output then
print(output)
if output:find("is the first bad commit", 1, true) then
break
end
end
end
os.execv(git.program, {"bisect", "reset"}, {curdir = gitdir})
end
|
0 | repos/xmake/xmake/modules | repos/xmake/xmake/modules/cli/archive.lua | --!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 ruki
-- @file archive.lua
--
-- imports
import("core.base.option")
import("utils.archive.archive")
-- the options
local options = {
{nil, "compress", "kv", nil, "Set the compress algorithm.", values = {"fastest", "faster", "default", "better", "best"}},
{'r', "recurse", "k", nil, "Enable recursive pattern."},
{'w', "workdir", "kv", nil, "Set the working directory."},
{nil, "excludes", "kv", nil, "Set the excludes patterns.",
"e.g.",
" - xmake l cli.archive --excludes=\"*/dir/*|dir/*\" -o archivefile inputfiles"},
{'o', "archivefile","kv", nil, "The output archive file."},
{nil, "inputfiles", "vs", nil, "The input files."}
}
function main(...)
local argv = table.pack(...)
local args = option.parse(argv, options, "Archive file.",
"",
"Usage: xmake l cli.archive [options]")
local archivefile = assert(args.archivefile, "please set output file!")
local inputfiles = assert(args.inputfiles, "please set input files!")
local opt = {}
opt.recurse = args.recurse
opt.compress = args.compress
opt.curdir = args.workdir
if args.excludes then
opt.excludes = args.excludes:split("|")
end
archive(archivefile, inputfiles, opt)
end
|
0 | repos/xmake/xmake/modules/ui | repos/xmake/xmake/modules/ui/app/version.lua | --!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 ruki
-- @file version.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.event")
import("core.ui.textdialog")
import("core.ui.application")
-- the application
local app = application()
-- init app
function app:init()
-- init name
application.init(self, "app")
-- init background
self:background_set("blue")
-- disable color code output
os.setenv("COLORTERM", "nocolor")
-- get version info
local version = os.iorun("xmake --version")
-- init main dialog
local dialog_main = textdialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "version info")
dialog_main:text():text_set(version or "unknown version!")
dialog_main:button_add("exit", "< Exit >", function (v) self:quit() end)
self:insert(dialog_main)
end
-- main entry
function main(...)
app:run(...)
end
|
0 | repos/xmake/xmake/modules/ui | repos/xmake/xmake/modules/ui/app/showfile.lua | --!A cross-platform build utility based on Lua
--
-- Licensed to the Apache Software Foundation (ASF) under one
-- or more contributor license agreements. See the NOTICE file
-- distributed with this work for additional information
-- regarding copyright ownership. The ASF licenses this file
-- to you under the Apache License, showfile 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 ruki
-- @file showfile.lua
--
-- imports
import("core.ui.log")
import("core.ui.rect")
import("core.ui.event")
import("core.ui.textdialog")
import("core.ui.application")
-- the application
local app = application()
-- init app
function app:init(argv)
-- init name
application.init(self, "app", argv)
-- init background
self:background_set("blue")
-- get file
local file = argv[1]
-- read file content
local content = nil
if file then
content = os.isfile(file) and io.readfile(file) or nil
else
content = "please input file path!"
end
-- init main dialog
local dialog_main = textdialog:new("dialog.main", rect {1, 1, self:width() - 1, self:height() - 1}, "showfile: " .. (file and path.filename(file) or ""))
dialog_main:text():text_set(content or string.format("cannot read file(%s)!", file))
dialog_main:button_add("exit", "< Exit >", function (v) self:quit() end)
self:insert(dialog_main)
end
-- main entry
function main(...)
app:run(...)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_wasisdk.lua | --!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 vkensou
-- @file find_wasisdk.lua
--
-- imports
import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_file")
-- find wasm-ld directory
function _find_wasm_ld(sdkdir)
local subdirs = {}
table.insert(subdirs, "bin")
local paths = {}
if sdkdir then
table.insert(paths, sdkdir)
end
table.insert(paths, "$(env WASI_SDK_PATH)")
local wasm_ldname = (is_host("windows") and "wasm-ld.exe" or "wasm-ld")
local wasm_ld = find_file(wasm_ldname, paths, {suffixes = subdirs})
if wasm_ld then
return path.directory(wasm_ld)
end
end
-- find wasi-sdk
function _find_wasisdk(sdkdir)
-- find bin directory
local bindir = _find_wasm_ld(sdkdir)
if not bindir or path.filename(bindir) ~= "bin" then
return {}
end
-- find sdk root directory
sdkdir = path.directory(bindir)
if not sdkdir then
return {}
end
return {sdkdir = sdkdir, bindir = bindir}
end
-- find wasi-sdk directory
--
-- @param sdkdir the wasi-sdk directory
-- @param opt the argument options, e.g. {force = true}
--
-- @return the sdk toolchains. e.g. {sdkdir = ..}
--
-- @code
--
-- local sdk = find_wasisdk("~/wasi-sdk")
--
-- @endcode
--
function main(sdkdir, opt)
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_wasisdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.sdk and cacheinfo.sdk.sdkdir and os.isdir(cacheinfo.sdk.sdkdir) then
return cacheinfo.sdk
end
-- find sdk
local sdk = _find_wasisdk(sdkdir)
if sdk and sdk.sdkdir and sdk.bindir then
if opt.verbose or option.get("verbose") then
cprint("checking for wasi-sdk directory ... ${color.success}%s", sdk.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for wasi-sdk directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.sdk = sdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return sdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_masm32.lua | --!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 ruki
-- @file find_masm32.lua
--
-- imports
import("lib.detect.find_path")
import("core.base.option")
import("core.project.config")
import("core.cache.detectcache")
-- find masm32 directory
function _find_sdkdir(sdkdir)
local paths = {}
if sdkdir then
table.insert(paths, path.join(sdkdir, "bin"))
else
for _, logical_drive in ipairs(winos.logical_drives()) do
table.insert(paths, path.join(logical_drive, "masm32", "bin"))
end
end
local bindir = find_path("ml.exe", paths)
if bindir then
return path.directory(bindir)
end
end
-- find masm32 toolchains
function _find_masm32(sdkdir)
sdkdir = _find_sdkdir(sdkdir)
if not sdkdir or not os.isdir(sdkdir) then
return
end
return {sdkdir = sdkdir, bindir = path.join(sdkdir, "bin"), includedir = path.join(sdkdir, "include"), libdir = path.join(sdkdir, "lib")}
end
-- find masm32 toolchains
--
-- @param sdkdir the masm32 directory
-- @param opt the argument options, e.g. {verbose = true, force = false}
--
-- @return the masm32 toolchains. e.g. {sdkver = ..., sdkdir, sdkdir_armcc, sdkdir_armclang}
--
-- @code
--
-- local toolchains = find_masm32("~/masm32")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_masm32"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.masm32 and cacheinfo.masm32.sdkdir and os.isdir(cacheinfo.masm32.sdkdir) then
return cacheinfo.masm32
end
-- find masm32
local masm32 = _find_masm32(sdkdir or config.get("sdk"))
if masm32 then
if opt.verbose or option.get("verbose") then
cprint("checking for masm32 directory ... ${color.success}%s", masm32.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for masm32 directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.masm32 = masm32 or false
detectcache:set(key, cacheinfo)
detectcache:save()
return masm32
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_ifortenv.lua | --!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 ruki
-- @file find_ifortenv.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
-- init ifort variables
local ifortvars = {"path",
"lib",
"libpath",
"include",
"DevEnvdir",
"VSInstallDir",
"VCInstallDir",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
"UniversalCRTSdkDir",
"UCRTVersion"}
-- load ifortvars_bat environment variables
function _load_ifortvars(ifortvars_bat, arch, opt)
-- make the genifortvars.bat
opt = opt or {}
local genifortvars_bat = os.tmpfile() .. "_genifortvars.bat"
local genifortvars_dat = os.tmpfile() .. "_genifortvars.txt"
local file = io.open(genifortvars_bat, "w")
file:print("@echo off")
file:print("call \"%s\" -arch %s > nul", ifortvars_bat, arch)
for idx, var in ipairs(ifortvars) do
file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genifortvars_dat)
end
file:close()
-- run genifortvars.bat
os.run(genifortvars_bat)
-- load all envirnoment variables
local variables = {}
for _, line in ipairs((io.readfile(genifortvars_dat) or ""):split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()
local value = line:sub(p + 1):trim()
variables[name] = value
end
end
if not variables.path then
return
end
-- remove some empty entries
for _, name in ipairs(ifortvars) do
if variables[name] and #variables[name]:trim() == 0 then
variables[name] = nil
end
end
-- fix bin path for ia32
if variables.path and arch == "ia32" then
variables.path = variables.path:gsub("windows\\bin\\intel64;", "windows\\bin\\intel64_ia32;")
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib
variables.LIBPATH = variables.libpath
variables.INCLUDE = variables.include
variables.path = nil
variables.lib = nil
variables.include = nil
variables.libpath = nil
return variables
end
-- find intel fortran envirnoment on windows
function _find_intel_on_windows(opt)
-- init options
opt = opt or {}
-- find ifortvars_bat.bat
local paths = {"$(env IFORT_COMPILER20)"}
local ifortvars_bat = find_file("bin/ifortvars.bat", paths)
-- look for setvars.bat which is new in 2021
if not ifortvars_bat then
-- find setvars.bat in intel oneapi toolkits rootdir
paths = {"$(env ONEAPI_ROOT)"}
ifortvars_bat = find_file("setvars.bat", paths)
end
if not ifortvars_bat then
-- find setvars.bat use IFORT_COMPILER.*
paths = {
"$(env IFORT_COMPILER21)",
"$(env IFORT_COMPILER22)",
"$(env IFORT_COMPILER23)"
}
ifortvars_bat = find_file("../../../setvars.bat", paths)
if not ifortvars_bat then
paths = {
"$(env IFORT_COMPILER24)"
}
ifortvars_bat = find_file("../../setvars.bat", paths)
end
end
if ifortvars_bat then
-- load ifortvars_bat
local ifortvars_x86 = _load_ifortvars(ifortvars_bat, "ia32", opt)
local ifortvars_x64 = _load_ifortvars(ifortvars_bat, "intel64", opt)
-- save results
return {ifortvars_bat = ifortvars_bat, ifortvars = {x86 = ifortvars_x86, x64 = ifortvars_x64}}
end
end
-- find intel fortran envirnoment on linux
function _find_intel_on_linux(opt)
local paths = {"/opt/intel/bin", "/usr/local/bin", "/usr/bin"}
local ifort = find_file("ifort", paths)
if ifort then
local bindir = path.directory(ifort)
local sdkdir = path.directory(bindir)
return {sdkdir = sdkdir, bindir = bindir, libdir = path.join(sdkdir, "lib")}
end
-- find it from oneapi sdk directory
local oneapi_rootdirs = {"~/intel/oneapi/compiler", "/opt/intel/oneapi/compiler"}
local arch = os.arch() == "x86_64" and "intel64" or "ia32"
paths = {}
for _, rootdir in ipairs(oneapi_rootdirs) do
table.insert(paths, path.join(rootdir, "*", is_host("macosx") and "mac" or "linux", "bin", arch))
end
if #paths > 0 then
local ifort = find_file("ifort", paths)
if ifort then
local bindir = path.directory(ifort)
local sdkdir = path.directory(path.directory(bindir))
return {sdkdir = sdkdir, bindir = bindir, libdir = path.join(sdkdir, "compiler", "lib", arch)}
end
end
end
-- find intel fortran environment
function main(opt)
if is_host("windows") then
return _find_intel_on_windows(opt)
else
return _find_intel_on_linux(opt)
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_iccenv.lua | --!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 ruki
-- @file find_iccenv.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
-- init icl variables
local iclvars = {"path",
"lib",
"libpath",
"include",
"DevEnvdir",
"VSInstallDir",
"VCInstallDir",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
"UniversalCRTSdkDir",
"UCRTVersion"}
-- load iclvars_bat environment variables
function _load_iclvars(iclvars_bat, arch, opt)
-- make the geniclvars.bat
opt = opt or {}
local geniclvars_bat = os.tmpfile() .. "_geniclvars.bat"
local geniclvars_dat = os.tmpfile() .. "_geniclvars.txt"
local file = io.open(geniclvars_bat, "w")
file:print("@echo off")
file:print("call \"%s\" -arch %s > nul", iclvars_bat, arch)
for idx, var in ipairs(iclvars) do
file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", geniclvars_dat)
end
file:close()
-- run geniclvars.bat
os.run(geniclvars_bat)
-- load all envirnoment variables
local variables = {}
for _, line in ipairs((io.readfile(geniclvars_dat) or ""):split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()
local value = line:sub(p + 1):trim()
variables[name] = value
end
end
if not variables.path then
return
end
-- remove some empty entries
for _, name in ipairs(iclvars) do
if variables[name] and #variables[name]:trim() == 0 then
variables[name] = nil
end
end
-- fix bin path for ia32
if variables.path and arch == "ia32" then
variables.path = variables.path:gsub("windows\\bin\\intel64;", "windows\\bin\\intel64_ia32;")
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib
variables.LIBPATH = variables.libpath
variables.INCLUDE = variables.include
variables.path = nil
variables.lib = nil
variables.include = nil
variables.libpath = nil
return variables
end
-- find intel c/c++ envirnoment on windows
function _find_intel_on_windows(opt)
-- init options
opt = opt or {}
-- find iclvars_bat.bat
local paths = {"$(env ICPP_COMPILER20)"}
local iclvars_bat = find_file("bin/iclvars.bat", paths)
-- look for setvars.bat which is new in 2021
if not iclvars_bat then
-- find setvars.bat in intel oneapi toolkits rootdir
paths = {"$(env ONEAPI_ROOT)"}
iclvars_bat = find_file("setvars.bat", paths)
end
if not iclvars_bat then
-- find setvars.bat using ICPP_COMPILER.*
paths = {
"$(env ICPP_COMPILER21)",
"$(env ICPP_COMPILER22)",
"$(env ICPP_COMPILER23)"
}
iclvars_bat = find_file("../../../setvars.bat", paths)
if not iclvars_bat then
paths = {
"$(env ICPP_COMPILER24)"
}
iclvars_bat = find_file("../../setvars.bat", paths)
end
end
if iclvars_bat then
-- load iclvars_bat
local iclvars_x86 = _load_iclvars(iclvars_bat, "ia32", opt)
local iclvars_x64 = _load_iclvars(iclvars_bat, "intel64", opt)
-- save results
return {iclvars_bat = iclvars_bat, iclvars = {x86 = iclvars_x86, x64 = iclvars_x64}}
end
end
-- find intel c/c++ envirnoment on linux
function _find_intel_on_linux(opt)
-- attempt to find the sdk directory
local paths = {"/opt/intel/bin", "/usr/local/bin", "/usr/bin"}
local icc = find_file("icc", paths)
if icc then
local sdkdir = path.directory(path.directory(icc))
return {sdkdir = sdkdir, bindir = path.directory(icc), path.join(sdkdir, "include"), libdir = path.join(sdkdir, "lib")}
end
-- find it from oneapi sdk directory
local oneapi_rootdirs = {"~/intel/oneapi/compiler", "/opt/intel/oneapi/compiler"}
local arch = os.arch() == "x86_64" and "intel64" or "ia32"
paths = {}
for _, rootdir in ipairs(oneapi_rootdirs) do
table.insert(paths, path.join(rootdir, "*", is_host("macosx") and "mac" or "linux", "bin", arch))
end
if #paths > 0 then
local icc = find_file("icc", paths)
if icc then
local bindir = path.directory(icc)
local sdkdir = path.directory(path.directory(bindir))
return {sdkdir = sdkdir, bindir = bindir, libdir = path.join(sdkdir, "compiler", "lib", arch)}
end
end
end
-- find intel c/c++ environment
function main(opt)
if is_host("windows") then
return _find_intel_on_windows(opt)
else
return _find_intel_on_linux(opt)
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_android_sdk.lua | --!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 ruki
-- @file find_android_sdk.lua
--
-- imports
import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_directory")
-- find sdk directory
function _find_android_sdkdir(sdkdir)
-- get sdk directory
if not sdkdir then
sdkdir = os.getenv("ANDROID_SDK_HOME") or os.getenv("ANDROID_SDK_ROOT")
if not sdkdir and is_host("macosx") then
sdkdir = "~/Library/Android/sdk"
end
end
-- get sdk directory
if sdkdir and os.isdir(sdkdir) then
return sdkdir
end
end
-- find the build-tools version of sdk
function _find_sdk_build_toolver(sdkdir)
-- find the max version
local toolver_max = "0"
for _, dir in ipairs(os.dirs(path.join(sdkdir, "build-tools", "*"))) do
local toolver = path.filename(dir)
if semver.is_valid(toolver) and semver.compare(toolver, toolver_max) > 0 then
toolver_max = toolver
end
end
-- get the max sdk version
return toolver_max ~= "0" and tostring(toolver_max) or nil
end
-- find the android sdk
function _find_android_sdk(sdkdir, build_toolver)
-- find sdk root directory
sdkdir = _find_android_sdkdir(sdkdir)
if not sdkdir then
return {}
end
-- find the build-tools version of sdk
build_toolver = build_toolver or _find_sdk_build_toolver(sdkdir)
-- ok?
return {sdkdir = sdkdir, build_toolver = build_toolver}
end
-- find android sdk directory
--
-- @param sdkdir the android sdk directory
-- @param opt the argument options, e.g. {force = true, build_toolver = "28.0.3"}
--
-- @return the sdk toolchains. e.g. {sdkdir = .., build_toolver = "28.0.3"}
--
-- @code
--
-- local sdk = find_android_sdk("~/Library/Android/sdk")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_android_sdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.sdk and cacheinfo.sdk.sdkdir and os.isdir(cacheinfo.sdk.sdkdir) then
return cacheinfo.sdk
end
-- find sdk
local sdk = _find_android_sdk(sdkdir or config.get("android_sdk") or global.get("android_sdk"), opt.build_toolver or config.get("build_toolver"))
if sdk and sdk.sdkdir then
-- save to config
config.set("android_sdk", sdk.sdkdir, {force = true, readonly = true})
config.set("build_toolver", sdk.build_toolver, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Android SDK directory ... ${color.success}%s", sdk.sdkdir)
cprint("checking for Build Tools Version of Android SDK ... ${color.success}%s", sdk.build_toolver)
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Android SDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.sdk = sdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return sdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_vstudio.lua | --!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 ruki
-- @file find_vstudio.lua
--
-- imports
import("core.project.config")
import("lib.detect.find_file")
import("lib.detect.find_tool")
import("core.cache.global_detectcache")
-- init vc variables
local vcvars = {"path",
"lib",
"libpath",
"include",
"DevEnvdir",
"VSInstallDir",
"VCInstallDir",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
"WindowsSdkVerBinPath",
"ExtensionSdkDir",
"UniversalCRTSdkDir",
"UCRTVersion",
"VCToolsVersion",
"VCIDEInstallDir",
"VCToolsInstallDir",
"VCToolsRedistDir",
"VisualStudioVersion",
"VSCMD_VER",
"VSCMD_ARG_app_plat",
"VSCMD_ARG_HOST_ARCH",
"VSCMD_ARG_TGT_ARCH"}
-- init vsvers
local vsvers =
{
["17.0"] = "2022"
, ["16.0"] = "2019"
, ["15.0"] = "2017"
, ["14.0"] = "2015"
, ["12.0"] = "2013"
, ["11.0"] = "2012"
, ["10.0"] = "2010"
, ["9.0"] = "2008"
, ["8.0"] = "2005"
, ["7.1"] = "2003"
, ["7.0"] = "7.0"
, ["6.0"] = "6.0"
, ["5.0"] = "5.0"
, ["4.2"] = "4.2"
}
-- init vsenvs
local vsenvs =
{
["17.0"] = "VS170COMNTOOLS"
, ["16.0"] = "VS160COMNTOOLS"
, ["15.0"] = "VS150COMNTOOLS"
, ["14.0"] = "VS140COMNTOOLS"
, ["12.0"] = "VS120COMNTOOLS"
, ["11.0"] = "VS110COMNTOOLS"
, ["10.0"] = "VS100COMNTOOLS"
, ["9.0"] = "VS90COMNTOOLS"
, ["8.0"] = "VS80COMNTOOLS"
, ["7.1"] = "VS71COMNTOOLS"
, ["7.0"] = "VS70COMNTOOLS"
, ["6.0"] = "VS60COMNTOOLS"
, ["5.0"] = "VS50COMNTOOLS"
, ["4.2"] = "VS42COMNTOOLS"
}
-- get all known Visual Studio environment variables
function get_vcvars()
local realvcvars = vcvars
for _, v in pairs(vsenvs) do
table.insert(realvcvars, v)
end
return realvcvars
end
-- load vcvarsall environment variables
function _load_vcvarsall(vcvarsall, vsver, arch, opt)
opt = opt or {}
-- is VsDevCmd.bat?
local is_vsdevcmd = path.basename(vcvarsall):lower() == "vsdevcmd"
-- make the genvcvars.bat
local genvcvars_bat = os.tmpfile() .. "_genvcvars.bat"
local file = io.open(genvcvars_bat, "w")
file:print("@echo off")
-- @note we need to get utf8 output from cmd.exe
-- because some %PATH% and other envs maybe contains unicode characters
if winos.version():gt("winxp") then
file:print("chcp 65001")
end
-- fix error caused by the new vsDevCmd.bat of vs2019
-- @see https://github.com/xmake-io/xmake/issues/549
if vsver and tonumber(vsver) >= 16 then
file:print("set VSCMD_SKIP_SENDTELEMETRY=yes")
end
local host_arch = os.arch()
if is_vsdevcmd then
if vsver and tonumber(vsver) >= 16 then
if opt.vcvars_ver then
file:print("call \"%s\" -host_arch=%s -arch=%s -winsdk=%s -vcvars_ver=%s > nul", vcvarsall, host_arch, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
else
file:print("call \"%s\" -host_arch=%s -arch=%s -winsdk=%s > nul", vcvarsall, host_arch, arch, opt.sdkver and opt.sdkver or "")
end
else
if opt.vcvars_ver then
file:print("call \"%s\" -arch=%s -winsdk=%s -vcvars_ver=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
else
file:print("call \"%s\" -arch=%s -winsdk=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
end
end
else
-- @see https://github.com/xmake-io/xmake/issues/5077
if vsver and tonumber(vsver) >= 16 and host_arch ~= arch then
if host_arch == "x64" then
host_arch = "amd64"
end
arch = host_arch .. "_" .. arch
end
if opt.vcvars_ver then
file:print("call \"%s\" %s %s -vcvars_ver=%s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "", opt.vcvars_ver)
else
file:print("call \"%s\" %s %s > nul", vcvarsall, arch, opt.sdkver and opt.sdkver or "")
end
end
for idx, var in ipairs(get_vcvars()) do
file:print("echo " .. var .. " = %%" .. var .. "%%")
end
file:close()
-- run genvcvars.bat
local outdata = try {function () return os.iorun(genvcvars_bat) end}
if not outdata then
return
end
-- load all envirnoment variables
local variables = {}
for _, line in ipairs(outdata:split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()
local value = line:sub(p + 1):trim()
variables[name] = value
end
end
if not variables.path then
return
end
-- remove some empty entries
for _, name in ipairs(vcvars) do
if variables[name] and #variables[name]:trim() == 0 then
variables[name] = nil
end
end
-- fix WindowsSDKVersion
local WindowsSDKVersion = variables["WindowsSDKVersion"]
if WindowsSDKVersion then
WindowsSDKVersion = WindowsSDKVersion:gsub("\\", ""):trim()
if WindowsSDKVersion ~= "" then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
else
-- sometimes the variable `WindowsSDKVersion` is not available
-- then parse it from `WindowsSdkBinPath`, such as: `C:\\Program Files (x86)\\Windows Kits\\8.1\\bin`
local WindowsSdkBinPath = variables["WindowsSdkBinPath"]
if WindowsSdkBinPath then
WindowsSDKVersion = string.match(WindowsSdkBinPath, "\\(%d+%.%d+)\\bin$")
if WindowsSDKVersion then
variables["WindowsSDKVersion"] = WindowsSDKVersion
end
end
end
-- fix UCRTVersion
--
-- @note vcvarsall.bat maybe detect error if install WDK and SDK at same time (multi-sdk version exists in include directory).
--
local UCRTVersion = variables["UCRTVersion"]
if UCRTVersion and WindowsSDKVersion and UCRTVersion ~= WindowsSDKVersion and WindowsSDKVersion ~= "" then
local lib = variables["lib"]
if lib then
lib = lib:gsub(UCRTVersion, WindowsSDKVersion)
variables["lib"] = lib
end
local include = variables["include"]
if include then
include = include:gsub(UCRTVersion, WindowsSDKVersion)
variables["include"] = include
end
UCRTVersion = WindowsSDKVersion
variables["UCRTVersion"] = UCRTVersion
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib
variables.LIBPATH = variables.libpath
variables.INCLUDE = variables.include
variables.path = nil
variables.lib = nil
variables.include = nil
variables.libpath = nil
return variables
end
-- find vstudio for msvc
function _find_vstudio(opt)
opt = opt or {}
-- find the single current MSVC/VS from environment variables
local VCInstallDir = os.getenv("VCInstallDir")
if VCInstallDir and (VCInstallDir ~= "") then
local VisualStudioVersion = os.getenv("VisualStudioVersion")
if not VisualStudioVersion or (VisualStudioVersion == "") then
-- heuristic for VisualStudioVersion value (early MSVC/VS versions don't set VisualStudioVersion)
local VSInstallDir = os.getenv("VSInstallDir") or ""
VisualStudioVersion = VSInstallDir:match('(%d+[.]?%d*)\\?%s*$')
if not VisualStudioVersion then VisualStudioVersion = VCInstallDir:match('(%d+[.]?%d*)\\VC\\?%s*$') end
if not VisualStudioVersion then VisualStudioVersion = "0" end
if not VisualStudioVersion:match('[.]') then VisualStudioVersion = VisualStudioVersion .. '.0' end
-- find highest known version which is less than or equal to VisualStudioVersion
if not vsvers[VisualStudioVersion] then
local versions = {}
local count = 0
for k in pairs(vsvers) do
table.insert(versions, tonumber(k))
count = count + 1
end
table.sort(versions)
local i = 0
local v = tonumber(VisualStudioVersion)
while ((i < count) and (versions[i + 1] <= v)) do
i = i + 1
end
VisualStudioVersion = versions[i] or "0"
end
end
-- find vcvarsall.bat or vcvars32.bat
local paths =
{
path.join(VCInstallDir, "Auxiliary", "Build"),
path.join(VCInstallDir, "bin"),
VCInstallDir
}
local vcvarsall = find_file("vcvarsall.bat", paths) or find_file("vcvars32.bat", paths)
if vcvarsall and os.isfile(vcvarsall) and vsvers[VisualStudioVersion] then
-- load vcvarsall
local vcvarsall_x86 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x86", opt)
local vcvarsall_x64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "x64", opt)
local vcvarsall_arm = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm", opt)
local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, VisualStudioVersion, "arm64", opt)
local vcvarsall_arm64ec = vcvarsall_arm64
-- save results
local results = {}
results[vsvers[VisualStudioVersion]] = {
version = VisualStudioVersion,
vcvarsall_bat = vcvarsall,
vcvarsall = {
x86 = vcvarsall_x86,
x64 = vcvarsall_x64,
arm = vcvarsall_arm,
arm64 = vcvarsall_arm64,
arm64ec = vcvarsall_arm64ec
}
}
return results
end
end
-- find vswhere
local vswhere = find_tool("vswhere")
-- sort vs versions
local order_vsvers = table.keys(vsvers)
table.sort(order_vsvers, function (a, b) return tonumber(a) > tonumber(b) end)
-- find vs2017 -> vs4.2
local results = {}
for _, version in ipairs(order_vsvers) do
-- find VC install path (and aux build path) using `vswhere` (for version >= 15.0)
-- * version > 15.0 eschews registry entries; but `vswhere` (included with version >= 15.2) can be used to find VC install path
-- ref: https://github.com/Microsoft/vswhere/blob/master/README.md @@ https://archive.is/mEmdu
local vswhere_VCAuxiliaryBuildDir = nil
local vswhere_Common7ToolsDir = nil
if (tonumber(version) >= 15) and vswhere then
local vswhere_vrange = format("%s,%s)", version, (version + 1))
-- build tools: https://github.com/microsoft/vswhere/issues/22 @@ https://aka.ms/vs/workloads
local result = os.iorunv(vswhere.program, {"-products", "*", "-prerelease", "-property", "installationpath", "-version", vswhere_vrange})
if result then
vswhere_VCAuxiliaryBuildDir = path.join(result:trim(), "VC", "Auxiliary", "Build")
vswhere_Common7ToolsDir = path.join(result:trim(), "Common7", "Tools")
end
end
-- init paths
local paths = {
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC7\\bin", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\VC\\Auxiliary\\Build", version)
}
if vsenvs[version] then
table.insert(paths, format("$(env %s)\\..\\..\\VC", vsenvs[version]))
end
if vswhere_VCAuxiliaryBuildDir and os.isdir(vswhere_VCAuxiliaryBuildDir) then
table.insert(paths, 1, vswhere_VCAuxiliaryBuildDir)
end
if version == "6.0" and os.arch() == "x64" then
table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\DevStudio\\6.0\\Products\\Microsoft Visual C++;ProductDir)\\Bin")
table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Microsoft\\VisualStudio\\6.0\\Setup\\Microsoft Visual C++;ProductDir)\\Bin")
end
-- find vcvarsall.bat, vcvars32.bat for vs7.1
local vcvarsall = find_file("vcvarsall.bat", paths) or find_file("vcvars32.bat", paths)
if not vcvarsall then
-- find vs from some logical drives paths
paths = {}
local logical_drives = winos.logical_drives()
-- we attempt to find vs from wdk directory
-- wdk: E:\Program Files\Windows Kits\10
-- vcvarsall: E:\Program Files\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build
local wdk = config.get("wdk")
if wdk and os.isdir(wdk) then
local p = wdk:find("Program Files")
if p then
table.insert(logical_drives, wdk:sub(1, p - 1))
end
end
for _, logical_drive in ipairs(logical_drives) do
if os.isdir(path.join(logical_drive, "Program Files (x86)")) then
table.insert(paths, path.join(logical_drive, "Program Files (x86)", "Microsoft Visual Studio", vsvers[version], "*", "VC", "Auxiliary", "Build"))
table.insert(paths, path.join(logical_drive, "Program Files (x86)", "Microsoft Visual Studio " .. version, "VC"))
end
table.insert(paths, path.join(logical_drive, "Program Files", "Microsoft Visual Studio", vsvers[version], "*", "VC", "Auxiliary", "Build"))
table.insert(paths, path.join(logical_drive, "Program Files", "Microsoft Visual Studio " .. version, "VC"))
if version == "6.0" then
table.insert(paths, path.join(logical_drive, "Program Files", "Microsoft Visual Studio", "VC98", "Bin"))
table.insert(paths, path.join(logical_drive, "Program Files (x86)", "Microsoft Visual Studio", "VC98", "Bin"))
end
end
vcvarsall = find_file("vcvarsall.bat", paths) or find_file("vcvars32.bat", paths)
end
if not vcvarsall then
local paths = {
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\Common7\\Tools", version),
format("$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\VisualStudio\\SxS\\VS7;%s)\\Common7\\Tools", version)
}
if vswhere_Common7ToolsDir and os.isdir(vswhere_Common7ToolsDir) then
table.insert(paths, 1, vswhere_Common7ToolsDir)
end
vcvarsall = find_file("VsDevCmd.bat", paths)
end
if vcvarsall then
-- load vcvarsall
local vcvarsall_x86 = _load_vcvarsall(vcvarsall, version, "x86", opt)
local vcvarsall_x64 = _load_vcvarsall(vcvarsall, version, "x64", opt)
local vcvarsall_arm = _load_vcvarsall(vcvarsall, version, "arm", opt)
local vcvarsall_arm64 = _load_vcvarsall(vcvarsall, version, "arm64", opt)
local vcvarsall_arm64ec = vcvarsall_arm64
-- save results
results[vsvers[version]] = {
version = version,
vcvarsall_bat = vcvarsall,
vcvarsall = {
x86 = vcvarsall_x86,
x64 = vcvarsall_x64,
arm = vcvarsall_arm,
arm64 = vcvarsall_arm64,
arm64ec = vcvarsall_arm64ec
}
}
end
end
return results
end
-- get last mtime of msvc
-- @see https://github.com/xmake-io/xmake/issues/3652
function _get_last_mtime_of_msvc(msvc)
local mtime = -1
for arch, envs in pairs(msvc.vcvarsall) do
if envs.PATH then
local pathenv = path.splitenv(envs.PATH)
for _, dir in ipairs(pathenv) do
local cl = path.join(dir, "cl.exe")
if os.isfile(cl) then
local t = os.mtime(cl)
if t > mtime then
mtime = t
end
end
end
end
local winsdk = envs.WindowsSdkDir
if winsdk and os.isdir(winsdk) then
local t = os.mtime(winsdk)
if t > mtime then
mtime = t
end
end
end
return mtime
end
-- get last mtime of vstudio
function _get_last_mtime(vstudio)
local mtime = -1
for _, msvc in pairs(vstudio) do
local vcvarsall_bat = msvc.vcvarsall_bat
if vcvarsall_bat and os.isfile(vcvarsall_bat) then
local t = os.mtime(vcvarsall_bat)
if t > mtime then
mtime = t
end
t = _get_last_mtime_of_msvc(msvc)
if t > mtime then
mtime = t
end
else
mtime = -1
break
end
end
return mtime
end
-- find vstudio environment
--
-- @param opt the options, e.g. {vcvars_ver = 14.0, sdkver = "10.0.15063.0"}
--
-- @return { 2008 = {version = "9.0", vcvarsall = {x86 = {path = .., lib = .., include = ..}}}
-- , 2017 = {version = "15.0", vcvarsall = {x64 = {path = .., lib = ..}}}}
--
function main(opt)
opt = opt or {}
-- only for windows
if not is_host("windows") then
return
end
local key = "vstudio"
if opt.vcvars_ver then
key = key .. opt.vcvars_ver
end
if opt.sdkver then
key = key .. opt.sdkver
end
-- attempt to get it from the global cache first
local vstudio = global_detectcache:get2(key, "msvc")
if vstudio then
local mtime = _get_last_mtime(vstudio)
local mtimeprev = global_detectcache:get2(key, "mtime")
if mtime and mtimeprev and mtime > 0 and mtimeprev > 0 and mtime == mtimeprev then
return vstudio
end
end
-- find and cache result
vstudio = _find_vstudio(opt)
if vstudio then
local mtime = _get_last_mtime(vstudio)
global_detectcache:set2(key, "msvc", vstudio)
global_detectcache:set2(key, "mtime", mtime)
global_detectcache:save()
end
return vstudio
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_icxenv.lua | --!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 ruki
-- @file find_icxenv.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
-- init icx variables
local icxvars = {"path",
"lib",
"libpath",
"include",
"DevEnvdir",
"VSInstallDir",
"VCInstallDir",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
"UniversalCRTSdkDir",
"UCRTVersion"}
-- load icxvars_bat environment variables
function _load_icxvars(icxvars_bat, arch, opt)
-- make the genicxvars.bat
opt = opt or {}
local genicxvars_bat = os.tmpfile() .. "_genicxvars.bat"
local genicxvars_dat = os.tmpfile() .. "_genicxvars.txt"
local file = io.open(genicxvars_bat, "w")
file:print("@echo off")
file:print("call \"%s\" -arch %s > nul", icxvars_bat, arch)
for idx, var in ipairs(icxvars) do
file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genicxvars_dat)
end
file:close()
-- run genicxvars.bat
os.run(genicxvars_bat)
-- load all envirnoment variables
local variables = {}
for _, line in ipairs((io.readfile(genicxvars_dat) or ""):split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()
local value = line:sub(p + 1):trim()
variables[name] = value
end
end
if not variables.path then
return
end
-- remove some empty entries
for _, name in ipairs(icxvars) do
if variables[name] and #variables[name]:trim() == 0 then
variables[name] = nil
end
end
-- fix bin path for ia32
if variables.path and arch == "ia32" then
variables.path = variables.path:gsub("windows\\bin\\intel64;", "windows\\bin\\intel64_ia32;")
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib
variables.LIBPATH = variables.libpath
variables.INCLUDE = variables.include
variables.path = nil
variables.lib = nil
variables.include = nil
variables.libpath = nil
return variables
end
-- find intel llvm c/c++ envirnoment on windows
function _find_intel_on_windows(opt)
opt = opt or {}
-- find icxvars_bat.bat
local paths = {"$(env ONEAPI_ROOT)"}
local icxvars_bat = find_file("setvars.bat", paths)
if not icxvars_bat then
paths = {}
local keys = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Intel\\DPCPPSuites\\**\\DPC++")
for _, key in ipairs(keys) do
table.insert(paths, format("$(reg %s;ProductDir)", key))
end
icxvars_bat = find_file("../../setvars.bat", paths)
end
if icxvars_bat then
local icxvars_x86 = _load_icxvars(icxvars_bat, "ia32", opt)
local icxvars_x64 = _load_icxvars(icxvars_bat, "intel64", opt)
return {icxvars_bat = icxvars_bat, icxvars = {x86 = icxvars_x86, x64 = icxvars_x64}}
end
end
-- find intel llvm c/c++ envirnoment on linux
function _find_intel_on_linux(opt)
-- attempt to find the sdk directory
local oneapi_rootdirs = {"~/intel/oneapi/compiler", "/opt/intel/oneapi/compiler"}
paths = {}
for _, rootdir in ipairs(oneapi_rootdirs) do
table.insert(paths, path.join(rootdir, "*", is_host("macosx") and "mac" or "linux", "bin"))
table.insert(paths, path.join(rootdir, "*", "bin"))
end
if #paths > 0 then
local icx = find_file("icx", paths)
if icx then
local bindir = path.directory(icx)
local sdkdir = path.directory(path.directory(bindir))
return {sdkdir = sdkdir, bindir = bindir}
end
end
end
-- find intel c/c++ environment
function main(opt)
if is_host("windows") then
return _find_intel_on_windows(opt)
else
return _find_intel_on_linux(opt)
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_dotnet.lua | --!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 ruki
-- @file find_dotnet.lua
--
-- imports
import("lib.detect.find_file")
import("core.tool.toolchain")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
-- find dotnet directory
function _find_sdkdir(sdkdir)
-- get sdk directory from vcvars
if not sdkdir then
local msvc = toolchain.load("msvc")
if msvc and msvc:check() then
local vcvars = msvc:config("vcvars")
if vcvars then
sdkdir = vcvars.WindowsSdkDir
if sdkdir then
sdkdir = path.join(path.directory(path.translate(sdkdir)), "NETFXSDK")
end
end
end
end
return sdkdir
end
-- find dotnet toolchains
function _find_dotnet(sdkdir, sdkver)
-- find dotnet directory
sdkdir = _find_sdkdir(sdkdir)
if not sdkdir or not os.isdir(sdkdir) then
return nil
end
-- get sdk version
if not sdkver then
local vers = {}
for _, dir in ipairs(os.dirs(path.join(sdkdir, "*", "Include"))) do
table.insert(vers, path.filename(path.directory(dir)))
end
for _, ver in ipairs(vers) do
if os.isdir(path.join(sdkdir, ver, "Lib", "um")) and os.isdir(path.join(sdkdir, ver, "Include", "um")) then
sdkver = ver
break
end
end
end
if not sdkver then
return nil
end
-- get the lib directory
local libdir = path.join(sdkdir, sdkver, "Lib")
-- get the include directory
local includedir = path.join(sdkdir, sdkver, "Include")
-- get toolchains
return {sdkdir = sdkdir, libdir = libdir, includedir = includedir, sdkver = sdkver}
end
-- find dotnet toolchains
--
-- @param sdkdir the dotnet directory
-- @param opt the argument options, e.g. {verbose = true, force = false, version = "5.9.1"}
--
-- @return the dotnet toolchains. e.g. {sdkver = ..., sdkdir = ..., bindir = .., libdir = ..., includedir = ..., .. }
--
-- @code
--
-- local toolchains = find_dotnet("~/dotnet")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_dotnet." .. (sdkdir or "")
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.dotnet then
return cacheinfo.dotnet
end
-- find dotnet
local dotnet = _find_dotnet(sdkdir or config.get("dotnet") or global.get("dotnet"), opt.version or config.get("dotnet_sdkver"))
if dotnet then
-- save to config
config.set("dotnet", dotnet.sdkdir, {force = true, readonly = true})
config.set("dotnet_sdkver", dotnet.sdkver, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for .Net SDK directory ... ${color.success}%s", dotnet.sdkdir)
cprint("checking for .Net SDK version ... ${color.success}%s", dotnet.sdkver)
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for .Net SDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.dotnet = dotnet or false
detectcache:set(key, cacheinfo)
detectcache:save()
return dotnet
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_qt.lua | --!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 ruki
-- @file find_qt.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
-- find qt sdk directory
function _find_sdkdir(sdkdir, sdkver)
-- append target sub-directory
local subdirs = {}
if is_plat("linux") then
table.insert(subdirs, path.join(sdkver or "*", is_arch("x86_64") and "gcc_64" or "gcc_32", "bin"))
table.insert(subdirs, path.join(sdkver or "*", is_arch("x86_64") and "clang_64" or "clang_32", "bin"))
elseif is_plat("macosx") then
table.insert(subdirs, path.join(sdkver or "*", "macos", "bin")) -- for Qt 6.2
table.insert(subdirs, path.join(sdkver or "*", is_arch("x86_64") and "clang_64" or "clang_32", "bin"))
elseif is_plat("iphoneos") then
table.insert(subdirs, path.join(sdkver or "*", "ios", "bin"))
elseif is_plat("windows") then
local vs = config.get("vs")
if vs then
table.insert(subdirs, path.join(sdkver or "*", is_arch("x64") and "msvc" .. vs .. "_64" or "msvc" .. vs .. "_32", "bin"))
table.insert(subdirs, path.join(sdkver or "*", "msvc" .. vs, "bin"))
end
table.insert(subdirs, path.join(sdkver or "*", is_arch("x64") and "msvc*_64" or "msvc*_32", "bin"))
table.insert(subdirs, path.join(sdkver or "*", "msvc*", "bin"))
elseif is_plat("mingw") then
table.insert(subdirs, path.join(sdkver or "*", is_arch("x86_64") and "mingw*_64" or "mingw*_32", "bin"))
elseif is_plat("android") then
local subdir
if is_arch("arm64-v8a") then
subdir = "android_arm64_v8a"
elseif is_arch("armeabi-v7a", "armeabi", "armv7-a", "armv5te") then -- armv7-a/armv5te are deprecated
subdir = "android_armv7"
elseif is_arch("x86", "i386") then -- i386 is deprecated
subdir = "android_x86"
elseif is_arch("x86_64") then
subdir = "android_x86_64"
end
if subdir then
table.insert(subdirs, path.join(sdkver or "*", subdir, "bin"))
end
table.insert(subdirs, path.join(sdkver or "*", "android", "bin"))
elseif is_plat("wasm") then
table.insert(subdirs, path.join(sdkver or "*", "wasm_*", "bin"))
else
table.insert(subdirs, path.join(sdkver or "*", "*", "bin"))
end
table.insert(subdirs, path.join("*", "bin"))
table.insert(subdirs, "bin")
-- init the search directories
local paths = {}
if sdkdir then
table.insert(paths, sdkdir)
end
if is_host("windows") then
-- we find it from /mingw64 first
if is_subhost("msys") then
local mingw_prefix = os.getenv("MINGW_PREFIX")
if mingw_prefix and os.isdir(mingw_prefix) then
table.insert(paths, mingw_prefix)
end
end
-- add paths from registry
local regs =
{
"HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.c\\shell\\Open\\Command",
"HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command",
"HKEY_CLASSES_ROOT\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command",
"HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.c\\shell\\Open\\Command",
"HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.cpp\\shell\\Open\\Command",
"HKEY_CURRENT_USER\\SOFTWARE\\Classes\\Applications\\QtProject.QtCreator.pro\\shell\\Open\\Command"
}
for _, reg in ipairs(regs) do
table.insert(paths, function ()
local value = val("reg " .. reg)
if value then
local p = value:find("\\Tools\\QtCreator", 1, true)
if p then
return path.translate(value:sub(1, p - 1))
end
end
end)
end
-- add root logical drive pates, e.g. C:/Qt/Qtx.x.x, D:/Qtx.x.x ..
for idx, drive in ipairs(winos.logical_drives()) do
if idx < 5 then
table.insert(paths, path.join(drive, "Qt", "Qt*"))
else
break
end
end
else
for _, dir in ipairs(os.dirs("~/Qt*")) do
table.insert(paths, dir)
end
end
-- special case for android on windows, where qmake is a .bat from version 6.3
-- this case also applys to wasm
if is_host("windows") and is_plat("android", "wasm") then
local qmake = find_file("qmake.bat", paths, {suffixes = subdirs})
if qmake then
return path.directory(path.directory(qmake)), qmake
end
end
-- attempt to find qmake
local qmake
if is_host("windows") then
qmake = find_file("qmake.exe", paths, {suffixes = subdirs})
else
-- @see https://github.com/xmake-io/xmake/issues/4881
if sdkver then
local major = sdkver:sub(1, 1)
qmake = find_file("qmake" .. major, paths, {suffixes = subdirs})
end
if not qmake then
qmake = find_file("qmake", paths, {suffixes = subdirs})
end
end
if qmake then
return path.directory(path.directory(qmake)), qmake
end
end
-- find qmake
function _find_qmake(sdkdir, sdkver)
-- we attempt to find qmake from qt sdkdir first
local sdkdir, qmakefile = _find_sdkdir(sdkdir, sdkver)
if qmakefile then
return qmakefile
end
-- try finding qmake with the specific version, e.g. /usr/bin/qmake6
-- https://github.com/xmake-io/xmake/pull/3555
local qmake
if sdkver then
sdkver = semver.try_parse(sdkver)
if sdkver then
local cachekey = "qmake-" .. sdkver:major()
qmake = find_tool("qmake", {program = "qmake" .. sdkver:major(), cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
end
end
-- we need to find the default qmake in current system
-- maybe we only installed qmake6
if not qmake then
local suffixes = {"", "6", "-qt5"}
for _, suffix in ipairs(suffixes) do
local cachekey = "qmake-" .. suffix
qmake = find_tool("qmake", {program = "qmake" .. suffix, cachekey = cachekey, paths = sdkdir and path.join(sdkdir, "bin")})
if qmake then
break
end
end
end
if qmake then
return qmake.program
end
end
-- get qt environment
function _get_qtenvs(qmake)
local envs = {}
local results = try {function () return os.iorunv(qmake, {"-query"}) end}
if results then
for _, qtenv in ipairs(results:split('\n', {plain = true})) do
local kv = qtenv:split(':', {plain = true, limit = 2}) -- @note set limit = 2 for supporting value with win-style path, e.g. `key:C:\xxx`
if #kv == 2 then
envs[kv[1]] = kv[2]:trim()
end
end
end
return envs
end
-- find qt sdk toolchains
function _find_qt(sdkdir, sdkver)
-- find qmake
local qmake = _find_qmake(sdkdir, sdkver)
if not qmake then
return
end
-- get qt environments
local qtenvs = _get_qtenvs(qmake)
if not qtenvs then
return
end
-- get qt toolchains
sdkdir = qtenvs.QT_INSTALL_PREFIX
local sdkver = qtenvs.QT_VERSION
local bindir = qtenvs.QT_INSTALL_BINS
local libexecdir = qtenvs.QT_INSTALL_LIBEXECS
local qmldir = qtenvs.QT_INSTALL_QML
local libdir = qtenvs.QT_INSTALL_LIBS
local pluginsdir = qtenvs.QT_INSTALL_PLUGINS
local includedir = qtenvs.QT_INSTALL_HEADERS
local mkspecsdir = qtenvs.QMAKE_MKSPECS or path.join(qtenvs.QT_INSTALL_ARCHDATA, "mkspecs")
-- for 6.2
local bindir_host = qtenvs.QT_HOST_BINS
if not bindir_host and libexecdir and is_plat("android", "iphoneos") then
local rootdir = path.directory(path.directory(bindir))
if is_host("macosx") then
bindir_host = path.join(rootdir, "macos", "bin")
else
-- TODO
end
end
local libexecdir_host = qtenvs.QT_HOST_LIBEXECS
if not libexecdir_host and libexecdir and is_plat("android", "iphoneos") then
local rootdir = path.directory(path.directory(libexecdir))
if is_host("macosx") then
libexecdir_host = path.join(rootdir, "macos", "libexec")
else
-- TODO
end
end
return {sdkdir = sdkdir, bindir = bindir, bindir_host = bindir_host, libexecdir = libexecdir, libexecdir_host = libexecdir_host, libdir = libdir, includedir = includedir, qmldir = qmldir, pluginsdir = pluginsdir, mkspecsdir = mkspecsdir, sdkver = sdkver}
end
-- find qt sdk toolchains
--
-- @param sdkdir the qt sdk directory
-- @param opt the argument options, e.g. {verbose = true, force = false, version = "5.9.1"}
--
-- @return the qt sdk toolchains. e.g. {sdkver = ..., sdkdir = ..., bindir = .., linkdirs = ..., includedirs = ..., .. }
--
-- @code
--
-- local toolchains = find_qt("~/Qt")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_qt"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.qt and cacheinfo.qt.sdkdir and os.isdir(cacheinfo.qt.sdkdir) then
return cacheinfo.qt
end
-- find qt
local qt = _find_qt(sdkdir or config.get("qt") or global.get("qt") or config.get("sdk"), opt.version or config.get("qt_sdkver"))
if qt then
-- save to config
config.set("qt", qt.sdkdir, {force = true, readonly = true})
config.set("qt_sdkver", qt.sdkver, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Qt SDK directory ... ${color.success}%s", qt.sdkdir)
if qt.sdkver then
cprint("checking for Qt SDK version ... ${color.success}%s", qt.sdkver)
else
cprint("checking for Qt SDK version ... ${color.nothing}${text.nothing}")
end
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Qt SDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.qt = qt or false
detectcache:set(key, cacheinfo)
detectcache:save()
return qt
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_matlab_runtime.lua | --!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 find_matlab_runtime.lua
--
-- imports
import("detect.sdks.matlab")
-- find matlab runtime sdk
--
-- @return the matlab runtime sdk. e.g. {sdkdir = ..., includedirs = ..., linkdirs = ..., .. }
--
-- @code
--
-- local sdk = find_matlab_runtime(opt)
--
-- @endcode
--
function main(opt)
opt = opt or {}
local version = opt.require_version and tostring(opt.require_version) or nil
local result = {sdkdir = "", includedirs = {}, linkdirs = {}, links = {}, bindirs = {}}
if is_host("windows") then
local matlabkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB Runtime"
local valuekeys = winos.registry_keys(matlabkey)
if #valuekeys == 0 then
return
end
local itemkey
local versionname
local versionvalue
if version == nil then
local splitvaluekeys = valuekeys[1]:split("\\")
versionvalue = splitvaluekeys[#splitvaluekeys]
versionname = matlab.versions()[versionvalue]
itemkey = valuekeys[1] .. ";MATLABROOT"
else
versionname = matlab.versions()[version]
if versionname ~= nil then
versionvalue = matlab.versions_names()[versionname:lower()]
itemkey = matlabkey .. "\\" .. version .. ";MATLABROOT"
else
versionvalue = matlab.versions_names()[version:lower()]
versionname = matlab.versions()[versionvalue]
if versionvalue ~= nil then
itemkey = matlabkey .. "\\" .. versionvalue .. ";MATLABROOT"
else
print("allowed values are:")
for k, v in pairs(matlab.versions()) do
print(" ", k, v)
end
raise("MATLAB Runtime version does not exist: " .. version)
end
end
end
local sdkdir = try {function () return winos.registry_query(itemkey) end}
if not sdkdir then
return
end
sdkdir = sdkdir .. "\\v" .. versionvalue:gsub("%.", "")
result.sdkdir = sdkdir
result.includedirs = path.join(sdkdir, "extern", "include")
result.bindirs = {
path.join(sdkdir, "bin", "win64"),
path.join(sdkdir, "runtime", "win64"),
}
for _, value in ipairs(os.dirs(path.join(sdkdir, "extern", "lib", "**"))) do
local dirbasename = path.basename(value)
if not dirbasename:startswith("win") then
result.linkdirs[dirbasename] = value
end
end
for _, value in pairs(result.linkdirs) do
local dirbasename = path.basename(value)
result.links[dirbasename] = {}
for _, filepath in ipairs(os.files(value.."/*.lib")) do
table.insert(result.links[dirbasename], path.basename(filepath))
end
result.links[dirbasename] = table.unique(result.links[dirbasename])
end
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_matlab.lua | --!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 jacklin
-- @file find_matlab.lua
--
-- imports
import("detect.sdks.matlab")
-- find matlab sdk toolchains
--
-- @return the matlab sdk toolchains. e.g. {sdkdir = ..., includedirs = ..., linkdirs = ..., .. }
--
-- @code
--
-- local toolchains = find_matlab(opt)
--
-- @endcode
--
function main(opt)
opt = opt or {}
local version = opt.require_version and tostring(opt.require_version) or nil
local result = {sdkdir = "", includedirs = {}, linkdirs = {}, links = {}}
if is_host("windows") then
local matlabkey = "HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB"
local valuekeys = winos.registry_keys(matlabkey)
if #valuekeys == 0 then
return
end
local itemkey
if version == nil then
itemkey = valuekeys[1] .. ";MATLABROOT"
else
local versionname = matlab.versions()[version]
if versionname ~= nil then
itemkey = matlabkey .. "\\" .. version .. ";MATLABROOT"
else
local versionvalue = matlab.versions_names()[version:lower()]
if versionvalue ~= nil then
itemkey = matlabkey .. "\\" .. versionvalue .. ";MATLABROOT"
else
print("allowed values are:")
for k, v in pairs(matlab.versions()) do
print(" ", k, v)
end
raise("MATLAB Runtime version does not exist: " .. version)
end
end
end
local sdkdir = try {function () return winos.registry_query(itemkey) end}
if not sdkdir then
return
end
result.sdkdir = sdkdir
result.includedirs = path.join(sdkdir, "extern", "include")
for _, value in ipairs(os.dirs(path.join(sdkdir, "extern", "lib", "**"))) do
local dirbasename = path.basename(value)
if not dirbasename:startswith("win") then
result.linkdirs[dirbasename] = value
end
end
for _, value in pairs(result.linkdirs) do
local dirbasename = path.basename(value)
result.links[dirbasename] = {}
for _, filepath in ipairs(os.files(value.."/*.lib")) do
table.insert(result.links[dirbasename], path.basename(filepath))
end
result.links[dirbasename] = table.unique(result.links[dirbasename])
end
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_hdk.lua | --!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 ruki
-- @file find_hdk.lua
--
-- imports
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_directory")
-- find hdk directory
function _find_hdkdir(sdkdir)
-- get hdk directory
if not sdkdir then
if not sdkdir then
if is_host("macosx") then
sdkdir = find_directory("native", "~/Library/Huawei/Sdk/*/*")
elseif is_host("windows") then
sdkdir = find_directory("native", "~/Huawei/Sdk/*/*")
end
end
end
-- get hdk directory
if sdkdir and os.isdir(sdkdir) then
return path.translate(sdkdir)
end
end
-- find the hdk toolchain
function _find_hdk(sdkdir)
-- find hdk root directory
sdkdir = _find_hdkdir(sdkdir)
if not sdkdir then
return
end
-- get the binary directory
local bindir = path.join(sdkdir, "llvm", "bin")
if not os.isdir(bindir) then
return
end
local sysroot = path.join(sdkdir, "sysroot")
return {sdkdir = sdkdir,
bindir = bindir,
sysroot = sysroot}
end
-- find hdk toolchains
--
-- @param sdkdir the hdk directory
-- @param opt the argument options
-- e.g. {verbose = true, force = false}
--
-- @return the hdk toolchains. e.g. {bindir = .., cross = ..}
--
-- @code
--
-- local toolchain = find_hdk("/xxx/android-hdk-r10e")
--
-- @endcode
--
function main(sdkdir, opt)
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_hdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.hdk and cacheinfo.hdk.sdkdir and os.isdir(cacheinfo.hdk.sdkdir) then
return cacheinfo.hdk
end
-- find hdk
local hdk = _find_hdk(sdkdir or config.get("sdk") or global.get("sdk"))
if hdk and hdk.sdkdir then
config.set("hdk", hdk.sdkdir, {force = true, readonly = true})
if opt.verbose or option.get("verbose") then
cprint("checking for Harmony SDK directory ... ${color.success}%s", hdk.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for Harmony SDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.hdk = hdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return hdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_mdk.lua | --!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 ruki
-- @file find_mdk.lua
--
-- imports
import("lib.detect.find_path")
import("core.base.option")
import("core.base.semver")
import("core.project.config")
import("core.cache.detectcache")
-- find MDK directory
function _find_sdkdir(sdkdir)
local paths = {
"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Keil\\Products\\MDK;Path)"
}
if sdkdir then
table.insert(paths, 1, sdkdir)
end
local result = find_path("armcc", paths) or find_path("armclang", paths)
if not result then
-- find it from some logical drives paths
paths = {}
for _, logical_drive in ipairs(winos.logical_drives()) do
table.insert(paths, path.join(logical_drive, "Keil_v5", "ARM"))
end
result = find_path("armcc", paths) or find_path("armclang", paths)
end
return result
end
-- find MDK toolchains
function _find_mdk(sdkdir)
-- find mdk directory
sdkdir = _find_sdkdir(sdkdir)
if not sdkdir or not os.isdir(sdkdir) then
return nil
end
local result = {sdkdir = sdkdir}
-- get sdk version
local sdkver = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Keil\\Products\\MDK;Version")
if sdkver then
sdkver = semver.match(sdkver, 1, "V%d+%.%d+")
if sdkver then
result.sdkver = sdkver:rawstr()
end
end
-- armcc sdk directory
local sdkdir_armcc = path.join(sdkdir, "armcc")
if os.isdir(sdkdir_armcc) and os.isfile(path.join(sdkdir_armcc, "bin", "armcc.exe")) then
result.sdkdir_armcc = sdkdir_armcc
end
-- armclang sdk directory
local sdkdir_armclang = path.join(sdkdir, "armclang")
if os.isdir(sdkdir_armclang) and os.isfile(path.join(sdkdir_armclang, "bin", "armclang.exe")) then
result.sdkdir_armclang = sdkdir_armclang
end
return result
end
-- find MDK toolchains
--
-- @param sdkdir the MDK directory
-- @param opt the argument options, e.g. {verbose = true, force = false}
--
-- @return the MDK toolchains. e.g. {sdkver = ..., sdkdir, sdkdir_armcc, sdkdir_armclang}
--
-- @code
--
-- local toolchains = find_mdk("~/mdk")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_mdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.mdk and cacheinfo.mdk.sdkdir and os.isdir(cacheinfo.mdk.sdkdir) then
return cacheinfo.mdk
end
-- find mdk
local mdk = _find_mdk(sdkdir or config.get("sdk"))
if mdk then
if opt.verbose or option.get("verbose") then
cprint("checking for MDK directory ... ${color.success}%s", mdk.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for MDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.mdk = mdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return mdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_vcpkgdir.lua | --!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 ruki
-- @file find_vcpkgdir.lua
--
-- imports
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_tool")
-- find vcpkgdir
function main()
local vcpkgdir = detectcache:get("detect.sdks.find_vcpkgdir")
if vcpkgdir == nil then
if not vcpkgdir then
vcpkgdir = config.get("vcpkg") or global.get("vcpkg")
if vcpkgdir then
if os.isfile(vcpkgdir) then
vcpkgdir = path.directory(vcpkgdir)
end
end
end
if not vcpkgdir then
vcpkgdir = os.getenv("VCPKG_ROOT") or os.getenv("VCPKG_INSTALLATION_ROOT")
end
if not vcpkgdir and is_host("macosx", "linux") then
local brew = find_tool("brew")
if brew then
dir = try
{
function ()
return os.iorunv(brew.program, {"--prefix", "vcpkg"})
end
}
end
if dir then
dir = path.join(dir:trim(), "libexec")
if os.isdir(path.join(dir, "installed")) then
vcpkgdir = dir
end
end
end
if not vcpkgdir and is_host("windows") then
-- attempt to read path info after running `vcpkg integrate install`
local pathfile = "~/../Local/vcpkg/vcpkg.path.txt"
if os.isfile(pathfile) then
local dir = io.readfile(pathfile):trim()
if os.isdir(dir) then
vcpkgdir = dir
end
end
end
detectcache:set("detect.sdks.find_vcpkgdir", vcpkgdir or false)
detectcache:save()
end
return vcpkgdir or nil
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/matlab.lua | --!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
--
-- get matlab versions
function 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 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_ndk.lua | --!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 ruki
-- @file find_ndk.lua
--
-- imports
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_directory")
-- get triple
function _get_triple(arch)
local triples =
{
["armv5te"] = "arm-linux-androideabi" -- deprecated
, ["armv7-a"] = "arm-linux-androideabi" -- deprecated
, ["armeabi"] = "arm-linux-androideabi" -- removed in ndk r17
, ["armeabi-v7a"] = "arm-linux-androideabi"
, ["arm64-v8a"] = "aarch64-linux-android"
, i386 = "i686-linux-android" -- deprecated
, x86 = "i686-linux-android"
, x86_64 = "x86_64-linux-android"
, mips = "mips-linux-android" -- removed in ndk r17
, mips64 = "mips64-linux-android" -- removed in ndk r17
}
return triples[arch]
end
-- find ndk directory
function _find_ndkdir(sdkdir)
-- get ndk directory
if not sdkdir then
sdkdir = os.getenv("ANDROID_NDK_HOME") or os.getenv("ANDROID_NDK_ROOT")
if not sdkdir and config.get("android_sdk") then
local ndkbundle = path.join(config.get("android_sdk"), "ndk-bundle")
if os.isdir(ndkbundle) then
sdkdir = ndkbundle
end
end
if not sdkdir and is_host("macosx") then
sdkdir = find_directory("NDK", "/Applications/AndroidNDK*.app/Contents")
if not sdkdir then
sdkdir = "~/Library/Android/sdk/ndk-bundle"
end
end
end
-- get ndk directory
if sdkdir and os.isdir(sdkdir) then
return path.translate(sdkdir)
end
end
-- find the sdk version of ndk
function _find_ndk_sdkver(sdkdir, bindir, sysroot, arch)
-- uses llvm stl?
local use_llvm = false
local ndk_cxxstl = config.get("ndk_cxxstl")
if ndk_cxxstl then
-- we uses c++_static/c++_shared instead of llvmstl_static/llvmstl_shared
if ndk_cxxstl:startswith("c++") or ndk_cxxstl:startswith("llvmstl") then
use_llvm = true
end
elseif bindir and bindir:find("llvm", 1, true) then
use_llvm = true
end
-- get triple
local triple = _get_triple(arch)
assert(triple, "no triple found for arch %s (wrong arch?)", arch)
-- try to select the best compatible version
local sdkver = "16"
if use_llvm or arch == "arm64-v8a" then
sdkver = "21"
end
if sysroot then
if os.isdir(path.join(sysroot, "usr", "lib", triple, sdkver)) then
return sdkver
end
end
if os.isdir(path.join(sdkdir, "platforms", "android-" .. sdkver)) then
return sdkver
end
-- find the max version
local sdkver_max = 0
local sdkver_dir_pattern
if sysroot and os.isdir(path.join(sysroot, "usr", "lib")) then
sdkver_dir_pattern = path.join(sysroot, "usr", "lib", triple, "*")
else
sdkver_dir_pattern = path.join(sdkdir, "platforms", "android-*")
end
for _, sdkdir in ipairs(os.dirs(sdkver_dir_pattern)) do
-- get version
local filename = path.filename(sdkdir)
local version, count = filename:gsub("android%-", "")
if count > 0 then
-- get the max version
local sdkver_now = tonumber(version)
if sdkver_now > sdkver_max then
sdkver_max = sdkver_now
end
end
end
-- get the max sdk version
return sdkver_max > 0 and tostring(sdkver_max) or nil
end
-- find the toolchains version of ndk
function _find_ndk_toolchains_ver(bindir)
return bindir:match("%-(%d*%.%d*)[/\\]")
end
-- find sysroot directory
function _find_ndk_sysroot(sdkdir)
-- get sysroot above ndk r22
-- @see https://github.com/android/ndk/wiki/Changelog-r22
local prebuilt = (is_host("macosx") and "darwin" or os.host()) .. "-x86_64"
local sysroot_r22 = path.join(sdkdir, "toolchains", "llvm", "prebuilt", prebuilt, "sysroot")
if os.isdir(sysroot_r22) then
return sysroot_r22
end
-- get sysroot above ndk r14
-- @see https://android.googlesource.com/platform/ndk/+/master/docs/UnifiedHeaders.md
local sysroot_r14 = path.join(sdkdir, "sysroot")
if os.isdir(sysroot_r14) then
return sysroot_r14
end
end
-- find the ndk toolchain
function _find_ndk(sdkdir, arch, ndk_sdkver, ndk_toolchains_ver)
-- find ndk root directory
sdkdir = _find_ndkdir(sdkdir)
if not sdkdir then
return
end
-- get cross
local crosses =
{
["armv5te"] = "arm-linux-androideabi-" -- deprecated
, ["armv7-a"] = "arm-linux-androideabi-" -- deprecated
, ["armeabi"] = "arm-linux-androideabi-" -- removed in ndk r17
, ["armeabi-v7a"] = "arm-linux-androideabi-"
, ["arm64-v8a"] = "aarch64-linux-android-"
, i386 = "i686-linux-android-" -- deprecated
, x86 = "i686-linux-android-"
, x86_64 = "x86_64-linux-android-"
, mips = "mips-linux-android-" -- removed in ndk r17
, mips64 = "mips64-linux-android-" -- removed in ndk r17
}
local cross = crosses[arch]
-- get gcc toolchain sub-directory
local gcc_toolchain_subdirs =
{
["armv5te"] = "arm-linux-androideabi-*"
, ["armv7-a"] = "arm-linux-androideabi-*"
, ["armeabi"] = "arm-linux-androideabi-*"
, ["armeabi-v7a"] = "arm-linux-androideabi-*"
, ["arm64-v8a"] = "aarch64-linux-android-*"
, i386 = "x86-*"
, x86 = "x86-*"
, x86_64 = "x86_64-*"
, mips = "mipsel-linux-android-*"
, mips64 = "mips64el-linux-android-*"
}
local gcc_toolchain_subdir = gcc_toolchain_subdirs[arch] or "arm-linux-androideabi-*"
-- find the binary directory
local llvm_toolchain
local prebuilt = (is_host("macosx") and "darwin" or os.host()) .. "-x86_64"
local bindir = find_directory("bin", path.join(sdkdir, "toolchains", "llvm", "prebuilt", prebuilt)) -- larger than ndk r16
if bindir then
llvm_toolchain = path.directory(bindir)
else
bindir = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*"))
end
if not bindir then
return
end
-- find the gcc toolchain
local gcc_toolchain = find_directory("bin", path.join(sdkdir, "toolchains", gcc_toolchain_subdir, "prebuilt", "*"))
if gcc_toolchain then
gcc_toolchain = path.directory(gcc_toolchain)
end
-- find the toolchains version
local toolchains_ver = ndk_toolchains_ver or _find_ndk_toolchains_ver(gcc_toolchain or bindir)
-- find sysroot directory
local sysroot = _find_ndk_sysroot(sdkdir)
-- find the sdk version
local sdkver = ndk_sdkver or _find_ndk_sdkver(sdkdir, bindir, sysroot, arch)
-- get ndk version, e.g. r16b, ..
local ndkver = nil
if sysroot then
local ndk_version_header = path.join(sysroot, "usr/include/android/ndk-version.h")
if os.isfile(ndk_version_header) then
local ndk_version_info = io.readfile(ndk_version_header)
if ndk_version_info then
ndk_version_info = ndk_version_info:match("#define __NDK_MAJOR__ (%d+)")
if ndk_version_info then
ndkver = tonumber(ndk_version_info)
end
end
end
end
return {ndkver = ndkver,
sdkdir = sdkdir,
bindir = bindir,
cross = cross,
sdkver = sdkver,
llvm_toolchain = llvm_toolchain, -- >= ndk r22
gcc_toolchain = gcc_toolchain,
toolchains_ver = toolchains_ver,
sysroot = sysroot}
end
-- find ndk toolchains
--
-- @param sdkdir the ndk directory
-- @param opt the argument options
-- e.g. {arch = "[armeabi|armeabi-v7a|arm64-v8a]", verbose = true, force = false, sdkver = 19, toolchains_ver = "4.9"}
--
-- @return the ndk toolchains. e.g. {bindir = .., cross = ..}
--
-- @code
--
-- local toolchain = find_ndk("/xxx/android-ndk-r10e")
-- local toolchain = find_ndk("/xxx/android-ndk-r10e", {arch = "arm64-v8a"})
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_ndk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.ndk and cacheinfo.ndk.sdkdir and os.isdir(cacheinfo.ndk.sdkdir) then
return cacheinfo.ndk
end
-- get arch
local arch = opt.arch or config.get("arch") or "armeabi-v7a"
-- find ndk
local ndk = _find_ndk(sdkdir or config.get("ndk") or global.get("ndk"), arch, opt.sdkver or config.get("ndk_sdkver"), opt.toolchains_ver or config.get("ndk_toolchains_ver"))
if ndk and ndk.sdkdir then
config.set("ndk", ndk.sdkdir, {force = true, readonly = true})
config.set("ndkver", ndk.ndkver, {force = true, readonly = true})
config.set("ndk_sdkver", ndk.sdkver, {force = true, readonly = true})
config.set("ndk_toolchains_ver", ndk.toolchains_ver, {force = true, readonly = true})
if opt.verbose or option.get("verbose") then
cprint("checking for NDK directory ... ${color.success}%s", ndk.sdkdir)
cprint("checking for SDK version of NDK ... ${color.success}%s", ndk.sdkver)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for NDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.ndk = ndk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return ndk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_wdk.lua | --!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 ruki
-- @file find_wdk.lua
--
-- imports
import("lib.detect.find_file")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.tool.toolchain")
import("core.cache.detectcache")
import("detect.sdks.find_vstudio")
-- find WDK directory
function _find_sdkdir(sdkdir)
-- get sdk directory from the environment variables first
if not sdkdir then
sdkdir = os.getenv("WindowsSdkDir")
end
-- get sdk directory from vcvars
if not sdkdir then
local msvc = toolchain.load("msvc")
if msvc and msvc:check() then
local vcvars = msvc:config("vcvars")
if vcvars then
sdkdir = vcvars.WindowsSdkDir
end
end
end
return sdkdir
end
-- find umdf version
function _find_umdfver(libdir, includedir)
-- find versions
local versions = {}
for _, p in ipairs(os.files(path.join(includedir, "wdf", "umdf", "*", "wdf.h"))) do
table.insert(versions, path.filename(path.directory(p)))
end
-- find version
local arch = config.arch() or os.arch()
if arch then
for _, ver in ipairs(versions) do
if os.isfile(path.join(libdir, "wdf", "umdf", arch, ver, "WdfDriverStubUm.lib")) then
return ver
end
end
end
end
-- find kmdf version
function _find_kmdfver(libdir, includedir)
-- find versions
local versions = {}
for _, p in ipairs(os.files(path.join(includedir, "wdf", "kmdf", "*", "wdf.h"))) do
table.insert(versions, path.filename(path.directory(p)))
end
-- find version
local arch = config.arch() or os.arch()
if arch then
for _, ver in ipairs(versions) do
if os.isfile(path.join(libdir, "wdf", "kmdf", arch, ver, "wdfdriverentry.lib")) then
return ver
end
end
end
end
-- find WDK toolchains
function _find_wdk(sdkdir, sdkver)
-- find wdk directory
sdkdir = _find_sdkdir(sdkdir)
if not sdkdir or not os.isdir(sdkdir) then
return nil
end
-- get sdk version
if not sdkver then
local vers = {}
for _, dir in ipairs(os.dirs(path.join(sdkdir, "Include", "*", "km"))) do
table.insert(vers, path.filename(path.directory(dir)))
end
for _, ver in ipairs(vers) do
if os.isdir(path.join(sdkdir, "Lib", ver, "km")) and os.isdir(path.join(sdkdir, "Lib", ver, "um")) and os.isdir(path.join(sdkdir, "Include", ver, "um")) then
sdkver = ver
break
end
end
end
if not sdkver then
return nil
end
-- get the bin directory
local bindir = path.join(sdkdir, "bin")
-- get the lib directory
local libdir = path.join(sdkdir, "Lib")
-- get the include directory
local includedir = path.join(sdkdir, "Include")
-- get umdf version
local umdfver = _find_umdfver(libdir, includedir)
-- get kmdf version
local kmdfver = _find_kmdfver(libdir, includedir)
-- get toolchains
return {sdkdir = sdkdir, bindir = bindir, libdir = libdir, includedir = includedir, sdkver = sdkver, umdfver = umdfver, kmdfver = kmdfver}
end
-- find WDK toolchains
--
-- @param sdkdir the WDK directory
-- @param opt the argument options, e.g. {verbose = true, force = false, version = "5.9.1"}
--
-- @return the WDK toolchains. e.g. {sdkver = ..., sdkdir = ..., bindir = .., libdir = ..., includedir = ..., .. }
--
-- @code
--
-- local toolchains = find_wdk("~/wdk")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_wdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.wdk and cacheinfo.wdk.sdkdir and os.isdir(cacheinfo.wdk.sdkdir) then
return cacheinfo.wdk
end
-- find wdk
local wdk = _find_wdk(sdkdir or config.get("wdk") or global.get("wdk") or config.get("sdk"), opt.version or config.get("wdk_sdkver"))
if wdk then
-- save to config
config.set("wdk", wdk.sdkdir, {force = true, readonly = true})
config.set("wdk_sdkver", wdk.sdkver, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for WDK directory ... ${color.success}%s", wdk.sdkdir)
cprint("checking for WDK version ... ${color.success}%s", wdk.sdkver)
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for WDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.wdk = wdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return wdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_ifxenv.lua | --!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 ruki
-- @file find_ifxenv.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_tool")
-- init ifx variables
local ifxvars = {"path",
"lib",
"libpath",
"include",
"DevEnvdir",
"VSInstallDir",
"VCInstallDir",
"WindowsSdkDir",
"WindowsLibPath",
"WindowsSDKVersion",
"WindowsSdkBinPath",
"UniversalCRTSdkDir",
"UCRTVersion"}
-- load ifxvars_bat environment variables
function _load_ifxvars(ifxvars_bat, arch, opt)
-- make the genifxvars.bat
opt = opt or {}
local genifxvars_bat = os.tmpfile() .. "_genifxvars.bat"
local genifxvars_dat = os.tmpfile() .. "_genifxvars.txt"
local file = io.open(genifxvars_bat, "w")
file:print("@echo off")
file:print("call \"%s\" -arch %s > nul", ifxvars_bat, arch)
for idx, var in ipairs(ifxvars) do
file:print("echo " .. var .. " = %%" .. var .. "%% %s %s", idx == 1 and ">" or ">>", genifxvars_dat)
end
file:close()
-- run genifxvars.bat
os.run(genifxvars_bat)
-- load all envirnoment variables
local variables = {}
for _, line in ipairs((io.readfile(genifxvars_dat) or ""):split("\n")) do
local p = line:find('=', 1, true)
if p then
local name = line:sub(1, p - 1):trim()
local value = line:sub(p + 1):trim()
variables[name] = value
end
end
if not variables.path then
return
end
-- remove some empty entries
for _, name in ipairs(ifxvars) do
if variables[name] and #variables[name]:trim() == 0 then
variables[name] = nil
end
end
-- fix bin path for ia32
if variables.path and arch == "ia32" then
variables.path = variables.path:gsub("windows\\bin\\intel64;", "windows\\bin\\intel64_ia32;")
end
-- convert path/lib/include to PATH/LIB/INCLUDE
variables.PATH = variables.path
variables.LIB = variables.lib
variables.LIBPATH = variables.libpath
variables.INCLUDE = variables.include
variables.path = nil
variables.lib = nil
variables.include = nil
variables.libpath = nil
return variables
end
-- find intel llvm fortran envirnoment on windows
function _find_intel_on_windows(opt)
opt = opt or {}
-- find ifxvars_bat.bat
local paths = {"$(env ONEAPI_ROOT)"}
local ifxvars_bat = find_file("setvars.bat", paths)
if not ifxvars_bat then
paths = {}
local keys = winos.registry_keys("HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\Intel\\Compilers\\Fortran\\**")
for _, key in ipairs(keys) do
table.insert(paths, format("$(reg %s;ProductDir)", key))
end
ifxvars_bat = find_file("../../setvars.bat", paths)
end
if ifxvars_bat then
local ifxvars_x86 = _load_ifxvars(ifxvars_bat, "ia32", opt)
local ifxvars_x64 = _load_ifxvars(ifxvars_bat, "intel64", opt)
return {ifxvars_bat = ifxvars_bat, ifxvars = {x86 = ifxvars_x86, x64 = ifxvars_x64}}
end
end
-- find intel llvm fortran envirnoment on linux
function _find_intel_on_linux(opt)
-- attempt to find the sdk directory
local oneapi_rootdirs = {"~/intel/oneapi/compiler", "/opt/intel/oneapi/compiler"}
paths = {}
for _, rootdir in ipairs(oneapi_rootdirs) do
table.insert(paths, path.join(rootdir, "*", is_host("macosx") and "mac" or "linux", "bin"))
table.insert(paths, path.join(rootdir, "*", "bin"))
end
if #paths > 0 then
local ifx = find_file("ifx", paths)
if ifx then
local bindir = path.directory(ifx)
local sdkdir = path.directory(path.directory(bindir))
return {sdkdir = sdkdir, bindir = bindir}
end
end
end
-- find intel fortran environment
function main(opt)
if is_host("windows") then
return _find_intel_on_windows(opt)
else
return _find_intel_on_linux(opt)
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_sdasstm8.lua | --!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 ruki
-- @file find_sdasstm8.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find sdasstm8
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local sdasstm8 = find_sdasstm8()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.command = opt.command or "--version"
-- add search paths
local paths = {}
local bindir = get_config("bin")
if bindir and os.isdir(bindir) then
table.insert(paths, bindir)
end
if is_host("windows") then
table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\SDCC)\\bin")
end
if #paths > 0 then
opt.paths = paths
end
-- find program
local program = find_program(opt.program or "sdasstm8", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_cross_toolchain.lua | --!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 ruki
-- @file find_cross_toolchain.lua
--
-- imports
import("core.project.config")
import("lib.detect.find_file")
-- find bin directory and cross
function _find_bindir(sdkdir, opt)
-- init bin directories
local bindirs = {}
if opt.bindir then
table.insert(bindirs, opt.bindir)
end
table.insert(bindirs, path.join(sdkdir, "bin"))
-- attempt to find *-[gcc|clang|ld]
for _, toolname in ipairs({"gcc", "clang", "ld"}) do
if is_host("windows") then
toolname = toolname .. ".exe"
end
local toolpath = find_file((opt.cross or '*-') .. toolname, bindirs)
if toolpath then
return path.directory(toolpath), path.filename(toolpath):sub(1, -(#toolname + 1))
end
-- find tool path
if not opt.cross then
toolpath = find_file(toolname, bindirs)
if toolpath then
return path.directory(toolpath), ""
end
end
end
-- attempt to use the bin directory
local bindir = opt.bindir or path.join(sdkdir, "bin")
if os.isdir(bindir) and not opt.cross then
return bindir
end
end
-- find cross toolchain
--
-- @param sdkdir the root sdk directory of cross toolchain
-- @param opt the argument options
-- e.g. {bindir = .., cross = ..}
--
-- @return the toolchain e.g. {sdkdir = .., bindir = .., cross = ..}
--
-- @code
--
-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e")
-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-"})
-- local toolchain = find_cross_toolchain("/xxx/android-cross-r10e", {cross = "arm-linux-androideabi-", bindir = ..})
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- get sdk directories
local sdkdirs = {}
if sdkdir then
table.insert(sdkdirs, sdkdir)
elseif opt.cross and not is_subhost("windows") then
-- we attempt to find cross toolchain from /usr, e.g. /usr/bin/aarch64-linux-gnu-gcc
table.insert(sdkdirs, "/usr/")
table.insert(sdkdirs, "/usr/local")
end
-- find bin directory and cross
local result
for _, _sdkdir in ipairs(sdkdirs) do
if os.isdir(_sdkdir) then
local bindir, cross = _find_bindir(_sdkdir, opt)
if bindir then
result = {sdkdir = _sdkdir, bindir = bindir, cross = cross}
break
end
end
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_mingw.lua | --!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 ruki
-- @file find_mingw.lua
--
-- imports
import("lib.detect.find_path")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("detect.sdks.find_cross_toolchain")
-- find mingw directory
function _find_mingwdir(sdkdir)
-- get mingw directory
if not sdkdir then
if is_host("macosx", "linux") and os.isdir("/opt/llvm-mingw") then
sdkdir = "/opt/llvm-mingw"
elseif is_host("macosx") and os.isdir("/usr/local/opt/mingw-w64") then
-- for macOS Intel
sdkdir = "/usr/local/opt/mingw-w64"
elseif is_host("macosx") and os.isdir("/opt/homebrew/opt/mingw-w64") then
-- for Apple Silicon
sdkdir = "/opt/homebrew/opt/mingw-w64"
elseif is_host("linux") then
sdkdir = "/usr"
elseif is_subhost("msys") then
local mingw_prefix = os.getenv("MINGW_PREFIX")
if mingw_prefix and os.isdir(mingw_prefix) then
sdkdir = mingw_prefix
end
end
-- attempt to get it from $PATH
-- @see https://github.com/xmake-io/xmake/issues/977
if not sdkdir then
local pathenv = os.getenv("PATH")
if pathenv then
local buildhash_pattern = string.rep('%x', 32)
local match_pattern = "[\\/]packages[\\/]%w[\\/].*mingw.*[\\/][^\\/]+[\\/]" .. buildhash_pattern .. "[\\/]bin"
for _, p in ipairs(path.splitenv(pathenv)) do
if (p:find(match_pattern) or p:find(string.ipattern("mingw[%w%-%_%+]*[\\/]bin"))) and
path.filename(p) == "bin" and os.isdir(p) then
sdkdir = path.directory(p)
break
end
end
end
end
end
-- attempt to find mingw directory from the qt sdk
local qt = config.get("qt")
if not sdkdir and qt then
sdkdir = find_path("bin", path.join(qt, "Tools", "mingw*_" .. (is_arch("x86_64") and "64" or "32")))
end
-- get mingw directory
if sdkdir and os.isdir(sdkdir) then
return sdkdir
end
end
-- find the mingw toolchain
function _find_mingw(sdkdir, bindir, cross)
-- find mingw root directory
sdkdir = _find_mingwdir(sdkdir)
if not sdkdir then
return
end
-- select cross on macOS, e.g x86_64-w64-mingw32- or i686-w64-mingw32-
if not cross then
if is_arch("i386", "x86", "i686") then
cross = "i686-w64-mingw32-"
elseif is_arch("arm64", "aarch64") then
cross = "aarch64-w64-mingw32-" -- for llvm-mingw
elseif is_arch("arm.*") then
cross = "armv7-w64-mingw32-" -- for llvm-mingw
else
cross = "x86_64-w64-mingw32-"
end
end
-- find cross toolchain
local toolchain = find_cross_toolchain(sdkdir or bindir, {bindir = bindir, cross = cross})
if not toolchain then -- fallback, e.g. gcc.exe without cross
toolchain = find_cross_toolchain(sdkdir or bindir, {bindir = bindir})
end
if toolchain then
return {sdkdir = toolchain.sdkdir, bindir = toolchain.bindir, cross = toolchain.cross}
end
end
-- find mingw toolchains
--
-- @param sdkdir the mingw directory
-- @param opt the argument options
-- e.g. {verbose = true, force = false, bindir = .., cross = ...}
--
-- @return the mingw toolchains. e.g. {sdkdir = .., bindir = .., cross = ..}
--
-- @code
--
-- local toolchain = find_mingw("/xxx/android-mingw-r10e")
-- local toolchain = find_mingw("/xxx/android-mingw-r10e", {force = true, verbose = true})
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_mingw"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.mingw and cacheinfo.mingw.sdkdir and os.isdir(cacheinfo.mingw.sdkdir) then
return cacheinfo.mingw
end
-- find mingw
local mingw = _find_mingw(sdkdir or config.get("mingw") or global.get("mingw") or config.get("sdk"), opt.bindir or config.get("bin"), opt.cross or config.get("cross"))
if mingw and mingw.sdkdir then
-- save to config
config.set("mingw", mingw.sdkdir, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for mingw directory ... ${color.success}%s", mingw.sdkdir)
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for mingw directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.mingw = mingw or false
detectcache:set(key, cacheinfo)
detectcache:save()
return mingw
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_cuda.lua | --!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 ruki
-- @file find_cuda.lua
--
-- imports
import("lib.detect.find_file")
import("lib.detect.find_programver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
-- find cuda sdk directory
function _find_sdkdir(version)
-- init the search directories
local paths = {}
if version then
if is_host("macosx") then
table.insert(paths, format("/Developer/NVIDIA/CUDA-%s/bin", version))
elseif is_host("windows") then
table.insert(paths, format("$(env CUDA_PATH_V%s)/bin", version:gsub("%.", "_")))
table.insert(paths, format("C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v%s\\bin", version))
else
table.insert(paths, format("/usr/local/cuda-%s/bin", version))
end
else
if is_host("macosx") then
table.insert(paths, "/Developer/NVIDIA/CUDA/bin")
table.insert(paths, "/Developer/NVIDIA/CUDA*/bin")
elseif is_host("windows") then
table.insert(paths, "$(env CUDA_PATH)/bin")
table.insert(paths, "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\*\\bin")
else
-- find from default symbol link dir
table.insert(paths, "/usr/local/cuda/bin")
table.insert(paths, "/usr/local/cuda*/bin")
end
table.insert(paths, "$(env PATH)")
end
-- attempt to find nvcc
local nvcc = find_file(is_host("windows") and "nvcc.exe" or "nvcc", paths)
if nvcc then
return path.directory(path.directory(nvcc))
end
end
-- find cuda msbuild extensions
function _find_msbuildextensionsdir(sdkdir)
local props = find_file("CUDA *.props", {path.join(sdkdir, "extras", "visual_studio_integration", "MSBuildExtensions")})
if props then
return path.directory(props)
end
end
-- find cuda sdk toolchains
function _find_cuda(sdkdir)
-- check sdkdir
if sdkdir and not os.isdir(sdkdir) and not sdkdir:match("^[%d*]+%.[%d*]+$") then
raise("invalid cuda version/location: " .. sdkdir)
end
-- find cuda directory
if not sdkdir then
sdkdir = _find_sdkdir()
elseif sdkdir:match("^[%d*]+%.[%d*]+$") then
local cudaversion = sdkdir
sdkdir = _find_sdkdir(cudaversion)
if not sdkdir then
raise("cuda version %s not found!", cudaversion)
end
end
-- not found?
if not sdkdir or not os.isdir(sdkdir) then
return nil
end
-- get the bin directory
local bindir = path.join(sdkdir, "bin")
if not os.isexec(path.join(bindir, "nvcc")) then
return nil
end
-- get linkdirs
local linkdirs = {}
if is_host("windows") then
local subdir = is_arch("x64") and "x64" or "Win32"
table.insert(linkdirs, path.join(sdkdir, "lib", subdir))
elseif is_host("linux") and is_arch("x86_64", "arm64") then
table.insert(linkdirs, path.join(sdkdir, "lib64"))
else
table.insert(linkdirs, path.join(sdkdir, "lib"))
end
-- get includedirs
local includedirs = {path.join(sdkdir, "include")}
-- get version
local version = find_programver(path.join(bindir, "nvcc"), {parse = "release (%d+%.%d+),"})
-- find msbuildextensionsdir on windows
local msbuildextensionsdir
if is_host("windows") then
msbuildextensionsdir = _find_msbuildextensionsdir(sdkdir)
end
-- get toolchains
return {sdkdir = sdkdir, bindir = bindir, version = version, linkdirs = linkdirs, includedirs = includedirs, msbuildextensionsdir = msbuildextensionsdir}
end
-- find cuda sdk toolchains
--
-- @param sdkdir the cuda sdk directory or version
-- @param opt the argument options
--
-- @return the cuda sdk toolchains. e.g. {sdkdir = ..., bindir = .., linkdirs = ..., includedirs = ..., .. }
--
-- @code
--
-- local toolchains = find_cuda("/Developer/NVIDIA/CUDA-9.1")
-- local toolchains = find_cuda("9.1")
-- local toolchains = find_cuda("9.*")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_cuda"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.cuda and cacheinfo.cuda.sdkdir and os.isdir(cacheinfo.cuda.sdkdir) then
return cacheinfo.cuda
end
-- find cuda
local cuda = _find_cuda(sdkdir or config.get("cuda") or global.get("cuda") or config.get("sdk"))
if cuda then
-- save to config
config.set("cuda", cuda.sdkdir, {force = true, readonly = true})
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Cuda SDK directory ... ${color.success}%s", cuda.sdkdir)
end
else
-- trace
if opt.verbose or option.get("verbose") then
cprint("checking for Cuda SDK directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.cuda = cuda or false
detectcache:set(key, cacheinfo)
detectcache:save()
return cuda
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_vulkansdk.lua | --!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 xq114
-- @file find_vulkansdk.lua
--
-- imports
import("core.project.config")
import("lib.detect.find_file")
import("lib.detect.find_path")
import("lib.detect.find_library")
import("lib.detect.find_programver")
import("lib.detect.find_package")
-- find vulkan from paths
function _find_vulkan_from_paths(paths, opt)
opt = opt or {}
local arch = opt.arch or config.arch() or os.arch()
local plat = opt.plat or config.plat() or os.host()
local binsuffix = ((is_host("windows") and arch == "x86") and "bin32" or "bin")
local libname = (is_host("windows") and "vulkan-1" or "vulkan")
local libsuffix = ((is_host("windows") and arch == "x86") and "lib32" or "lib")
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}}
local linkinfo = find_library(libname, paths, {suffixes = {libsuffix}, plat = plat})
if linkinfo then
result.sdkdir = path.directory(linkinfo.linkdir)
result.bindir = path.join(result.sdkdir, binsuffix)
table.insert(result.linkdirs, linkinfo.linkdir)
table.insert(result.links, libname)
else
-- not found?
return
end
-- find headers
local incdir = find_path(path.join("vulkan", "vulkan.h"), paths, {suffixes = {"include"}})
if incdir then
table.insert(result.includedirs, incdir)
else
-- not found?
return
end
-- find api version
local vkinfo
if is_host("windows") then
if arch == "x86" then
vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin32"}})
else
vkinfo = find_file("vulkaninfoSDK.exe", paths, {suffixes = {"bin"}})
end
elseif is_host("linux") then
vkinfo = find_file("vulkaninfo", paths, {suffixes = {"bin"}})
end
if vkinfo then
local apiver = find_programver(vkinfo, {command = "--summary", parse = "Vulkan Instance Version: (%d+%.%d+%.%d+)"})
result.apiversion = apiver
end
return result
end
-- find vulkan from system
function _find_vulkan_from_system(opt)
local result = find_package("pkgconfig::vulkan", table.join({version = true}, opt))
if result then
result.apiversion = result.version
result.version = nil
if not result.apiversion then
local apiver = find_programver("vulkaninfo", {command = "--summary", parse = "Vulkan Instance Version: (%d+%.%d+%.%d+)"})
result.apiversion = apiver
end
end
return result
end
-- find vulkansdk
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
local paths = {
"$(env VK_SDK_PATH)",
"$(env VULKAN_SDK)"
}
local result = _find_vulkan_from_paths(paths, opt)
if not result then
result = _find_vulkan_from_system(opt)
end
if not result and is_host("linux") then
-- we attempt to find vulkan from /usr, e.g. /usr/include/vulkan/vulkan.h
paths = {"/usr", "/usr/local"}
result = _find_vulkan_from_paths(paths, opt)
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_c51.lua | --!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.
-- Based On template file xmake\modules\detect\sdks\find_mdk.lua
--
-- @author DawnMagnet
-- @file find_c51.lua
--
-- imports
import("lib.detect.find_path")
import("core.base.option")
import("core.base.semver")
import("core.project.config")
import("core.cache.detectcache")
-- find C51 directory
function _find_sdkdir(sdkdir)
local paths = {
"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Keil\\Products\\C51;Path)"
}
if sdkdir then
table.insert(paths, 1, sdkdir)
end
local result = find_path("..\\C51", paths)
if not result then
-- find it from some logical drives paths
paths = {}
for _, logical_drive in ipairs(winos.logical_drives()) do
table.insert(paths, path.join(logical_drive, "Keil_v5", "C51", "BIN"))
end
result = find_path("C51.exe", paths)
end
return result
end
-- find C51 toolchains
function _find_c51(sdkdir)
-- find C51 directory
sdkdir = _find_sdkdir(sdkdir)
if not sdkdir or not os.isdir(sdkdir) then
return nil
end
local result = {sdkdir = sdkdir}
-- get sdk version
local sdkver = winos.registry_query("HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Keil\\Products\\C51;Version")
if sdkver then
sdkver = semver.match(sdkver, 1, "V%d+%.%d+")
if sdkver then
result.sdkver = sdkver:rawstr()
end
end
-- c51(exe) sdk directory
if os.isfile(path.join(sdkdir, "bin", "c51.exe")) then
result.sdkdir_c51 = sdkdir
end
-- a51(exe) sdk directory
if os.isfile(path.join(sdkdir, "bin", "a51.exe")) then
result.sdkdir_a51 = sdkdir
end
return result
end
-- find c51 toolchains
--
-- @param sdkdir the C51 directory
-- @param opt the argument options, e.g. {verbose = true, force = false}
--
-- @return the C51 toolchains. e.g. {sdkver = ..., sdkdir, sdkdir_armcc, sdkdir_armclang, sdkdir_c51}
--
-- @code
--
-- local toolchains = find_c51("~/c51")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_c51"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.c51 and cacheinfo.c51.sdkdir and os.isdir(cacheinfo.c51.sdkdir) then
return cacheinfo.c51
end
-- find c51
local c51 = _find_c51(sdkdir or config.get("sdk"))
if c51 then
if opt.verbose or option.get("verbose") then
cprint("checking for c51 directory ... ${color.success}%s", c51.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for c51 directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.c51 = c51 or false
detectcache:set(key, cacheinfo)
detectcache:save()
return c51
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_xcode.lua | --!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 ruki
-- @file find_xcode.lua
--
-- imports
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_directory")
import("private.tools.codesign")
-- find xcode directory
function _find_sdkdir(sdkdir, opt)
if sdkdir and os.isdir(sdkdir) then
return sdkdir
end
return find_directory("Xcode.app", {"/Applications"}) or find_directory("Xcode*.app", {"/Applications"})
end
-- find the sdk version of xcode
function _find_xcode_sdkver(sdkdir, opt)
-- select platform sdkdir
local plat = opt.plat
local arch = opt.arch
local platsdkdir = nil
if plat == "iphoneos" then
if arch == "i386" or arch == "x86_64" then
platsdkdir = "Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator*.*.sdk"
else
platsdkdir = "Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.*.sdk"
end
elseif plat == "watchos" then
if arch == "i386" or arch == "x86_64" then
platsdkdir = "Contents/Developer/Platforms/WatchSimulator.platform/Developer/SDKs/WatchSimulator*.*.sdk"
else
platsdkdir = "Contents/Developer/Platforms/WatchOS.platform/Developer/SDKs/WatchOS*.*.sdk"
end
elseif plat == "appletvos" then
if arch == "i386" or arch == "x86_64" then
platsdkdir = "Contents/Developer/Platforms/AppleTVSimulator.platform/Developer/SDKs/AppleTVSimulator*.*.sdk"
else
platsdkdir = "Contents/Developer/Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS*.*.sdk"
end
elseif plat == "applexros" then
if arch == "i386" or arch == "x86_64" then
platsdkdir = "Contents/Developer/Platforms/XRSimulator.platform/Developer/SDKs/XRSimulator*.*.sdk"
else
platsdkdir = "Contents/Developer/Platforms/XROS.platform/Developer/SDKs/XROS*.*.sdk"
end
else
platsdkdir = "Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX*.*.sdk"
end
-- attempt to find the platform directory and get sdk version
if platsdkdir then
local dir = find_directory(platsdkdir, sdkdir)
if dir then
local basename = path.basename(dir)
return basename:match("%d+%.%d+")
end
end
end
-- find the target minver
function _find_target_minver(sdkdir, sdkver, opt)
opt = opt or {}
local target_minver = sdkver
if opt.plat == "macosx" then
if opt.appledev == "catalyst" then
local platsdkdir = "Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS*.*.sdk"
local dir = find_directory(platsdkdir, sdkdir)
if dir then
local basename = path.basename(dir)
target_minver = basename:match("%d+%.%d+")
else
target_minver = "13.1"
end
else
local macos_ver = macos.version()
if macos_ver and (not sdkver or macos_ver:le(sdkver)) then
target_minver = macos_ver:major() .. "." .. macos_ver:minor()
end
end
end
return target_minver
end
-- find the xcode toolchain
function _find_xcode(sdkdir, opt)
-- find xcode root directory
sdkdir = _find_sdkdir(sdkdir, opt)
if not sdkdir then
return {}
end
-- find the sdk version
local sdkver = opt.sdkver or _find_xcode_sdkver(sdkdir, opt)
if not sdkver then
return {}
end
-- find the target minver
local target_minver = _find_target_minver(sdkdir, sdkver, opt)
-- find codesign
local codesign_identity, mobile_provision
if opt.find_codesign then
-- find codesign identity
codesign_identity = config.get("xcode_codesign_identity")
if codesign_identity == nil then -- we will disable codesign_identity if be false
codesign_identity = global.get("xcode_codesign_identity")
end
if codesign_identity == nil then
local codesign_identities = codesign.codesign_identities()
if codesign_identities then
for identity, _ in pairs(codesign_identities) do
codesign_identity = identity
break
end
end
end
-- find mobile provision only for iphoneos
if opt.plat == "iphoneos" then
local mobile_provisions = codesign.mobile_provisions()
if mobile_provisions then
mobile_provision = config.get("xcode_mobile_provision")
if mobile_provision == nil then -- we will disable mobile_provision if be false
mobile_provision = global.get("xcode_mobile_provision")
end
if mobile_provision == nil then
for provision, _ in pairs(mobile_provisions) do
mobile_provision = provision
break
end
-- valid mobile provision not found? reset it
elseif not mobile_provisions[mobile_provision] then
mobile_provision = nil
end
end
end
end
return {sdkdir = sdkdir, sdkver = sdkver, target_minver = target_minver, codesign_identity = codesign_identity, mobile_provision = mobile_provision}
end
-- find xcode toolchain
--
-- @param sdkdir the xcode directory
-- @param opt the argument options
-- e.g. {verbose = true, force = false, sdkver = 19, find_codesign = true}
--
-- @return the xcode toolchain. e.g. {bindir = .., cross = ..}
--
-- @code
--
-- local toolchain = find_xcode("/Applications/Xcode.app")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_xcode"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.xcode and cacheinfo.xcode.sdkdir and os.isdir(cacheinfo.xcode.sdkdir) then
return cacheinfo.xcode
end
-- get plat and arch
local plat = opt.plat or config.get("plat") or os.host()
local arch = opt.arch or config.get("arch") or os.arch()
-- find xcode
local xcode = _find_xcode(sdkdir or config.get("xcode") or global.get("xcode"), opt)
-- save to cache
cacheinfo.xcode = xcode or false
detectcache:set(key, cacheinfo)
detectcache:save()
return xcode
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/sdks/find_emsdk.lua | --!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 SirLynix
-- @file find_emsdk.lua
--
-- imports
import("core.base.semver")
import("core.base.option")
import("core.base.global")
import("core.project.config")
import("core.cache.detectcache")
import("lib.detect.find_file")
-- find sdk directory
function _find_emsdkdir(sdkdir)
local paths = {}
if sdkdir then
table.insert(paths, sdkdir)
end
table.insert(paths, "$(env EMSDK)")
local emsdk = find_file("emsdk.py", paths, {suffixes = subdirs})
if emsdk then
return path.directory(emsdk)
end
end
-- find emsdk
function _find_emsdk(sdkdir)
-- find sdk root directory
sdkdir = _find_emsdkdir(sdkdir)
if not sdkdir then
return {}
end
-- find emscripten toolchain directory
local emscripten
local subdirs = {}
table.insert(subdirs, path.join("*", "emscripten"))
local emcc = find_file("emcc", sdkdir, {suffixes = subdirs})
if emcc then
emscripten = path.directory(emcc)
end
return {sdkdir = sdkdir, emscripten = emscripten}
end
-- find emsdk directory
--
-- @param sdkdir the emsdk directory
-- @param opt the argument options, e.g. {force = true}
--
-- @return the sdk toolchains. e.g. {sdkdir = ..}
--
-- @code
--
-- local sdk = find_emsdk("~/emsdk")
--
-- @endcode
--
function main(sdkdir, opt)
-- init arguments
opt = opt or {}
-- attempt to load cache first
local key = "detect.sdks.find_emsdk"
local cacheinfo = detectcache:get(key) or {}
if not opt.force and cacheinfo.sdk and cacheinfo.sdk.sdkdir and os.isdir(cacheinfo.sdk.sdkdir) then
return cacheinfo.sdk
end
-- find sdk
local sdk = _find_emsdk(sdkdir or config.get("emsdk") or global.get("emsdk"))
if sdk and sdk.sdkdir then
config.set("emsdk", sdk.sdkdir, {force = true, readonly = true})
if opt.verbose or option.get("verbose") then
cprint("checking for emsdk directory ... ${color.success}%s", sdk.sdkdir)
end
else
if opt.verbose or option.get("verbose") then
cprint("checking for emsdk directory ... ${color.nothing}${text.nothing}")
end
end
-- save to cache
cacheinfo.sdk = sdk or false
detectcache:set(key, cacheinfo)
detectcache:save()
return sdk
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_pcre.lua | --!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 ruki
-- @file find_pcre.lua
--
-- imports
import("package.manager.find_package")
-- find pcre
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- find package by the builtin script
local result = opt.find_package("pcre", opt)
-- find package from the homebrew package manager
if not result and opt.plat == os.host() and opt.arch == os.arch() then
for _, width in ipairs({"", "16", "32"}) do
result = find_package("brew::pcre/libpcre" .. width, opt)
if result then
break
end
end
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_mkl.lua | --!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 xq114
-- @file find_mkl.lua
--
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
import("lib.detect.find_package")
-- find mkl
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- for windows platform
if opt.plat == "windows" then
-- init bits
local rdir = (opt.arch == "x64" and "intel64" or "ia32")
-- init search paths
local paths = {
"$(env ONEAPI_ROOT)\\mkl\\latest"
}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}, threading = ""}
local linkinfo = find_library("mkl_core", paths, {suffixes = path.join("lib", rdir)})
if not linkinfo then
return
end
table.insert(result.linkdirs, linkinfo.linkdir)
if rdir == "intel64" then
table.insert(result.links, "mkl_intel_ilp64")
else
table.insert(result.links, "mkl_intel_c")
end
-- use tbb if available
local tbb_res = find_package("tbb")
if tbb_res then
table.join2(result.linkdirs, tbb_res.linkdirs)
table.join2(result.links, {"mkl_tbb_thread", "mkl_core", "tbb"})
result.threading = "tbb"
else
table.join2(result.links, {"mkl_sequential", "mkl_core"})
result.threading = "seq"
end
-- find include
table.insert(result.includedirs, find_path("mkl.h", paths, {suffixes = "include"}))
return result
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_pcre2.lua | --!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 ruki
-- @file find_pcre2.lua
--
-- imports
import("package.manager.find_package")
-- find pcre2
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- find package by the builtin script
local result = opt.find_package("pcre2", opt)
-- find package from the homebrew package manager
if not result and opt.plat == os.host() and opt.arch == os.arch() then
for _, width in ipairs({"8", "16", "32"}) do
result = find_package("brew::pcre2/libpcre2-" .. width, opt)
if result then
break
end
end
end
-- patch PCRE2_CODE_UNIT_WIDTH
if result and not result.defines then
local links = {}
for _, link in ipairs(result.links) do
links[link] = true
end
for _, width in ipairs({"8", "16", "32"}) do
if links["pcre2-" .. width] then
result.links = {"pcre2-" .. width}
result.defines = {"PCRE2_CODE_UNIT_WIDTH=" .. width}
break
end
end
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_zlib.lua | --!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 ruki
-- @file find_zlib.lua
--
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
import("package.manager.find_package")
-- find zlib
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- for windows platform
--
-- http://gnuwin32.sourceforge.net/packages/zlib.html
--
if opt.plat == "windows" then
-- init search paths
local paths = {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GnuWin32\\Zlib;InstallPath)",
"$(env PROGRAMFILES)/GnuWin32",
"$(env PROGRAMFILES)/zlib"}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}}
local linkinfo = find_library("zlib", paths, {suffixes = "lib"})
if not linkinfo then
return
end
-- save link and directory
table.insert(result.links, linkinfo.link)
table.insert(result.linkdirs, linkinfo.linkdir)
-- find include
local includedir = find_path("zlib.h", paths, {suffixes = "include"})
if includedir then
-- save include directory
table.insert(result.includedirs, includedir)
-- get version
local zlib_h = io.readfile(path.join(includedir, "zlib.h"))
if zlib_h then
local version = zlib_h:match("#define ZLIB_VERSION \"(%d+%.?%d+%.?%d+)\"")
if version then
result.version = version
end
end
end
return result
end
-- find it by the builtin script first
local result = opt.find_package("zlib", opt)
if not result then
-- find it from the link name: z
result = find_package("system::z", opt)
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_nvtx.lua | --!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 xq114
-- @file find_nvtx.lua
--
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
import("detect.sdks.find_cuda")
-- find nvtx
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
if opt.plat == "windows" then
-- init bits
local rdir = (opt.arch == "x64" and "x64" or "Win32")
local libname = (opt.arch == "x64" and "nvToolsExt64_1" or "nvToolsExt32_1")
-- init search paths
local paths =
{
"$(env NVTOOLSEXT_PATH)",
"$(env PROGRAMFILES)/NVIDIA Corporation/NvToolsExt"
}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}, libfiles = {}}
local linkinfo = find_library(libname, paths, {suffixes = path.join("lib", rdir)})
if linkinfo then
local nvtx_dir = path.directory(path.directory(linkinfo.linkdir))
table.insert(result.linkdirs, linkinfo.linkdir)
table.insert(result.links, libname)
table.insert(result.libfiles, path.join(nvtx_dir, "bin", rdir, libname .. ".dll"))
table.insert(result.libfiles, path.join(nvtx_dir, "lib", rdir, libname .. ".lib"))
else
-- not found?
return
end
-- find include
table.insert(result.includedirs, find_path("nvToolsExt.h", paths, {suffixes = "include"}))
return result
else
local cuda = find_cuda()
if cuda then
local result = {links = {}, linkdirs = {}, includedirs = {}}
-- find library
local linkinfo = find_library("nvToolsExt", cuda.linkdirs)
if linkinfo then
table.insert(result.links, "nvToolsExt")
table.insert(result.linkdirs, linkinfo.linkdir)
else
return
end
table.join2(result.includedirs, cuda.includedirs)
return result
end
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_tbb.lua | --!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 xq114
-- @file find_tbb.lua
--
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
-- find tbb
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- for windows platform
if opt.plat == "windows" then
-- init bits
local rdir = (opt.arch == "x64" and "intel64" or "ia32")
-- init search paths
local paths = {
"$(env ONEAPI_ROOT)\\tbb\\latest"
}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}}
local linkinfo = find_library("tbb", paths, {suffixes = path.join("lib", rdir, "vc14")})
if linkinfo then
table.insert(result.linkdirs, linkinfo.linkdir)
table.join2(result.links, {"tbb", "tbb_malloc"})
else
-- not found?
return
end
-- find include
table.insert(result.includedirs, find_path(path.join("tbb", "tbb.h"), paths, {suffixes = "include"}))
-- ok
return result
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_openssl.lua | --!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 ruki
-- @file find_openssl.lua
--
-- imports
import("lib.detect.find_path")
import("lib.detect.find_library")
-- find openssl
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- for windows platform
--
-- http://www.slproweb.com/products/Win32OpenSSL.html
--
if opt.plat == "windows" then
-- init bits
local bits = (opt.arch == "x64" and "64" or "32")
-- init search paths
local paths = {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL %(" .. bits .. "-bit%)_is1;Inno Setup: App Path)",
"$(env PROGRAMFILES)/OpenSSL",
"$(env PROGRAMFILES)/OpenSSL-Win" .. bits,
"C:/OpenSSL",
"C:/OpenSSL-Win" .. bits}
-- find library
local result = {links = {}, linkdirs = {}, includedirs = {}}
for _, name in ipairs({"libssl", "libcrypto"}) do
local linkinfo = find_library(name, paths, {suffixes = "lib"})
if linkinfo then
table.insert(result.links, linkinfo.link)
table.insert(result.linkdirs, linkinfo.linkdir)
end
end
-- not found?
if #result.links ~= 2 then
return
end
-- find include
table.insert(result.includedirs, find_path("openssl/ssl.h", paths, {suffixes = "include"}))
-- ok
return result
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_mysql.lua | --!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 ruki
-- @file find_mysql.lua
--
-- imports
import("package.manager.find_package")
-- find mysql
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- find package by the builtin script
local result = opt.find_package("mysql", opt)
-- find package from the homebrew package manager
if not result and opt.plat == os.host() and opt.arch == os.arch() then
result = find_package("brew::mysqlclient", opt)
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_vulkansdk.lua | --!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 xq114
-- @file find_vulkansdk.lua
--
-- imports
import("detect.sdks.find_vulkansdk")
-- find vulkansdk
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
opt = opt or {}
return find_vulkansdk({arch = opt.arch})
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_mbedtls.lua | --!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 ruki
-- @file find_mbedtls.lua
--
-- imports
import("package.manager.find_package")
-- find mbedtls
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
opt.links = {"mbedtls", "mbedcrypto", "mbedx509"}
return opt.find_package("mbedtls", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/packages/find_libxml2.lua | --!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 ruki
-- @file find_libxml2.lua
--
-- imports
import("package.manager.find_package")
-- find libxml2
--
-- @param opt the package options. e.g. see the options of find_package()
--
-- @return see the return value of find_package()
--
function main(opt)
-- find package by the builtin script
local result = opt.find_package("libxml2", opt)
-- find package from the homebrew package manager
if not result and opt.plat == os.host() and opt.arch == os.arch() then
result = find_package("brew::libxml2/libxml-2.0", opt)
end
-- patch "include/libxml2"
if result then
local includedirs = {}
for _, includedir in ipairs(result.includedirs) do
if includedir:endswith("include") then
table.insert(includedirs, path.join(includedir, "libxml2"))
else
table.insert(includedirs, includedir)
end
end
result.includedirs = includedirs
end
return result
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_emcc.lua | --!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 ruki
-- @file find_emcc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("detect.sdks.find_emsdk")
-- find emcc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local emcc = find_emcc()
-- local emcc, version = find_emcc({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- init the search directories
local emsdk = find_emsdk()
if emsdk and emsdk.emscripten then
local paths = {}
table.insert(paths, emsdk.emscripten)
opt.paths = paths
end
-- find program
local program = find_program(opt.program or (is_host("windows") and "emcc.bat" or "emcc"), opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_sdar.lua | --!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 ruki
-- @file find_sdar.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find dmd
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local dmd = find_sdar()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.command = opt.command or "--version"
-- add search paths
local paths = {}
local bindir = get_config("bin")
if bindir and os.isdir(bindir) then
table.insert(paths, bindir)
end
if is_host("windows") then
table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\SDCC)\\bin")
end
if #paths > 0 then
opt.paths = paths
end
-- find program
local program = find_program(opt.program or "sdar", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_metallib.lua | --!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 ruki
-- @file find_metallib.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find metallib
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local metallib = find_metallib()
-- local metallib, version = find_metallib({program = "xcrun -sdk macosx metallib", version = true})
--
-- @endcode
--
function main(opt)
-- find program
opt = opt or {}
local program = find_program(opt.program or "xcrun -sdk macosx metallib", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_apt.lua | --!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 ruki
-- @file find_apt.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find apt
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local apt = find_apt()
-- local apt, version = find_apt({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "apt", opt)
if not program and not opt.program then
program = find_program("apt-get", opt)
end
-- 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_pkg_config.lua | --!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 ruki
-- @file find_pkg_config.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find pkg_config
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local pkg_config = find_pkg_config()
-- local pkg_config, version = find_pkg_config({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "pkg-config", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_link.lua | --!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 ruki
-- @file find_link.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("lib.detect.find_tool")
-- find link
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local link = find_link()
--
-- @endcode
--
function main(opt)
-- init version info first
local version = nil
local verinfo = nil
-- init options
opt = opt or {}
opt.check = opt.check or function (program)
local toolchain = opt.toolchain
if toolchain and toolchain:name() == "masm32" then
-- if this link.exe is from masm32 sdk, we just pass it fastly
-- because it does not contain cl.exe
--
-- TODO maybe we can use ml to improve it
else
local cl = assert(find_tool("cl", {envs = opt.envs}))
-- make an stub source file
local binaryfile = os.tmpfile() .. ".exe"
local objectfile = os.tmpfile() .. ".obj"
local sourcefile = os.tmpfile() .. ".c"
-- compile sourcefile first
io.writefile(sourcefile, "int main(int argc, char** argv)\n{return 0;}")
os.runv(cl.program, {"-c", "-Fo" .. objectfile, sourcefile}, {envs = opt.envs})
-- do link
verinfo = os.iorunv(program, {"-lib", "-out:" .. binaryfile, objectfile}, {envs = opt.envs})
-- remove files
os.rm(objectfile)
os.rm(sourcefile)
os.rm(binaryfile)
end
end
opt.command = opt.command or function () return verinfo end
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
-- find program
local program = find_program(opt.program or "link.exe", opt)
-- find program version
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_rustc.lua | --!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 ruki
-- @file find_rustc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find rustc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local rustc = find_rustc()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "rustc", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_dxc.lua | --!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 ruki
-- @file find_dxc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find dxc
--
-- @param opt the argument options, e.g. {version = true, program = "c:\xxx\dxc.exe"}
--
-- @return program, version
--
-- @code
--
-- local dxc = find_dxc()
-- local dxc, version = find_dxc({version = true})
-- local dxc, version = find_dxc({version = true, program = "c:\xxx\dxc.exe"})
--
-- @endcode
--
function main(opt)
opt = opt or {}
opt.paths = opt.paths or {
"$(env VULKAN_SDK)/Bin",
"$(env VK_SDK_PATH)/Bin",
"$(env PATH)"
}
local program = find_program(opt.program or "dxc.exe", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ideviceinstaller.lua | --!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 ruki
-- @file find_ideviceinstaller.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find ideviceinstaller
--
-- @param opt the arguments, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ideviceinstaller = find_ideviceinstaller()
-- local ideviceinstaller, version = find_ideviceinstaller({version = true})
--
-- @endcode
--
function main(opt)
-- only for macosx
if not is_host("macosx") then
return
end
-- init options
opt = opt or {}
opt.check = "-h"
-- find program
return find_program(opt.program or "ideviceinstaller", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_bazel.lua | --!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 ruki
-- @file find_bazel.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find bazel
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local bazel = find_bazel()
-- local bazel, version = find_bazel({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "bazel", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_brew.lua | --!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 ruki
-- @file find_brew.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find brew
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local brew = find_brew()
-- local brew, version = find_brew({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- we do not attempt to run brew and only find the brew program path
-- because the `brew --version` and `brew help` commands are too slow. (~1.5s)
opt.norun = true
-- find program
local program = find_program(opt.program or "brew", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_gdb.lua | --!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 ruki
-- @file find_gdb.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find gdb
--
-- @param opt the argument options, e.g. {version = true, program="/usr/bin/gdb"}
--
-- @return program, version
--
-- @code
--
-- local gdb = find_gdb()
-- local gdb, version = find_gdb({version = true})
-- local gdb, version = find_gdb({version = true, program = "/usr/bin/gdb"})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "gdb", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_clang_scan_deps.lua | --!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 ruki
-- @file find_clang_scan_deps.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find clang-scan-deps
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local clang_scan_deps = find_clang_scan_deps()
-- local clang_scan_deps, version = find_clang_scan_deps({program = "clang-scan-deps", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "clang-scan-deps", opt)
if not program and is_host("macosx") then
local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end}
if llvm then
opt.paths = opt.paths or {}
opt.force = true
table.insert(opt.paths, path.join(llvm:trim(), "bin"))
program = find_program(opt.program or "clang-scan-deps", opt)
end
end
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_swift_frontend.lua | --!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 ruki
-- @file find_swift_frontend.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find swift_frontend
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local swift_frontend = find_swift_frontend()
-- local swift_frontend, version = find_swift_frontend({program = "xcrun -sdk macosx swift-frontend", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "swift-frontend", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ifort.lua | --!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 ruki
-- @file find_ifort.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find ifort
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ifort = find_ifort()
-- local ifort, version, hintname = find_ifort({program = "ifort", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
if is_host("windows") then
-- find program
opt.check = opt.check or function (program) os.runv(program, {"/help"}, {envs = opt.envs}) end
local program = find_program(opt.program or "ifort.exe", opt)
-- find program version
local version = nil
if program and opt and opt.version then
opt.command = opt.command or function () local _, info = os.iorunv(program, {"/help"}, {envs = opt.envs}); return info end
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
version = find_programver(program, opt)
end
return program, version
else
-- find program
local program = find_program(opt.program or "ifort", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_circle.lua | --!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 ruki
-- @file find_circle.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find circle
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local circle = find_circle()
-- local circle, version = find_circle({program = "circle", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "circle", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_perl.lua | --!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 xq114
-- @file find_perl.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find perl
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local perl = find_perl()
-- local perl, version = find_perl({program = "perl", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- init the search directories
local paths = {}
if is_host("windows") then
table.insert(paths, "$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\GitForWindows;InstallPath)\\usr\\bin")
end
opt.paths = paths
-- find program
local program = find_program(opt.program or "perl", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_glslc.lua | --!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 ruki
-- @file find_glslc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("core.tool.toolchain")
-- find glslc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local glslc = find_glslc()
-- local glslc, version = find_glslc({program = "glslc", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "glslc", opt)
if not program and is_plat("android") then
local ndk = toolchain.load("ndk"):config("ndk")
if ndk then
local prebuilt = (is_host("macosx") and "darwin" or os.host()) .. "-x86_64"
opt.paths = path.join(ndk, "shader-tools", prebuilt)
program = find_program(opt.program or "glslc", opt)
end
end
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_git.lua | --!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 ruki
-- @file find_git.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find git
--
-- @param opt the arguments, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local git = find_git()
-- local git, version = find_git({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "git", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_armlink.lua | --!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 ruki
-- @file find_armlink.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("detect.sdks.find_mdk")
-- find armlink
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local armlink = find_armlink()
-- local armlink, version = find_armlink({program = "armlink", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = "-h"
-- find program
local program = find_program(opt.program or "armlink.exe", opt)
if not program then
local mdk = find_mdk()
if mdk then
if mdk.sdkdir_armcc then
program = find_program(path.join(mdk.sdkdir_armcc, "bin", "armlink.exe"), opt)
end
if not program and mdk.sdkdir_armclang then
program = find_program(path.join(mdk.sdkdir_armclang, "bin", "armlink.exe"), opt)
end
end
end
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_pacman.lua | --!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 ruki
-- @file find_pacman.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find pacman
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local pacman = find_pacman()
-- local pacman, version = find_pacman({version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "pacman", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_nvfortran.lua | --!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 ruki
-- @file find_nvfortran.lua
--
-- imports
import("private.detect.find_cudatool")
-- find nvfortran
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local nvfortran = find_nvfortran()
-- local nvfortran, version = find_nvfortran({program = "nvfortran", version = true})
--
-- @endcode
--
function main(opt)
return find_cudatool("nvfortran", "V(%d+%.?%d*%.?%d*.-)%s", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_zypper.lua | --!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 ruki, Lingfeng Fu
-- @file find_zypper.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find zypper
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local zypper = find_zypper()
-- local zypper, version = find_zypper({version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "zypper", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_tclsh.lua | --!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 ruki
-- @file find_tclsh.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find tclsh
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local tclsh = find_tclsh()
-- local tclsh, version = find_tclsh({program = "tclsh", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
opt.check = opt.check or function (program)
local infile = os.tmpfile()
local outfile = os.tmpfile()
io.writefile(infile, "puts hello\n")
local outdata = os.iorunv(program, {infile})
assert(outdata == "hello\n")
os.rm(infile)
os.rm(outfile)
end
return find_program(opt.program or "tclsh", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_gzip.lua | --!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 ruki
-- @file find_gzip.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find gzip
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local gzip = find_gzip()
-- local gzip, version = find_gzip({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "gzip", opt)
-- find program version
local version = nil
if program and opt and opt.version then
opt.command = opt.command or function()
local outdata, errdata = os.iorunv(program, {"--version"})
return (outdata or "") .. (errdata or "")
end
version = find_programver(program, opt)
end
-- ok?
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_llvm_ar.lua | --!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 ruki
-- @file find_llvm_ar.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find llvm-ar
--
-- @param opt the argument options, e.g. {version = true, program = "c:\xxx\llvm_ar.exe"}
--
-- @return program, version
--
-- @code
--
-- local llvm_ar = find_llvm_ar()
-- local llvm_ar, version = find_llvm_ar({version = true})
-- local llvm_ar, version = find_llvm_ar({version = true, program = "c:\xxx\llvm_ar.exe"})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = opt.check or "-h"
opt.command = opt.command or "--version"
-- find program
local program = find_program(opt.program or "llvm-ar", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_rc.lua | --!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 ruki
-- @file find_rc.lua
--
-- imports
import("core.project.config")
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find rc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local rc = find_rc()
--
-- @endcode
--
function main(opt)
-- not on windows?
if not is_host("windows") then
return
end
-- init options
opt = opt or {}
opt.check = opt.check or "-?"
opt.command = opt.command or "-?"
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
-- fix rc.exe missing issues
--
-- @see https://github.com/xmake-io/xmake/issues/225
-- https://stackoverflow.com/questions/43847542/rc-exe-no-longer-found-in-vs-2015-command-prompt/45319119
--
-- patch sdk bin directory to path environment
--
-- e.g. C:\Program Files (x86)\Windows Kits\10\bin\10.0.17134.0\x64
--
local envs = opt.envs
if envs and envs.WindowsSdkDir and envs.WindowsSDKVersion then
local toolchain = opt.toolchain
local arch = toolchain and toolchain:arch() or config.arch()
local bindir = path.join(envs.WindowsSdkDir, "bin", envs.WindowsSDKVersion, arch)
if os.isdir(bindir) then
opt.paths = opt.paths or {}
table.insert(opt.paths, bindir)
end
end
-- find program
local program = find_program(opt.program or "rc.exe", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_nvc.lua | --!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 ruki
-- @file find_nvc.lua
--
-- imports
import("private.detect.find_cudatool")
-- find nvc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local nvc = find_nvc()
-- local nvc, version = find_nvc({program = "nvc", version = true})
--
-- @endcode
--
function main(opt)
return find_cudatool("nvc", "V(%d+%.?%d*%.?%d*.-)%s", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_msbuild.lua | --!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 ruki
-- @file find_msbuild.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find msbuild
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local msbuild = find_msbuild()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = "/version"
-- find program
local program = find_program(opt.program or "msbuild.exe", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_llvm_rc.lua | --!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 ruki
-- @file find_llvm_rc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find llvm-rc
--
-- @param opt the argument options, e.g. {version = true, program = "c:\xxx\llvm_rc.exe"}
--
-- @return program, version
--
-- @code
--
-- local llvm_rc = find_llvm_rc()
-- local llvm_rc, version = find_llvm_rc({version = true})
-- local llvm_rc, version = find_llvm_rc({version = true, program = "c:\xxx\llvm_rc.exe"})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
opt.check = opt.check or "/?"
return find_program(opt.program or "llvm-rc", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_clangxx.lua | --!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 ruki
-- @file find_clangxx.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find clang++
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local clangxx = find_clangxx()
-- local clangxx, version = find_clangxx({program = "xcrun -sdk macosx clang++", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "clang++", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_cpp.lua | --!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 ruki
-- @file find_cpp.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find cpp
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local cpp = find_cpp()
-- local cpp, version = find_cpp({program = "xcrun -sdk macosx cpp", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local version = nil
local program = find_program(opt.program or "cpp", opt)
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_windbg.lua | --!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 ruki
-- @file find_windbg.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find windbg
--
-- @param opt the argument options, e.g. {version = true, program = "c:\xxx\windbg.exe"}
--
-- @return program, version
--
-- @code
--
-- local windbg = find_windbg()
-- local windbg, version = find_windbg({version = true})
-- local windbg, version = find_windbg({version = true, program = "c:\xxx\windbg.exe"})
--
-- @endcode
--
function main(opt)
-- not on windows?
if os.host() ~= "windows" then
return
end
-- init options
opt = opt or {}
opt.paths = opt.paths or function ()
for _, reg in ipairs({"HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger", "HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug;Debugger"}) do
return (val("reg " .. reg) or ""):match("\"(.-)\"")
end
end
opt.check = opt.check or function (program) if not os.isfile(program) then raise() end end
-- find program
return find_program(opt.program or "windbg", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_patch.lua | --!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 ruki
-- @file find_patch.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find lua
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local lua = find_patch()
-- local lua, version = find_patch({program = "patch", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "patch", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_python.lua | --!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 ruki
-- @file find_python.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("detect.tools.find_python2")
import("detect.tools.find_python3")
-- find python
--
-- @param opt the arguments, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local python = find_python()
-- local python, version = find_python({version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "python", opt)
if not program then
local opt2 = table.clone(opt)
opt2.program = nil
program = find_python3(opt2) or find_python2(opt2)
end
local version = nil
if program and opt.version then
opt.command = function ()
local outs, errs = os.iorunv(program, {"--version"})
return ((outs or "") .. (errs or "")):trim()
end
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ifx.lua | --!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 ruki
-- @file find_ifx.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find ifx
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ifx = find_ifx()
-- local ifx, version, hintname = find_ifx({program = "ifx", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
if is_host("windows") then
-- find program
opt.check = opt.check or function (program) os.runv(program, {"/help"}, {envs = opt.envs}) end
local program = find_program(opt.program or "ifx.exe", opt)
-- find program version
local version = nil
if program and opt and opt.version then
opt.command = opt.command or function () local _, info = os.iorunv(program, {"/help"}, {envs = opt.envs}); return info end
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
version = find_programver(program, opt)
end
return program, version
else
-- find program
local program = find_program(opt.program or "ifx", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_gn.lua | --!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 ruki
-- @file find_gn.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find gn
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local gn = find_gn()
-- local gn, version = find_gn({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "gn", opt)
if not program and is_host("windows") then
program = find_program("gn.bat", opt)
end
-- 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_cxx.lua | --!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 ruki
-- @file find_cxx.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find c++
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local cxx = find_cxx()
-- local cxx, version, hintname = find_cxx({program = "xcrun -sdk macosx c++", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "c++", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
-- is clang++ or c++
local is_clang = false
if program then
local versioninfo = os.iorunv(program, {"--version"})
if versioninfo and versioninfo:find("clang", 1, true) then
is_clang = true
end
end
return program, version, (is_clang and "clangxx" or "cxx")
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_yasm.lua | --!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 ruki
-- @file find_yasm.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find yasm
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local yasm = find_yasm()
-- local yasm, version = find_yasm({program = "yasm", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "yasm", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ml.lua | --!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 ruki
-- @file find_ml.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find ml
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ml = find_ml()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = opt.check or function (program) os.runv(program, {}, {envs = opt.envs}) end
-- find program
local program = find_program(opt.program or "ml.exe", opt)
-- find program version
local version = nil
if program and opt and opt.version then
opt.command = opt.command or function () local _, info = os.iorunv(program, {}, {envs = opt.envs}); return info end
opt.parse = opt.parse or function (output) return output:match("Version (%d+%.?%d*%.?%d*.-)%s") end
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_tar.lua | --!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 ruki
-- @file find_tar.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find tar
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local tar = find_tar()
-- local tar, version = find_tar({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "tar", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_armclang.lua | --!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 ruki
-- @file find_armclang.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
import("detect.sdks.find_mdk")
-- find armclang
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local armclang = find_armclang()
-- local armclang, version = find_armclang({program = "armclang", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.parse = opt.parse or function (output) return output:match("Arm Compiler for Embedded (%d+%.?%d+%.?%d+)%s") end
-- find program
local program = find_program(opt.program or "armclang.exe", opt)
if not program then
local mdk = find_mdk()
if mdk and mdk.sdkdir_armclang then
program = find_program(path.join(mdk.sdkdir_armclang, "bin", "armclang.exe"), opt)
end
end
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ld_lld.lua | --!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 ruki
-- @file find_ld_lld.lua
--
-- imports
import("core.tool.compiler")
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find ar
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ar = find_ld_lld()
-- local ar, version = find_ld_lld({program = "ld.lld", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "ld.lld", opt)
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_dmd.lua | --!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 ruki
-- @file find_dmd.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find dmd
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local dmd = find_dmd()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.command = opt.command or "--version"
-- find program
local program = find_program(opt.program or "dmd", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_valac.lua | --!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 ruki
-- @file find_valac.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find valac
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local valac = find_valac()
-- local valac, version, hintname = find_valac({program = "valac", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "valac", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_cosmoar.lua | --!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 ruki
-- @file find_cosmoar.lua
--
-- imports
import("lib.detect.find_program")
-- find ar
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ar = find_cosmoar()
--
-- @endcode
--
function main(opt)
opt = opt or {}
opt.shell = true
opt.envs = opt.envs or {PATH = os.getenv("PATH")}
local program = find_program(opt.program or "cosmoar", opt)
if program and is_host("windows") then
program = program:gsub("\\", "/")
end
return program
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_ld.lua | --!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 ruki
-- @file find_ld.lua
--
-- imports
import("core.tool.compiler")
import("lib.detect.find_program")
-- find ar
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ar = find_ld()
-- local ar, version = find_ld({program = "ld", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
opt.norun = true
return find_program(opt.program or "ld", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_windres.lua | --!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 ruki
-- @file find_windres.lua
--
-- imports
import("lib.detect.find_program")
-- we cannot run `windres --version` to check it, because llvm-mingw/windres always return non-zero
function _check(program, opt)
local objectfile = os.tmpfile() .. ".o"
local resourcefile = os.tmpfile() .. ".rc"
io.writefile(resourcefile, [[
#include <winresrc.h>
VS_VERSION_INFO VERSIONINFO
FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
FILEFLAGS 0x0L
FILEOS VOS_NT_WINDOWS32
FILETYPE VFT_APP
FILESUBTYPE VFT2_UNKNOWN
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "000004B0"
BEGIN
VALUE "ProductName", "xmake"
END
END
END
]])
os.runv(program, {"-i", resourcefile, "-o", objectfile}, {envs = opt.envs})
os.rm(resourcefile)
os.rm(objectfile)
end
-- find windres
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local windres = find_windres()
-- local windres, version = find_windres({version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
opt.check = function (program)
_check(program, opt)
end
return find_program(opt.program or "windres", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_emar.lua | --!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 ruki
-- @file find_emar.lua
--
-- imports
import("core.tool.compiler")
import("lib.detect.find_program")
import("lib.detect.find_tool")
import("detect.sdks.find_emsdk")
-- check
function _check(program)
end
-- find ar
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local ar = find_emar()
-- local ar, version = find_emar({program = "xcrun -sdk macosx g++", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = opt.check or function (program)
local bindir = path.directory(program)
local filename = path.filename(program)
filename = filename:gsub("emar", "emcc")
local emcc_program = filename
if bindir and bindir ~= "." then
emcc_program = path.join(bindir, filename)
end
local emcc = assert(find_tool("emcc", {program = emcc_program, envs = opt.envs}), "emcc not found!")
-- make an stub source file
local libraryfile = os.tmpfile() .. ".a"
local objectfile = os.tmpfile() .. ".o"
local sourcefile = os.tmpfile() .. ".c"
io.writefile(sourcefile, "int test(void)\n{return 0;}")
-- compile it
os.runv(emcc.program, {"-c", "-o" .. objectfile, sourcefile}, {envs = opt.envs})
-- archive it
os.runv(program, {"-cr", libraryfile, objectfile}, {envs = opt.envs})
-- remove files
os.rm(objectfile)
os.rm(sourcefile)
os.rm(libraryfile)
end
-- init the search directories
local emsdk = find_emsdk()
if emsdk and emsdk.emscripten then
local paths = {}
table.insert(paths, emsdk.emscripten)
opt.paths = paths
end
-- find program
return find_program(opt.program or (is_host("windows") and "emar.bat" or "emar"), opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_codesign.lua | --!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 ruki
-- @file find_codesign.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find codesign
--
-- @param opt the arguments, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local codesign = find_codesign()
-- local codesign, version = find_codesign({version = true})
--
-- @endcode
--
function main(opt)
-- only for macosx
if not is_host("macosx") then
return
end
-- init options
opt = opt or {}
opt.check = function (program)
os.runv(program, {"-d", "/bin/echo"})
end
-- find program
return find_program(opt.program or "codesign", opt)
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_nimble.lua | --!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 ruki
-- @file find_nimble.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find nim
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local nim = find_nimble()
-- local nim, version = find_nimble({program = "nimble", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "nimble", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_strip.lua | --!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 ruki
-- @file find_strip.lua
--
-- imports
import("core.tool.compiler")
import("lib.detect.find_program")
-- check strip of xcode
function _check_strip_of_xcode(program)
-- make an stub source file
local objectfile = os.tmpfile() .. ".o"
local sourcefile = os.tmpfile() .. ".c"
io.writefile(sourcefile, "int test(void)\n{return 0;}")
-- compile it
compiler.compile(sourcefile, objectfile)
-- archive it
os.runv(program, {"-S", objectfile})
-- remove files
os.rm(objectfile)
os.rm(sourcefile)
end
-- find strip
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local strip = find_strip()
-- local strip, version = find_strip({program = "xcrun -sdk macosx strip", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- attempt to find gnu strip first with `--version`
local program = find_program(opt.program or "strip", opt)
if not program then
-- find strip of xcode without `--version`
if is_plat("macosx", "iphoneos", "watchos") or is_host("macosx") then
opt.force = true
opt.check = _check_strip_of_xcode
program = find_program(opt.program or "strip", opt)
end
end
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_xz.lua | --!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 ruki
-- @file find_xz.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find xz
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local xz = find_xz()
-- local xz, version = find_xz({version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "xz", 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
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_vvp.lua | --!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 ruki
-- @file find_vvp.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find vvp
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local vvp = find_vvp()
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
opt.check = opt.check or "-V"
opt.command = opt.command or "-V"
-- find it from some logical drives paths
if is_host("windows") then
opt.paths = opt.paths or {}
for _, logical_drive in ipairs(winos.logical_drives()) do
table.insert(opt.paths, path.join(logical_drive, "iverilog", "bin"))
end
end
-- find program
local program = find_program(opt.program or "vvp", opt)
-- find program version
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_icc.lua | --!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 ruki
-- @file find_icc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find icc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local icc = find_icc()
-- local icc, version, hintname = find_icc({program = "icc", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "icc", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_dpcpp.lua | --!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 ruki
-- @file find_icpc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find icpc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local icpc = find_icpc()
-- local icpc, version, hintname = find_icpc({program = "icpc", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "dpcpp", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_clang_format.lua | --!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 ruki
-- @file find_clang_format.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find clang-format
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local clang_format = find_clang_format()
-- local clang_format, version = find_clang_format({program = "clang-format", version = true})
--
-- @endcode
--
function main(opt)
opt = opt or {}
local program = find_program(opt.program or "clang-format", opt)
if not program and is_host("macosx") then
local llvm = try {function () return os.iorunv("brew", {"--prefix", "llvm"}) end}
if llvm then
opt.paths = opt.paths or {}
opt.force = true
table.insert(opt.paths, path.join(llvm:trim(), "bin"))
program = find_program(opt.program or "clang-format", opt)
end
end
local version = nil
if program and opt and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
0 | repos/xmake/xmake/modules/detect | repos/xmake/xmake/modules/detect/tools/find_icpx.lua | --!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 ruki
-- @file find_icpc.lua
--
-- imports
import("lib.detect.find_program")
import("lib.detect.find_programver")
-- find icpc
--
-- @param opt the argument options, e.g. {version = true}
--
-- @return program, version
--
-- @code
--
-- local icpc = find_icpc()
-- local icpc, version, hintname = find_icpc({program = "icpc", version = true})
--
-- @endcode
--
function main(opt)
-- init options
opt = opt or {}
-- find program
local program = find_program(opt.program or "icpx", opt)
-- find program version
local version = nil
if program and opt.version then
version = find_programver(program, opt)
end
return program, version
end
|
Subsets and Splits
No saved queries yet
Save your SQL queries to embed, download, and access them later. Queries will appear here once saved.