aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2018-09-13 15:09:00 +0200
committerEike Ziller <eike.ziller@qt.io>2018-09-14 09:46:34 +0000
commitebbaa352fcfac361479c56192ac6cba4dcc87efb (patch)
tree7390aa5f34d376c7444960b4eff170a28e2690ad
parentd3714d329c292f4930fea8c0d9aa33ed59b12f38 (diff)
Add optional bindings to regular build
Change-Id: I47e02299707e59dc5417e965a2bbcf2a6b5d0428 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r--README.md8
-rw-r--r--TODO.md2
-rw-r--r--docs/tools.md16
-rw-r--r--optional/README.md17
-rw-r--r--optional/binding/binding.h (renamed from optional/template/binding.h)0
-rw-r--r--optional/binding/binding.pri15
-rw-r--r--optional/optional.pro5
-rw-r--r--optional/projectexplorer/projectexplorer.pro (renamed from optional/projectexplorer/binding_custom.pri)25
-rw-r--r--optional/setup.py139
-rw-r--r--optional/template/binding.pro79
-rw-r--r--optional/texteditor/texteditor.pro (renamed from optional/texteditor/binding_custom.pri)28
-rw-r--r--pythonextensions.pro12
-rw-r--r--tools/build.py109
13 files changed, 43 insertions, 412 deletions
diff --git a/README.md b/README.md
index 2cc6722..b609d3f 100644
--- a/README.md
+++ b/README.md
@@ -60,11 +60,9 @@ source.
To build QtCreator, which is necessary for building the plugin, please refer to their
[build instructions](https://doc-snapshots.qt.io/qtcreator-extending/getting-and-building.html).
-### Building the C++ plugin
-Once all dependencies are installed, you can go ahead and build the
-plugin itself. To do this (in the best case) all you will have to do
-is run the following commands in the `plugins/pythonextensions`
-directory:
+### Building the C++ plugin and bindings
+Once all dependencies are installed, you can go ahead and build the python
+bindings and the plugin itself.
```
$ path/to/your/qmake
diff --git a/TODO.md b/TODO.md
index 80b1a08..098ec7a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -12,8 +12,6 @@
## Build System
- [ ] Fix having to `export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/clang/lib`
-- [ ] Automatically build optional bindings alongside main plugin (?)
-- [ ] Fix optional bindings build system
## Examples
- [ ] Make a text editor example (once the text editor binding does anything)
diff --git a/docs/tools.md b/docs/tools.md
index e7e6612..10e18a0 100644
--- a/docs/tools.md
+++ b/docs/tools.md
@@ -4,14 +4,6 @@ This project includes a few Python scripts, included as utilities for convenienc
relatively small and self-contained. They should also all include usage instructions in comments at
the beginning of the scripts. Some of them are scattered around the project. These include:
- * [The optional bindings build script](../optional/setup.py)
- - This script is intended to help building the optional bindings, by bundling files needed by
- all optional binding libraries in a `template` directory.
- - **Available options are:**
- - --qmake=/path/to/your/qmake *required*
- - --only=binding_dir *optional, only build binding_dir*
- - clean *optional, ignores all options and removes the build directories*
-
* [The example packaging script](../examples/package.py)
- This script creates .zip files for use with the included extension manager form the example
extension sources.
@@ -33,11 +25,3 @@ The other scripts are in the [tools folder](../tools/), they are:
* [Sanity helper script](../tools/sanity.py)
- This script automatically corrects some annoying nags for the Qt Gerrit sanity check.
- Takes no options and should be run in root directory with `$ python ./tools/sanity.py`.
-
- * [Build helper script](../tools/build.py)
- - This script executes all the build scripts in this project in the correct order
- - Mainly for lazy people and only usable if everything is setup correctly
- - **Available options are:**
- - --qmake=/path/to/your/qmake *required*
- - --skip *optional, only build main c++ plugin*
- - --user *optional, build to user directory*
diff --git a/optional/README.md b/optional/README.md
index 2c5af5d..96ab614 100644
--- a/optional/README.md
+++ b/optional/README.md
@@ -9,23 +9,6 @@ that are shared for each binding.
## Documentation
-### Building
-If your environment is setup correctly (i.e. you can build the Python Extensions plugin), all that
-you should need to do is run:
-
-```
-python setup.py --qmake=/path/to/your/qmake
-```
-
-and the optional bindings should build and be installed. To clean the build files after a build,
-just run:
-
-```
-python setup.py clean
-```
-
-For problems and possible solutions, please refer to the main `README.md`.
-
### Writing optional binding libraries
**NOTICE:** Please refer to the `pyutil.h` header file for anything that is not explained
here.
diff --git a/optional/template/binding.h b/optional/binding/binding.h
index 9b397a1..9b397a1 100644
--- a/optional/template/binding.h
+++ b/optional/binding/binding.h
diff --git a/optional/binding/binding.pri b/optional/binding/binding.pri
new file mode 100644
index 0000000..8c0a0c8
--- /dev/null
+++ b/optional/binding/binding.pri
@@ -0,0 +1,15 @@
+DEFINES += PYTHONEXTENSIONS_LIBRARY
+
+# PythonExtensions files
+
+SOURCES += \
+ binding.cpp
+
+HEADERS += \
+ $$PWD/binding.h
+
+INCLUDEPATH *= $$PWD
+
+QTC_PLUGIN_DIRS += $$PWD/../../plugins
+include(../../plugins/pythonextensions/qtcreator.pri)
+include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri)
diff --git a/optional/optional.pro b/optional/optional.pro
new file mode 100644
index 0000000..1b4b363
--- /dev/null
+++ b/optional/optional.pro
@@ -0,0 +1,5 @@
+TEMPLATE = subdirs
+
+SUBDIRS = \
+ texteditor \
+ projectexplorer
diff --git a/optional/projectexplorer/binding_custom.pri b/optional/projectexplorer/projectexplorer.pro
index b9e3faf..a60ac99 100644
--- a/optional/projectexplorer/binding_custom.pri
+++ b/optional/projectexplorer/projectexplorer.pro
@@ -1,11 +1,3 @@
-# Additional sources
-
-SOURCES += \
- # optional
-
-HEADERS += \
- # optional
-
# Declare dependencies and name
@@ -23,22 +15,17 @@ QTC_PLUGIN_DEPENDS += \
QTC_PLUGIN_RECOMMENDS += \
# optional plugin dependencies. nothing here at this time
+include(../binding/binding.pri)
+
+INCLUDEPATH *= $$IDE_SOURCE_TREE/src/plugins/projectexplorer
# Shiboken binding generation setup
-WRAPPED_HEADER = wrappedclasses.h
+WRAPPED_HEADER = $$PWD/wrappedclasses.h
WRAPPER_DIR = $$OUT_PWD/QtCreatorBindingProjectExplorer
TYPESYSTEM_FILE = typesystem_projectexplorer.xml
-
TYPESYSTEM_NAME = qtcreatorbindingprojectexplorer
-
-## Include additional QtCreator paths
-QT_INCLUDEPATHS += \
- -I"$$IDE_SOURCE_TREE/src/plugins/projectexplorer"
-
-INCLUDEPATH += \
- $$IDE_SOURCE_TREE/src/plugins/projectexplorer \
- $$IDE_SOURCE_TREE/src/libs/utils
+SHIBOKEN_QT = core gui widgets network
## These headers are needed so the generated wrappers are added to the
## build. Right now they are empty files, however there might be a more elegant
@@ -55,3 +42,5 @@ WRAPPED_CLASSES = \
bindingheaders/utils.h \
bindingheaders/utils_filename.h \
# Sentinel line
+
+include(../../shiboken.pri)
diff --git a/optional/setup.py b/optional/setup.py
deleted file mode 100644
index c0f6f43..0000000
--- a/optional/setup.py
+++ /dev/null
@@ -1,139 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2018 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Python Extensions Plugin for QtCreator.
-##
-## $QT_BEGIN_LICENSE:BSD$
-## You may use this file under the terms of the BSD license as follows:
-##
-## "Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following conditions are
-## met:
-## * Redistributions of source code must retain the above copyright
-## notice, this list of conditions and the following disclaimer.
-## * Redistributions in binary form must reproduce the above copyright
-## notice, this list of conditions and the following disclaimer in
-## the documentation and/or other materials provided with the
-## distribution.
-## * Neither the name of The Qt Company Ltd nor the names of its
-## contributors may be used to endorse or promote products derived
-## from this software without specific prior written permission.
-##
-##
-## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# Assemble the binding projects and build them
-
-# You need to specify the correct qmake when running:
-# $ python setup.py --qmake=/path/to/qmake
-# (defaults to "qmake")
-
-# You can also specify a binding to build:
-# $ python setup.py --only=bindingname
-# (default is to build all)
-
-# You can clean the build directories with
-# $ python setup.py clean
-
-import os, shutil, subprocess, sys
-
-
-def qmake():
- for arg in sys.argv:
- if arg.split("=")[0] == "--qmake":
- return arg.split("=")[-1]
- return "qmake"
-
-def only():
- for arg in sys.argv:
- if arg.split("=")[0] == "--only":
- return arg.split("=")[-1]
- return False
-
-def copytree(src, dst, symlinks=False, ignore=None):
- for item in os.listdir(src):
- s = os.path.join(src, item)
- d = os.path.join(dst, item)
- if os.path.isdir(s):
- shutil.copytree(s, d, symlinks, ignore)
- else:
- shutil.copy2(s, d)
-
-def generate_build_deps():
- if os.path.exists("build_deps"):
- shutil.rmtree("build_deps")
- # Plugin dependencies .pri file
- os.makedirs("build_deps/pythonextensions")
- shutil.copy2(
- "../plugins/pythonextensions/pythonextensions_dependencies.pri",
- "build_deps/pythonextensions/pythonextensions_dependencies.pri"
- )
-
-def generate_build_dir(binding_name):
- build_dir = "build_{}".format(binding_name)
- if os.path.exists(build_dir):
- shutil.rmtree(build_dir)
- os.makedirs(build_dir)
- copytree("template", build_dir)
- copytree(binding_name, build_dir)
-
-def run_build(binding_name):
- build_dir = "build_{}".format(binding_name)
- if os.path.exists(build_dir):
- try:
- subprocess.check_call(qmake(), cwd=build_dir)
- subprocess.check_call("make", cwd=build_dir)
- except Exception as e:
- print("Got exception when building {}:".format(binding_name), e)
- return False
- return True
- return False
-
-def clean_build_dirs():
- for build_dir in os.scandir():
- if build_dir.is_dir() and build_dir.name.split("_")[0] == "build":
- shutil.rmtree(build_dir.name)
- print("Removing {}".format(build_dir.name))
-
-def main():
- generate_build_deps()
- if only():
- generate_build_dir(only())
- if run_build(only()):
- print("Built {}".format(only()))
- else:
- print("Error building {}".format(only()))
- print("Skipping other builds")
- return
- final_message = "Summary:"
- for binding in os.scandir():
- if binding.is_dir() and binding.name != "template" and binding.name.split("_")[0] != "build":
- generate_build_dir(binding.name)
- if run_build(binding.name):
- final_message += "\nBuilt {}".format(binding.name)
- else:
- final_message += "\nError building {}".format(binding.name)
- print(final_message)
-
-
-if __name__ == "__main__":
- if "clean" in sys.argv:
- clean_build_dirs()
- else:
- main()
diff --git a/optional/template/binding.pro b/optional/template/binding.pro
deleted file mode 100644
index e7f71a1..0000000
--- a/optional/template/binding.pro
+++ /dev/null
@@ -1,79 +0,0 @@
-# NOTE: This is not yet properly tested on general systems
-# and will (if at all) probably only work on a linux environment
-
-PYTHON = python
-DEFINES += PYTHONEXTENSIONS_LIBRARY
-
-# PythonExtensions files
-
-SOURCES += \
- binding.cpp
-
-HEADERS += \
- binding.h
-
-
-# Qt Creator linking
-
-# Shared QtCreator sources and build destination
-# (these are shared with the main plugin)
-include(../../plugins/pythonextensions/qtcreator.pri)
-
-## Include Qt and QtCreator paths
-QT_INCLUDEPATHS = -I"$$[QT_INSTALL_HEADERS]" -I"$$[QT_INSTALL_HEADERS]/QtCore" \
- -I"$$[QT_INSTALL_HEADERS]/QtGui" -I"$$[QT_INSTALL_HEADERS]/QtWidgets" \
- -I"$$[QT_INSTALL_HEADERS]/QtNetwork" \
- -I"$$IDE_SOURCE_TREE/src/plugins" \
- -I"$$IDE_SOURCE_TREE/src/libs"
-
-# Custom Buildsystem setup per binding
-include(binding_custom.pri)
-
-# Add the build dependencies directory, which will contain dependencies
-# related to the python extensions plugin
-QTC_PLUGIN_DIRS += $${WRAPPER_DIR}/../../build_deps/
-include($$IDE_SOURCE_TREE/src/qtcreatorplugin.pri)
-
-# Shiboken stuff
-
-# This setup is currently only tested on Linux
-
-include(../../plugins/pythonextensions/pyside2.pri)
-
-SHIBOKEN_OPTIONS = --generator-set=shiboken --enable-parent-ctor-heuristic \
- --enable-pyside-extensions --enable-return-value-heuristic --use-isnull-as-nb_nonzero \
- $$QT_INCLUDEPATHS -I$$PWD -T$$PWD -T$$PYSIDE2/typesystems --output-directory=$$OUT_PWD
-
-## Prepare the shiboken tool
-QT_TOOL.shiboken.binary = $$system_path($$PYSIDE2/shiboken2)
-qtPrepareTool(SHIBOKEN, shiboken)
-
-## Shiboken run that adds the module wrapper to GENERATED_SOURCES
-shiboken.output = $$WRAPPER_DIR/$${TYPESYSTEM_NAME}_module_wrapper.cpp
-shiboken.commands = $$SHIBOKEN $$SHIBOKEN_OPTIONS $$PWD/$$WRAPPED_HEADER ${QMAKE_FILE_IN}
-shiboken.input = TYPESYSTEM_FILE
-shiboken.dependency_type = TYPE_C
-shiboken.variable_out = GENERATED_SOURCES
-
-module_wrapper_dummy_command.output = $$WRAPPER_DIR/${QMAKE_FILE_BASE}_wrapper.cpp
-module_wrapper_dummy_command.commands = echo ${QMAKE_FILE_IN}
-module_wrapper_dummy_command.depends = $$WRAPPER_DIR/$${TYPESYSTEM_NAME}_module_wrapper.cpp
-module_wrapper_dummy_command.input = WRAPPED_CLASSES
-module_wrapper_dummy_command.dependency_type = TYPE_C
-module_wrapper_dummy_command.variable_out = GENERATED_SOURCES
-
-QMAKE_EXTRA_COMPILERS += shiboken module_wrapper_dummy_command
-
-# Include paths for Shiboken generated files
-INCLUDEPATH += $$WRAPPER_DIR \
- $$WRAPPER_DIR/../../../plugins/pythonextensions \
- $$WRAPPER_DIR/../../../plugins/pythonextensions/PythonExtension/QtCreator \
- "$$IDE_SOURCE_TREE/src/plugins/coreplugin" \
- "$$IDE_SOURCE_TREE/src/plugins/coreplugin/actionmanager" \
- "$$IDE_SOURCE_TREE/src/plugins/coreplugin/editormanager" \
- "$$IDE_SOURCE_TREE/src/libs/extensionsystem" \
- "$$IDE_SOURCE_TREE/src/libs/utils"
-
-for(i, PYSIDE2_INCLUDE) {
- INCLUDEPATH += $$i/QtWidgets $$i/QtGui $$i/QtCore $$i/QtNetwork
-}
diff --git a/optional/texteditor/binding_custom.pri b/optional/texteditor/texteditor.pro
index 361da10..e1a5e2e 100644
--- a/optional/texteditor/binding_custom.pri
+++ b/optional/texteditor/texteditor.pro
@@ -1,11 +1,3 @@
-# Additional sources
-
-SOURCES += \
- # optional
-
-HEADERS += \
- # optional
-
# Declare dependencies and name
@@ -23,25 +15,17 @@ QTC_PLUGIN_DEPENDS += \
QTC_PLUGIN_RECOMMENDS += \
# optional plugin dependencies. nothing here at this time
+include(../binding/binding.pri)
+
+INCLUDEPATH *= $$IDE_SOURCE_TREE/src/plugins/texteditor
# Shiboken binding generation setup
-WRAPPED_HEADER = wrappedclasses.h
+WRAPPED_HEADER = $$PWD/wrappedclasses.h
WRAPPER_DIR = $$OUT_PWD/QtCreatorBindingTextEditor
TYPESYSTEM_FILE = typesystem_texteditor.xml
-
TYPESYSTEM_NAME = qtcreatorbindingtexteditor
-
-## Include additional QtCreator paths
-QT_INCLUDEPATHS += \
- -I"$$IDE_SOURCE_TREE/src/plugins/texteditor"
-
-INCLUDEPATH += \
- $$IDE_SOURCE_TREE/src/plugins/coreplugin \
- $$IDE_SOURCE_TREE/src/plugins/coreplugin/editormanager \
- $$IDE_SOURCE_TREE/src/plugins/coreplugin/find \
- $$IDE_SOURCE_TREE/src/plugins/texteditor \
- $$IDE_SOURCE_TREE/src/libs/utils
+SHIBOKEN_QT = core gui widgets
## These headers are needed so the generated wrappers are added to the
## build. Right now they are empty files, however there might be a more elegant
@@ -49,3 +33,5 @@ INCLUDEPATH += \
WRAPPED_CLASSES = \
bindingheaders/texteditor.h \
# Sentinel line
+
+include(../../shiboken.pri)
diff --git a/pythonextensions.pro b/pythonextensions.pro
index 3b3723b..5d5804d 100644
--- a/pythonextensions.pro
+++ b/pythonextensions.pro
@@ -1,10 +1,10 @@
TEMPLATE = subdirs
SUBDIRS += \
- plugins/pythonextensions \
- python
+ pythonextensions \
+ python \
+ optional
-# Note: This does not yet include the
-# optional bindings. They have to
-# be built using their own setup.py,
-# or using the tools/build.py
+pythonextensions.subdir = plugins/pythonextensions
+
+optional.depends = pythonextensions
diff --git a/tools/build.py b/tools/build.py
deleted file mode 100644
index 4491025..0000000
--- a/tools/build.py
+++ /dev/null
@@ -1,109 +0,0 @@
-#############################################################################
-##
-## Copyright (C) 2018 The Qt Company Ltd.
-## Contact: http://www.qt.io/licensing/
-##
-## This file is part of the Python Extensions Plugin for QtCreator.
-##
-## $QT_BEGIN_LICENSE:BSD$
-## You may use this file under the terms of the BSD license as follows:
-##
-## "Redistribution and use in source and binary forms, with or without
-## modification, are permitted provided that the following conditions are
-## met:
-## * Redistributions of source code must retain the above copyright
-## notice, this list of conditions and the following disclaimer.
-## * Redistributions in binary form must reproduce the above copyright
-## notice, this list of conditions and the following disclaimer in
-## the documentation and/or other materials provided with the
-## distribution.
-## * Neither the name of The Qt Company Ltd nor the names of its
-## contributors may be used to endorse or promote products derived
-## from this software without specific prior written permission.
-##
-##
-## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-## "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-## LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-## A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-## OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-## DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-## THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-## (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-## OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
-##
-## $QT_END_LICENSE$
-##
-#############################################################################
-
-# This is intended as a convenience for building the main C++
-# plugin, as well as the optional bindings using one command.
-# This exists mainly because I am lazy and should probably not
-# really be a part of the build-system going forward.
-
-# Usage:
-# $ python build.py --qmake=/path/to/qmake
-
-# Options:
-# --user
-# (optional, sets USE_USER_DESTDIR)
-# --skip
-# (optional, skip optional builds)
-
-import subprocess, sys
-
-
-def user():
- return "--user" in sys.argv
-
-def skip():
- return "--skip" in sys.argv
-
-def qmake():
- for arg in sys.argv:
- if arg.split("=")[0] == "--qmake":
- return arg.split("=")[-1]
- return "qmake"
-
-def clean():
- return "clean" in sys.argv
-
-def read_pri():
- f = open("plugins/pythonextensions/qtcreator.pri", "r")
- body = f.read(-1)
- f.close()
- return body
-
-def write_pri(body):
- f = open("plugins/pythonextensions/qtcreator.pri", "w")
- f.write(body)
- f.close()
-
-def build_plugin():
- subprocess.check_call(qmake(), cwd="plugins/pythonextensions")
- subprocess.check_call("make", cwd="plugins/pythonextensions")
-
-def build_optional():
- subprocess.check_call(["python", "setup.py", "--qmake={}".format(qmake())], cwd="optional")
-
-def main():
- if user():
- write_pri(read_pri().replace("# USE_USER_DESTDIR = yes", "USE_USER_DESTDIR = yes"))
- build_plugin()
- if not skip():
- build_optional()
- if user():
- write_pri(read_pri().replace("USE_USER_DESTDIR = yes", "# USE_USER_DESTDIR = yes"))
-
-def main_clean():
- subprocess.check_call(["make", "clean"], cwd="plugins/pythonextensions")
- subprocess.check_call(["python", "setup.py", "clean"], cwd="optional")
-
-
-if __name__ == "__main__":
- if clean():
- main_clean()
- else:
- main()