|
|
@@ -1 +1,107 @@
|
|
|
-includes("AV")
|
|
|
+-- includes("AV")
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+target("qt_widgetapp")
|
|
|
+ add_rules("qt.widgetapp")
|
|
|
+ set_rundir("$(projectdir)/ci_build")
|
|
|
+
|
|
|
+ on_build(function (target)
|
|
|
+ print("build it")
|
|
|
+ import("core.base.hashset")
|
|
|
+ import("private.action.run.runenvs", {try = true})
|
|
|
+ if not runenvs then
|
|
|
+ import("private.action.run.make_runenvs")
|
|
|
+ end
|
|
|
+ -- 获取当前 target 的环境
|
|
|
+ function _add_target_pkgenvs(target, pkgenvs, targets_added)
|
|
|
+ if targets_added[target:name()] then
|
|
|
+ return
|
|
|
+ end
|
|
|
+ targets_added[target:name()] = true
|
|
|
+ table.join2(pkgenvs, target:pkgenvs())
|
|
|
+ for _, dep in ipairs(target:orderdeps()) do
|
|
|
+ _add_target_pkgenvs(dep, pkgenvs, targets_added)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ local pkgenvs = {}
|
|
|
+ _add_target_pkgenvs(target, pkgenvs, {})
|
|
|
+ -- 获取当前系统的环境
|
|
|
+ local addrunenvs, setrunenvs = runenvs and runenvs.make(target) or make_runenvs(target)
|
|
|
+ local runenvs = { add = addrunenvs, set = setrunenvs }
|
|
|
+ for name, env in pairs(pkgenvs) do
|
|
|
+ runenvs.add[name] = runenvs.add[name] or {}
|
|
|
+ table.append(runenvs.add[name], env)
|
|
|
+ end
|
|
|
+ -- PATH 环境整合 添加 到系统
|
|
|
+ if type(runenvs.add) == "table" then
|
|
|
+ for key, value in pairs(runenvs.add) do
|
|
|
+ --print(key, value)
|
|
|
+ for i, v in pairs(value) do
|
|
|
+ os.addenvs({[key] = v})
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ -- key: LIB PATH
|
|
|
+ function add_toolchain_envs(key)
|
|
|
+ local env_table = {}
|
|
|
+ local search_env_set = hashset.new()
|
|
|
+ local function insert_include(dir)
|
|
|
+ if not path.is_absolute(dir) then
|
|
|
+ dir = path.absolute(dir, os.projectdir())
|
|
|
+ end
|
|
|
+ if search_env_set:insert(dir) then
|
|
|
+ table.insert(env_table, dir)
|
|
|
+ end
|
|
|
+ end
|
|
|
+
|
|
|
+ for _, toolchain in ipairs(target:toolchains()) do
|
|
|
+ local runenvs = toolchain:runenvs()
|
|
|
+ if runenvs and runenvs[key] then
|
|
|
+ for _, env in ipairs(path.splitenv(runenvs[key])) do
|
|
|
+ insert_include(env)
|
|
|
+ end
|
|
|
+ end
|
|
|
+ end
|
|
|
+ -- INCLUDE 环境整合
|
|
|
+ for _, value in pairs(env_table) do
|
|
|
+ os.addenvs({[key] = value})
|
|
|
+ end
|
|
|
+ end
|
|
|
+ -- 添加工具链需要的环境信息
|
|
|
+ add_toolchain_envs("LIBPATH")
|
|
|
+ add_toolchain_envs("LIB")
|
|
|
+ add_toolchain_envs("INCLUDE")
|
|
|
+ local envs = os.getenvs()
|
|
|
+ local rundir = path.join(os.projectdir(), "ci_build")
|
|
|
+
|
|
|
+ -- 确保运行目录存在
|
|
|
+ os.mkdir(rundir)
|
|
|
+
|
|
|
+ os.execv("qmake", {"-version"}, {envs = envs, curdir = rundir})
|
|
|
+ -- print(envs)
|
|
|
+ local proPath = path.join(os.projectdir(), "LearningSmartClient.pro")
|
|
|
+ print("build:", proPath)
|
|
|
+ if is_mode("debug") then
|
|
|
+ os.execv("qmake", {proPath, "-spec", "win32-msvc", "CONFIG+=debug", "CONFIG+=qml_debug"}, {envs = envs, curdir = rundir})
|
|
|
+ elseif is_mode("release") then
|
|
|
+ os.execv("qmake", {proPath, "-spec", "win32-msvc", "CONFIG+=release"}, {envs = envs, curdir = rundir})
|
|
|
+ else
|
|
|
+ print("no supp QMake")
|
|
|
+ end
|
|
|
+
|
|
|
+ local jom = "D:\\Qt\\Tools\\QtCreator\\bin\\jom\\jom.exe"
|
|
|
+
|
|
|
+ if is_mode("debug") then
|
|
|
+ os.execv(jom, {"-f", "Makefile.Debug", "qmake_all"}, {envs = envs, curdir = rundir})
|
|
|
+ elseif is_mode("release") then
|
|
|
+ os.execv(jom, {"-f", "Makefile.Release", "qmake_all"}, {envs = envs, curdir = rundir})
|
|
|
+ else
|
|
|
+ print("no supp mode Makefile")
|
|
|
+ end
|
|
|
+ os.execv(jom, {"-j24"}, {envs = envs, curdir = rundir})
|
|
|
+ end)
|
|
|
+target_end()
|
|
|
+
|