summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-04-17 00:29:59 +0800
committerruki <[email protected]>2018-04-16 20:59:58 +0800
commit811bda9a12d7cecfaac97f2ab9943daa4e627396 (patch)
tree4da40a60fb6ffc7202bf54a22cda561da1ed458c
parent05f1e2189edb9cdab244a19f170bbccf1938c90e (diff)
improve qt rules
-rw-r--r--tests/projects/qt_console/xmake.lua2
-rw-r--r--tests/projects/qt_shared_library/xmake.lua2
-rw-r--r--tests/projects/qt_static_library/xmake.lua2
-rw-r--r--xmake/rules/qt/console/load.lua67
-rw-r--r--xmake/rules/qt/console/xmake.lua30
-rw-r--r--xmake/rules/qt/shared/load.lua67
-rw-r--r--xmake/rules/qt/shared/xmake.lua30
-rw-r--r--xmake/rules/qt/static/load.lua67
-rw-r--r--xmake/rules/qt/static/xmake.lua30
-rw-r--r--xmake/rules/qt/xmake.lua116
10 files changed, 122 insertions, 291 deletions
diff --git a/tests/projects/qt_console/xmake.lua b/tests/projects/qt_console/xmake.lua
index 0ab7a6b23..4ff829575 100644
--- a/tests/projects/qt_console/xmake.lua
+++ b/tests/projects/qt_console/xmake.lua
@@ -11,3 +11,5 @@ target("qt_console")
-- add files
add_files("src/*.cpp")
+ -- add frameworks
+ add_frameworks("QtCore")
diff --git a/tests/projects/qt_shared_library/xmake.lua b/tests/projects/qt_shared_library/xmake.lua
index f858b266c..7fb713393 100644
--- a/tests/projects/qt_shared_library/xmake.lua
+++ b/tests/projects/qt_shared_library/xmake.lua
@@ -17,3 +17,5 @@ target("qt_demo")
-- add defines
add_defines("QT_DEMO_LIBRARY")
+ -- add frameworks
+ add_frameworks("QtGui", "QtCore")
diff --git a/tests/projects/qt_static_library/xmake.lua b/tests/projects/qt_static_library/xmake.lua
index e69538015..42e208787 100644
--- a/tests/projects/qt_static_library/xmake.lua
+++ b/tests/projects/qt_static_library/xmake.lua
@@ -14,3 +14,5 @@ target("qt_demo")
-- add files
add_files("src/*.cpp")
+ -- add frameworks
+ add_frameworks("QtGui", "QtCore")
diff --git a/xmake/rules/qt/console/load.lua b/xmake/rules/qt/console/load.lua
deleted file mode 100644
index 4185132e0..000000000
--- a/xmake/rules/qt/console/load.lua
+++ /dev/null
@@ -1,67 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file load.lua
---
-
--- imports
-import("core.project.config")
-import("detect.sdks.find_qt")
-
--- the main entry
-function main(target)
-
- -- check qt sdk
- local qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")
-
- -- set kind: binary
- target:set("kind", "binary")
-
- -- add defines for using core lib
- target:add("defines", "QT_CORE_LIB")
-
- -- need c++11
- target:set("languages", "cxx11")
-
- -- add defines for the compile mode
- if is_mode("debug") then
- target:add("defines", "QT_QML_DEBUG")
- elseif is_mode("release") then
- target:add("defines", "QT_NO_DEBUG")
- elseif is_mode("profile") then
- target:add("defines", "QT_QML_DEBUG", "QT_NO_DEBUG")
- end
-
- -- The following define makes your compiler emit warnings if you use
- -- any feature of Qt which as been marked deprecated (the exact warnings
- -- depend on your compiler). Please consult the documentation of the
- -- deprecated API in order to know how to port your code away from it.
- target:add("defines", "QT_DEPRECATED_WARNINGS")
-
- -- add includedirs, linkdirs for macosx
- if is_plat("macosx") then
- target:add("frameworkdirs", qt.linkdirs)
- target:add("frameworks", "QtCore", "DiskArbitration", "IOKit")
- target:add("includedirs", path.join(qt.sdkdir, "lib/QtCore.framework/Headers"))
- target:add("includedirs", path.join(qt.sdkdir, "mkspecs/macx-clang"))
- target:add("rpathdirs", "@executable_path/Frameworks", qt.linkdirs)
- end
-end
diff --git a/xmake/rules/qt/console/xmake.lua b/xmake/rules/qt/console/xmake.lua
deleted file mode 100644
index 0b3149222..000000000
--- a/xmake/rules/qt/console/xmake.lua
+++ /dev/null
@@ -1,30 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file xmake.lua
---
-
--- define rule
-rule("qt:console")
-
- -- on load
- on_load("load")
-
diff --git a/xmake/rules/qt/shared/load.lua b/xmake/rules/qt/shared/load.lua
deleted file mode 100644
index 6baf7050b..000000000
--- a/xmake/rules/qt/shared/load.lua
+++ /dev/null
@@ -1,67 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file load.lua
---
-
--- imports
-import("core.project.config")
-import("detect.sdks.find_qt")
-
--- the main entry
-function main(target)
-
- -- check qt sdk
- local qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")
-
- -- set kind: shared
- target:set("kind", "shared")
-
- -- add defines for using gui and core libs
- target:add("defines", "QT_GUI_LIB", "QT_CORE_LIB")
-
- -- need c++11
- target:set("languages", "cxx11")
-
- -- add defines for the compile mode
- if is_mode("debug") then
- target:add("defines", "QT_QML_DEBUG")
- elseif is_mode("release") then
- target:add("defines", "QT_NO_DEBUG")
- elseif is_mode("profile") then
- target:add("defines", "QT_QML_DEBUG", "QT_NO_DEBUG")
- end
-
- -- The following define makes your compiler emit warnings if you use
- -- any feature of Qt which as been marked deprecated (the exact warnings
- -- depend on your compiler). Please consult the documentation of the
- -- deprecated API in order to know how to port your code away from it.
- target:add("defines", "QT_DEPRECATED_WARNINGS")
-
- -- add includedirs and linkdirs for macosx
- if is_plat("macosx") then
- target:add("frameworkdirs", qt.linkdirs)
- target:add("frameworks", "QtCore", "DiskArbitration", "IOKit")
- target:add("includedirs", path.join(qt.sdkdir, "lib/QtCore.framework/Headers"))
- target:add("includedirs", path.join(qt.sdkdir, "mkspecs/macx-clang"))
- target:add("rpathdirs", "@executable_path/Frameworks", qt.linkdirs)
- end
-end
diff --git a/xmake/rules/qt/shared/xmake.lua b/xmake/rules/qt/shared/xmake.lua
deleted file mode 100644
index 7dbbe5913..000000000
--- a/xmake/rules/qt/shared/xmake.lua
+++ /dev/null
@@ -1,30 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file xmake.lua
---
-
--- define rule
-rule("qt:shared")
-
- -- on load
- on_load("load")
-
diff --git a/xmake/rules/qt/static/load.lua b/xmake/rules/qt/static/load.lua
deleted file mode 100644
index 51af12bd3..000000000
--- a/xmake/rules/qt/static/load.lua
+++ /dev/null
@@ -1,67 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file load.lua
---
-
--- imports
-import("core.project.config")
-import("detect.sdks.find_qt")
-
--- the main entry
-function main(target)
-
- -- check qt sdk
- local qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")
-
- -- set kind: static
- target:set("kind", "static")
-
- -- add defines for using gui and core libs
- target:add("defines", "QT_GUI_LIB", "QT_CORE_LIB")
-
- -- need c++11
- target:set("languages", "cxx11")
-
- -- add defines for the compile mode
- if is_mode("debug") then
- target:add("defines", "QT_QML_DEBUG")
- elseif is_mode("release") then
- target:add("defines", "QT_NO_DEBUG")
- elseif is_mode("profile") then
- target:add("defines", "QT_QML_DEBUG", "QT_NO_DEBUG")
- end
-
- -- The following define makes your compiler emit warnings if you use
- -- any feature of Qt which as been marked deprecated (the exact warnings
- -- depend on your compiler). Please consult the documentation of the
- -- deprecated API in order to know how to port your code away from it.
- target:add("defines", "QT_DEPRECATED_WARNINGS")
-
- -- add includedirs for macosx
- if is_plat("macosx") then
- target:add("frameworkdirs", qt.linkdirs)
- target:add("frameworks", "OpenGL", "AGL")
- target:add("includedirs", path.join(qt.sdkdir, "lib/QtGui.framework/Headers"))
- target:add("includedirs", path.join(qt.sdkdir, "lib/QtCore.framework/Headers"))
- target:add("includedirs", path.join(qt.sdkdir, "mkspecs/macx-clang"))
- end
-end
diff --git a/xmake/rules/qt/static/xmake.lua b/xmake/rules/qt/static/xmake.lua
deleted file mode 100644
index 0d88967ce..000000000
--- a/xmake/rules/qt/static/xmake.lua
+++ /dev/null
@@ -1,30 +0,0 @@
---!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, 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 - 2018, TBOOX Open Source Group.
---
--- @author ruki
--- @file xmake.lua
---
-
--- define rule
-rule("qt:static")
-
- -- on load
- on_load("load")
-
diff --git a/xmake/rules/qt/xmake.lua b/xmake/rules/qt/xmake.lua
new file mode 100644
index 000000000..4c08cea78
--- /dev/null
+++ b/xmake/rules/qt/xmake.lua
@@ -0,0 +1,116 @@
+--!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, 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 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define base rule
+rule("qt:base")
+
+ -- on load
+ on_load(function (target)
+
+ -- imports
+ import("core.project.config")
+ import("detect.sdks.find_qt")
+
+ -- check qt sdk
+ local qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")
+
+ -- set kind: binary
+ target:set("kind", "binary")
+
+ -- need c++11
+ target:set("languages", "cxx11")
+
+ -- add defines for the compile mode
+ if is_mode("debug") then
+ target:add("defines", "QT_QML_DEBUG")
+ elseif is_mode("release") then
+ target:add("defines", "QT_NO_DEBUG")
+ elseif is_mode("profile") then
+ target:add("defines", "QT_QML_DEBUG", "QT_NO_DEBUG")
+ end
+
+ -- The following define makes your compiler emit warnings if you use
+ -- any feature of Qt which as been marked deprecated (the exact warnings
+ -- depend on your compiler). Please consult the documentation of the
+ -- deprecated API in order to know how to port your code away from it.
+ target:add("defines", "QT_DEPRECATED_WARNINGS")
+
+ -- do frameworks for qt
+ for _, framework in ipairs(target:get("frameworks")) do
+
+ -- translate qt frameworks
+ if framework:startswith("Qt") then
+
+ -- add defines
+ target:add("defines", "QT_" .. framework:sub(3):upper() .. "_LIB")
+
+ -- add includedirs for macosx
+ if is_plat("macosx") then
+ target:add("includedirs", path.join(qt.sdkdir, "lib/" .. framework .. ".framework/Headers"))
+ end
+ end
+ end
+
+ -- add includedirs, linkdirs for macosx
+ if is_plat("macosx") then
+ target:add("frameworkdirs", qt.linkdirs)
+ target:add("frameworks", "DiskArbitration", "IOKit")
+ target:add("includedirs", path.join(qt.sdkdir, "mkspecs/macx-clang"))
+ target:add("rpathdirs", "@executable_path/Frameworks", qt.linkdirs)
+ end
+ end)
+
+-- define rule: qt console
+rule("qt:console")
+
+ -- add base rule
+ add_deps("qt:base")
+
+ -- on load
+ on_load(function (target)
+ target:set("kind", "binary")
+ end)
+
+-- define rule: qt static library
+rule("qt:static")
+
+ -- add base rule
+ add_deps("qt:base")
+
+ -- on load
+ on_load(function (target)
+ target:set("kind", "static")
+ end)
+
+-- define rule: qt shared library
+rule("qt:shared")
+
+ -- add base rule
+ add_deps("qt:base")
+
+ -- on load
+ on_load(function (target)
+ target:set("kind", "shared")
+ end)
+