summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-07 23:09:50 +0800
committerruki <[email protected]>2020-04-07 12:59:05 +0800
commit20b25b2a16d0282b0496f23d0f0e1ba8842b9205 (patch)
treec358ca5f0290e88fde95364d42281e40cf67e664
parent1e491924ccad666ad42e30d30e2031662bc1d3d0 (diff)
remove some ifelse
-rw-r--r--xmake/core/sandbox/modules/import/lib/detect/cache.lua2
-rw-r--r--xmake/modules/detect/packages/find_openssl.lua2
-rw-r--r--xmake/modules/devel/git/clone.lua2
-rw-r--r--xmake/modules/devel/git/ls_remote.lua2
-rw-r--r--xmake/plugins/macro/macros/package.lua6
-rw-r--r--xmake/plugins/project/make/makefile.lua2
-rw-r--r--xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua4
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x.lua2
-rw-r--r--xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua12
-rwxr-xr-xxmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua4
10 files changed, 19 insertions, 19 deletions
diff --git a/xmake/core/sandbox/modules/import/lib/detect/cache.lua b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
index cf8a78192..bedc42dd4 100644
--- a/xmake/core/sandbox/modules/import/lib/detect/cache.lua
+++ b/xmake/core/sandbox/modules/import/lib/detect/cache.lua
@@ -36,7 +36,7 @@ local raise = require("sandbox/modules/raise")
function sandbox_lib_detect_cache._instance()
-- get it
- local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(utils.ifelse(os.isfile(project.rootfile()), "local.detect", "memory.detect"))
+ local detectcache = sandbox_lib_detect_cache._INSTANCE or cache(os.isfile(project.rootfile()) and "local.detect" or "memory.detect")
sandbox_lib_detect_cache._INSTANCE = detectcache
return detectcache
end
diff --git a/xmake/modules/detect/packages/find_openssl.lua b/xmake/modules/detect/packages/find_openssl.lua
index bfde4bb1a..d502e5575 100644
--- a/xmake/modules/detect/packages/find_openssl.lua
+++ b/xmake/modules/detect/packages/find_openssl.lua
@@ -37,7 +37,7 @@ function main(opt)
if opt.plat == "windows" then
-- init bits
- local bits = ifelse(opt.arch == "x64", "64", "32")
+ local bits = (opt.arch == "x64" and "64" or "32")
-- init search pathes
local pathes = {"$(reg HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\OpenSSL %(" .. bits .. "-bit%)_is1;Inno Setup: App Path)",
diff --git a/xmake/modules/devel/git/clone.lua b/xmake/modules/devel/git/clone.lua
index b8fca2b48..4285b392d 100644
--- a/xmake/modules/devel/git/clone.lua
+++ b/xmake/modules/devel/git/clone.lua
@@ -54,7 +54,7 @@ function main(url, opt)
-- set depth
if opt.depth then
table.insert(argv, "--depth")
- table.insert(argv, ifelse(type(opt.depth) == "number", tostring(opt.depth), opt.depth))
+ table.insert(argv, type(opt.depth) == "number" and tostring(opt.depth) or opt.depth)
end
-- recursive?
diff --git a/xmake/modules/devel/git/ls_remote.lua b/xmake/modules/devel/git/ls_remote.lua
index 9b87fdf3f..a52e0d68d 100644
--- a/xmake/modules/devel/git/ls_remote.lua
+++ b/xmake/modules/devel/git/ls_remote.lua
@@ -72,7 +72,7 @@ function main(reftype, url)
local ref = refinfo[2]
-- save this ref
- local prefix = ifelse(reftype == "refs", "refs/", "refs/" .. reftype .. "/")
+ local prefix = reftype == "refs" and "refs/" or ("refs/" .. reftype .. "/")
if ref and ref:startswith(prefix) and commit and #commit == 40 then
table.insert(refs, ref:sub(#prefix + 1))
end
diff --git a/xmake/plugins/macro/macros/package.lua b/xmake/plugins/macro/macros/package.lua
index aa6775c6d..0fa536a3e 100644
--- a/xmake/plugins/macro/macros/package.lua
+++ b/xmake/plugins/macro/macros/package.lua
@@ -59,13 +59,13 @@ function main(argv)
for _, arch in ipairs(archs) do
-- config it
- os.exec("xmake f -p %s -a %s %s -c %s", plat, arch, args.config or "", ifelse(option.get("verbose"), "-v", ""))
+ os.exec("xmake f -p %s -a %s %s -c %s", plat, arch, args.config or "", option.get("verbose") and "-v" or "")
-- package it
if args.outputdir then
- os.exec("xmake p -o %s %s", args.outputdir, ifelse(option.get("verbose"), "-v", ""))
+ os.exec("xmake p -o %s %s", args.outputdir, option.get("verbose") and "-v" or "")
else
- os.exec("xmake p %s", ifelse(option.get("verbose"), "-v", ""))
+ os.exec("xmake p %s", option.get("verbose") and "-v" or "")
end
end
diff --git a/xmake/plugins/project/make/makefile.lua b/xmake/plugins/project/make/makefile.lua
index a3eea6c64..95df0ee86 100644
--- a/xmake/plugins/project/make/makefile.lua
+++ b/xmake/plugins/project/make/makefile.lua
@@ -191,7 +191,7 @@ function _make_object(makefile, target, sourcefile, objectfile, sourceflags)
makefile:print(" %s", sourcefile)
-- make body
- makefile:print("\t@echo %scompiling.$(mode) %s", ifelse(ccache, "ccache ", ""), sourcefile)
+ makefile:print("\t@echo %scompiling.$(mode) %s", ccache and "ccache " or "", sourcefile)
_mkdir(makefile, path.directory(objectfile))
makefile:writef("\t@%s > %s 2>&1\n", command, _logfile())
diff --git a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
index 72bfcca64..ffe6f852c 100644
--- a/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs200x_vcproj.lua
@@ -182,7 +182,7 @@ function _make_VCCLCompilerTool(vcprojfile, vsinfo, target, compflags)
break
end
end
- vcprojfile:print("RuntimeLibrary=\"%d\"", ifelse(val("mode") == "debug", runtime + 1, runtime))
+ vcprojfile:print("RuntimeLibrary=\"%d\"", is_mode("debug") and runtime + 1 or runtime)
vcprojfile:leave("/>")
end
@@ -234,7 +234,7 @@ function _make_VCLinkerTool(vcprojfile, vsinfo, target, vcprojdir)
vcprojfile:print("LinkIncremental=\"2\"") -- enable: 2, disable: 1
vcprojfile:print("GenerateDebugInformation=\"%s\"", tostring(debug))
vcprojfile:print("SubSystem=\"%d\"", subsystem) -- console: 1, windows: 2
- vcprojfile:print("TargetMachine=\"%d\"", ifelse(config.arch() == "x64", 17, 1))
+ vcprojfile:print("TargetMachine=\"%d\"", is_arch("x64") and 17 or 1)
vcprojfile:leave("/>")
end
diff --git a/xmake/plugins/project/vstudio/impl/vs201x.lua b/xmake/plugins/project/vstudio/impl/vs201x.lua
index 992b1c739..1168ae3e7 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x.lua
@@ -35,7 +35,7 @@ import("actions.config.configheader", {alias = "generate_configheader", rootdir
function _make_targetinfo(mode, arch, target)
-- init target info
- local targetinfo = { mode = mode, arch = ifelse(arch == "x86", "Win32", "x64") }
+ local targetinfo = { mode = mode, arch = (arch == "x86" and "Win32" or "x64") }
-- get sdk version
local vcvarsall = config.get("__vcvarsall")
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
index 442c2be18..b69651f5f 100644
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj.lua
@@ -415,7 +415,7 @@ function _make_common_item(vcxprojfile, vsinfo, target, targetinfo, vcxprojdir)
end
-- make TargetMachine
- vcxprojfile:print("<TargetMachine>%s</TargetMachine>", ifelse(targetinfo.arch == "x64", "MachineX64", "MachineX86"))
+ vcxprojfile:print("<TargetMachine>%s</TargetMachine>", (targetinfo.arch == "x64" and "MachineX64" or "MachineX86"))
vcxprojfile:leave("</%s>", linkerkinds[targetinfo.targetkind])
@@ -528,7 +528,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
end
-- enter it
- local nodename = ifelse(sourcekind == "as", "CustomBuild", ifelse(sourcekind == "mrc", "ResourceCompile", "ClCompile"))
+ local nodename = (sourcekind == "as" and "CustomBuild" or (sourcekind == "mrc" and "ResourceCompile" or "ClCompile"))
sourcefile = path.relative(path.absolute(sourcefile), vcxprojdir)
vcxprojfile:enter("<%s Include=\"%s\">", nodename, sourcefile)
@@ -597,7 +597,7 @@ function _make_source_file_forall(vcxprojfile, vsinfo, target, sourcefile, sourc
-- disable the precompiled header if sourcekind ~= headerkind
local pcheader = target.pcxxheader or target.pcheader
local pcheader_disable = false
- if pcheader and language.sourcekind_of(sourcefile) ~= ifelse(target.pcxxheader, "cxx", "cc") then
+ if pcheader and language.sourcekind_of(sourcefile) ~= (target.pcxxheader and "cxx" or "cc") then
pcheader_disable = true
end
@@ -646,7 +646,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
for _, info in ipairs(sourceinfo) do
-- enter it
- local nodename = ifelse(info.sourcekind == "as", "CustomBuild", ifelse(info.sourcekind == "mrc", "ResourceCompile", "ClCompile"))
+ local nodename = (info.sourcekind == "as" and "CustomBuild" or (info.sourcekind == "mrc" and "ResourceCompile" or "ClCompile"))
vcxprojfile:enter("<%s Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\" Include=\"%s\">", nodename, info.mode, info.arch, sourcefile)
-- for *.asm files
@@ -667,7 +667,7 @@ function _make_source_file_forspec(vcxprojfile, vsinfo, target, sourcefile, sour
-- disable the precompiled header if sourcekind ~= headerkind
local pcheader = target.pcxxheader or target.pcheader
- if pcheader and language.sourcekind_of(sourcefile) ~= ifelse(target.pcxxheader, "cxx", "cc") then
+ if pcheader and language.sourcekind_of(sourcefile) ~= (target.pcxxheader and "cxx" or "cc") then
vcxprojfile:print("<PrecompiledHeader>NotUsing</PrecompiledHeader>")
end
vcxprojfile:print("<ObjectFileName>%s</ObjectFileName>", objectfile)
@@ -693,7 +693,7 @@ function _make_source_file_forpch(vcxprojfile, vsinfo, target, vcxprojdir)
for _, info in ipairs(target.info) do
-- compile as c/c++
- local compileas = ifelse(target.pcxxheader, "CompileAsCpp", "CompileAsC")
+ local compileas = (target.pcxxheader and "CompileAsCpp" or "CompileAsC")
vcxprojfile:print("<CompileAs Condition=\"\'%$(Configuration)|%$(Platform)\'==\'%s|%s\'\">%s</CompileAs>", info.mode, info.arch, compileas)
-- add object file
diff --git a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
index 526fa03b4..b1fc97929 100755
--- a/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
+++ b/xmake/plugins/project/vstudio/impl/vs201x_vcxproj_filters.lua
@@ -95,9 +95,9 @@ function _make_sources(filtersfile, vsinfo, target, vcxprojdir)
local filter = _make_filter(sourcefile, target, vcxprojdir)
if filter then
local as = sourcefile:endswith(".asm")
- filtersfile:enter("<%s Include=\"%s\">", ifelse(as, "CustomBuild", "ClCompile"), path.relative(path.absolute(sourcefile), vcxprojdir))
+ filtersfile:enter("<%s Include=\"%s\">", (as and "CustomBuild" or "ClCompile"), path.relative(path.absolute(sourcefile), vcxprojdir))
filtersfile:print("<Filter>%s</Filter>", filter)
- filtersfile:leave("</%s>", ifelse(as, "CustomBuild", "ClCompile"))
+ filtersfile:leave("</%s>", (as and "CustomBuild" or "ClCompile"))
end
local pcheader = target.pcxxheader or target.pcheader
if pcheader then