diff options
author | Dominik Holland <dominik.holland@pelagicore.com> | 2018-07-23 13:05:03 +0200 |
---|---|---|
committer | Dominik Holland <dominik.holland@pelagicore.com> | 2018-09-14 13:01:39 +0000 |
commit | e54f439758007f2212442a90a3c44333b5a60268 (patch) | |
tree | 3dec171d3d547d8f5fabb406aa7dab0cf8584bdc | |
parent | a54a10e2b00397f1fdb26eefbcc6d6b47b54157c (diff) | |
download | qtivi-e54f439758007f2212442a90a3c44333b5a60268.tar.gz |
Add a option to use the system python instead of creating a virtualenv
If the qface module is available in the same version as we would
set it up in the virtualenv ourselfs we now skip creating a virtualenv
This is useful for yocto deployment as we can use the packaged python3
binaries and by this better support creating SDKs
Change-Id: I9b114c9cc7241e4af976f35153b97e3d799466e9
Reviewed-by: Robert Griebl <robert.griebl@pelagicore.com>
-rw-r--r-- | mkspecs/features/ivigenerator.prf | 25 | ||||
-rw-r--r-- | src/ivicore/configure.json | 27 | ||||
-rw-r--r-- | src/ivicore/configure.pri | 8 | ||||
-rw-r--r-- | src/tools/ivigenerator/ivigenerator.pro | 5 |
4 files changed, 50 insertions, 15 deletions
diff --git a/mkspecs/features/ivigenerator.prf b/mkspecs/features/ivigenerator.prf index 8d36aae..b573610 100644 --- a/mkspecs/features/ivigenerator.prf +++ b/mkspecs/features/ivigenerator.prf @@ -9,7 +9,7 @@ # QFACE_OUTPUT_DIR = my_output_dir (defaults to current build dir) # QFACE_ANNOTATIONS += additional.yaml # -QT_FOR_CONFIG += ivicore-private +QT_FOR_CONFIG += ivicore ivicore-private isEmpty(QFACE_FORMAT): QFACE_FORMAT = frontend isEmpty(QFACE_OUTPUT_DIR): QFACE_OUTPUT_DIR = $$OUT_PWD @@ -51,13 +51,23 @@ QT_FOR_CONFIG *= ivicore-private else: ENV += IVIGENERATOR_CONFIG="$$shell_path($$QTIVI_BUILD_ROOT/src/tools/ivigenerator/.config)" } -equals(QMAKE_HOST.os, Windows) { - VIRTUALENV_PYTHON = $$VIRTUALENV_PATH/Scripts/python.exe +qtConfig(system-qface) { + isEmpty(QMAKE_PYTHON3_LOCATION): error("Couldn't find the QMAKE_PYTHON3_LOCATION variable, Please reconfigure qtivi") + PYTHON = $$QMAKE_PYTHON3_LOCATION + !exists($$PYTHON) { + PYTHON = $$[QT_HOST_BINS]/python3 + equals(QMAKE_HOST.os, Windows): PYTHON = $${PYTHON}.exe + warning("The Python binary in QMAKE_PYTHON3_LOCATION variable doesn't exist, falling back to use QT_HOST_BINS") + } } else { - VIRTUALENV_PYTHON = $$VIRTUALENV_PATH/bin/python - ENV += LD_LIBRARY_PATH="$$shell_path($$VIRTUALENV_PATH/bin)" + equals(QMAKE_HOST.os, Windows) { + PYTHON = $$VIRTUALENV_PATH/Scripts/python.exe + } else { + PYTHON = $$VIRTUALENV_PATH/bin/python + ENV += LD_LIBRARY_PATH="$$shell_path($$VIRTUALENV_PATH/bin)" + } } -IVI_GENERATOR = $$VIRTUALENV_PYTHON $$IVI_GENERATOR_PATH/generate.py +IVI_GENERATOR = $$PYTHON $$IVI_GENERATOR_PATH/generate.py # TODO make this work with multiple input files, or only support one QFACE_SOURCE # Although this could be extra_compiler it is a normal EXTRA_TARGET for a reason. @@ -116,7 +126,8 @@ Makefile.depends = $$relative_path($$PRI, $$OUT_PWD) # In this case we create the target with a dependency to the forceRebuild file. # This file is created during the qmake run and updated once the virtualenv is ready # and will then cause a rerun of qmake -!isEmpty(QTIVI_BUILD_ROOT):!exists($$VIRTUALENV_PATH): { +# When using qface from the system, we don't need to wait for the virtualenv to be setup +!qtConfig(system-qface):!isEmpty(QTIVI_BUILD_ROOT):!exists($$VIRTUALENV_PATH): { Makefile.depends = $$shadowed($$IVI_GENERATOR_PATH)/forceRebuild } else { !isEmpty(QFACE_HEADERS_OUTPUT_TARGET) { diff --git a/src/ivicore/configure.json b/src/ivicore/configure.json index 1482146..a86a389 100644 --- a/src/ivicore/configure.json +++ b/src/ivicore/configure.json @@ -5,6 +5,7 @@ "commandline": { "options": { "ivigenerator": { "type": "enum", "values": [ "no", "qt", "system" ] }, + "qface": { "type": "enum", "values": [ "no", "qt", "system" ] }, "host-tools-only": "boolean", "force-ivigenerator-qtsimulator": "boolean", "force-ivigenerator-qtremoteobjects": "boolean" @@ -23,7 +24,13 @@ "package": "virtualenv" }, "qface": { - "label": "qface", + "label": "qface 1.10", + "type": "python3_package", + "package": "qface", + "version": "1.10" + }, + "qface-submodule": { + "label": "qface-submodule", "type": "qface_submodule" } }, @@ -34,8 +41,8 @@ "condition": "tests.python3", "output": [ "privateFeature", - { "type": "varAssign", "name": "QMAKE_PYTHON3_LOCATION", "value": "tests.python3.value" }, - { "type": "varAssign", "name": "QMAKE_PYTHON3_VERSION", "value": "tests.python3.version" } + { "type": "varAssign", "public": true, "name": "QMAKE_PYTHON3_LOCATION", "value": "tests.python3.value" }, + { "type": "varAssign", "public": true, "name": "QMAKE_PYTHON3_VERSION", "value": "tests.python3.version" } ] }, "python3-virtualenv": { @@ -43,6 +50,13 @@ "condition": "features.python3 && tests.virtualenv", "output": [ "privateFeature" ] }, + "system-qface": { + "label": "System QFace", + "enable": "input.qface == 'system'", + "disable": "input.qface == 'no' || input.qface == 'qt'", + "condition": "tests.qface", + "output": [ "publicFeature" ] + }, "system-ivigenerator": { "label": "System IVI Generator", "enable": "input.ivigenerator == 'system'", @@ -53,7 +67,7 @@ "label": "IVI Generator", "enable": "input.ivigenerator == 'qt' || input.ivigenerator == 'system'", "disable": "input.ivigenerator == 'no'", - "condition": "features.ivicore && features.python3 && features.python3-virtualenv && tests.qface || features.system-ivigenerator", + "condition": "features.ivicore && features.python3 && ((features.python3-virtualenv && tests.qface-submodule) || (features.system-qface)) || features.system-ivigenerator", "output": [ "publicFeature" ] }, "host-tools-only": { @@ -87,7 +101,7 @@ Make sure python3 and its 'virtualenv' packages are installed. E.g. by running apt-get install python3 python3-virtualenv -And make sure the qface submodule is initialized. +And make sure the qface submodule is initialized or the correct qface version is installed on your system. E.g. by running the following command: git submodule init && git submodule update" }, @@ -115,7 +129,8 @@ The QtSimulator Support is needed for the communication between the simulation b { "type": "python3" }, - "python3-virtualenv" + "python3-virtualenv", + "system-qface" ] }, "ivigenerator", diff --git a/src/ivicore/configure.pri b/src/ivicore/configure.pri index dc59dbf..2e6832c 100644 --- a/src/ivicore/configure.pri +++ b/src/ivicore/configure.pri @@ -39,8 +39,14 @@ defineTest(qtConfTest_python3) { defineTest(qtConfTest_python3_package) { python3_exe = $$eval($${currentConfig}.tests.python3.value) package = $$eval($${1}.package) + version = $$eval($${1}.version) - qtRunLoggedCommand("$$python3_exe -c \"import $${package}\"", package_exists)|return(false) + qtRunLoggedCommand("$$python3_exe -c \"import pkg_resources; print(pkg_resources.get_distribution('$${package}').version)\"", package_version)|return(false) + !isEmpty(version) { + qtLog("Also checking for the exact version:") + qtLog("Expected: $$version") + !equals(version, $$package_version): return(false) + } return(true) } diff --git a/src/tools/ivigenerator/ivigenerator.pro b/src/tools/ivigenerator/ivigenerator.pro index 5e4df1c..960235a 100644 --- a/src/tools/ivigenerator/ivigenerator.pro +++ b/src/tools/ivigenerator/ivigenerator.pro @@ -1,8 +1,11 @@ TEMPLATE = aux +# We need the include here as we don't have a hard build dependency against ivicore, but we still +# need to have the config, so we just include that, even if ivicore itself is not build. +include($$OUT_PWD/../../ivicore/qtivicore-config.pri) QT_FOR_CONFIG += ivicore -!contains(CONFIG, no_internal_qface): include(qface_internal_build.pri) +!qtConfig(system-qface): include(qface_internal_build.pri) # Make sure to only build this once in a debug_and_release config # This needs to be the last step as it unsets other configs and may have side effects |