Android: Correctly escape backslashes in deployment settings

When outputting the deployment settings on Windows, the paths might
have backslashes. These need to be escaped, otherwise they will simply
be removed by the JSON parser (or converted into whatever they happen
to represent given the neighbouring character.)

Task-number: QTBUG-33926
Change-Id: I11f1bc7d1f8082c73329bdc02fb8d653a0b5c0ee
Reviewed-by: Paul Olav Tvete <paul.tvete@digia.com>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
Eskil Abrahamsen Blomfeldt 2013-10-07 22:42:11 +02:00 committed by The Qt Project
parent d4b30757ab
commit c376c272e6

View File

@ -1,17 +1,22 @@
contains(TEMPLATE, ".*app"):!build_pass:!android-no-sdk {
defineReplace(emitString) {
return("\"$$replace(1, \\\\, \\\\)\"")
}
FILE_CONTENT = "{"
FILE_CONTENT += " \"description\": \"This file is generated by qmake to be read by androiddeployqt and should not be modified by hand.\","
FILE_CONTENT += " \"qt\": \"$$[QT_INSTALL_PREFIX]\","
FILE_CONTENT += " \"qt\": $$emitString($$[QT_INSTALL_PREFIX]),"
# Settings from mkspecs/environment
isEmpty(SDK_ROOT): SDK_ROOT = $$(ANDROID_SDK_ROOT)
isEmpty(SDK_ROOT): SDK_ROOT = $$DEFAULT_ANDROID_SDK_ROOT
FILE_CONTENT += " \"sdk\": \"$$SDK_ROOT\","
FILE_CONTENT += " \"sdk\": $$emitString($$SDK_ROOT),"
isEmpty(NDK_ROOT): NDK_ROOT = $$(ANDROID_NDK_ROOT)
isEmpty(NDK_ROOT): NDK_ROOT = $$DEFAULT_ANDROID_NDK_ROOT
FILE_CONTENT += " \"ndk\": \"$$NDK_ROOT\","
FILE_CONTENT += " \"ndk\": $$emitString($$NDK_ROOT),"
NDK_TOOLCHAIN_PREFIX = $$(ANDROID_NDK_TOOLCHAIN_PREFIX)
isEmpty(NDK_TOOLCHAIN_PREFIX) {
@ -19,48 +24,47 @@ contains(TEMPLATE, ".*app"):!build_pass:!android-no-sdk {
else: equals(ANDROID_TARGET_ARCH, mips): NDK_TOOLCHAIN_PREFIX = mipsel-linux-android
else: NDK_TOOLCHAIN_PREFIX = arm-linux-androideabi
}
FILE_CONTENT += " \"toolchain-prefix\": \"$$NDK_TOOLCHAIN_PREFIX\","
FILE_CONTENT += " \"toolchain-prefix\": $$emitString($$NDK_TOOLCHAIN_PREFIX),"
NDK_TOOLCHAIN_VERSION = $$(ANDROID_NDK_TOOLCHAIN_VERSION)
isEmpty(NDK_TOOLCHAIN_VERSION): NDK_TOOLCHAIN_VERSION = $$DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION
FILE_CONTENT += " \"toolchain-version\": \"$$NDK_TOOLCHAIN_VERSION\","
FILE_CONTENT += " \"toolchain-version\": $$emitString($$NDK_TOOLCHAIN_VERSION),"
NDK_HOST = $$(ANDROID_NDK_HOST)
isEmpty(NDK_HOST): NDK_HOST = $$DEFAULT_ANDROID_NDK_HOST
FILE_CONTENT += " \"ndk-host\": \"$$NDK_HOST\","
FILE_CONTENT += " \"ndk-host\": $$emitString($$NDK_HOST),"
ANDROID_TARGET_ARCH = $$(ANDROID_TARGET_ARCH)
isEmpty(ANDROID_TARGET_ARCH): ANDROID_TARGET_ARCH = $$DEFAULT_ANDROID_TARGET_ARCH
FILE_CONTENT += " \"target-architecture\": \"$$ANDROID_TARGET_ARCH\","
FILE_CONTENT += " \"target-architecture\": $$emitString($$ANDROID_TARGET_ARCH),"
# Explicitly set dependencies of application for deployment
!isEmpty(ANDROID_DEPLOYMENT_DEPENDENCIES): \
FILE_CONTENT += " \"deployment-dependencies\": \""$$join(ANDROID_DEPLOYMENT_DEPENDENCIES, ",")"\","
FILE_CONTENT += " \"deployment-dependencies\": $$emitString($$join(ANDROID_DEPLOYMENT_DEPENDENCIES, ",")),"
# Android-specific settings of Project
!isEmpty(ANDROID_PACKAGE_SOURCE_DIR): \
FILE_CONTENT += " \"android-package-source-directory\": \"$$ANDROID_PACKAGE_SOURCE_DIR\","
FILE_CONTENT += " \"android-package-source-directory\": $$emitString($$ANDROID_PACKAGE_SOURCE_DIR),"
!isEmpty(ANDROID_PACKAGE): \
FILE_CONTENT += " \"android-package\": \"$$ANDROID_PACKAGE\","
FILE_CONTENT += " \"android-package\": $$emitString($$ANDROID_PACKAGE),"
!isEmpty(ANDROID_MINIMUM_VERSION): \
FILE_CONTENT += " \"android-minimum-version\": $$ANDROID_MINIMUM_VERSION,"
FILE_CONTENT += " \"android-minimum-version\": $$ANDROID_MINIMUM_VERSION,"
!isEmpty(ANDROID_TARGET_VERSION): \
FILE_CONTENT += " \"android-target-version\": $$ANDROID_TARGET_VERSION,"
FILE_CONTENT += " \"android-target-version\": $$ANDROID_TARGET_VERSION,"
!isEmpty(ANDROID_APP_NAME): \
FILE_CONTENT += " \"android-app-name\": \"$$ANDROID_APP_NAME\","
FILE_CONTENT += " \"android-app-name\": $$emitString($$ANDROID_APP_NAME),"
!isEmpty(ANDROID_EXTRA_LIBS): \
FILE_CONTENT += " \"android-extra-libs\": \""$$join(ANDROID_EXTRA_LIBS, ",")"\","
FILE_CONTENT += " \"android-extra-libs\": $$emitString($$join(ANDROID_EXTRA_LIBS, ",")),"
!isEmpty(QMAKE_SUPPORTED_ORIENTATIONS): \
FILE_CONTENT += " \"supported-orientations\": \""$$join(QMAKE_SUPPORTED_ORIENTATIONS, ",")"\","
FILE_CONTENT += " \"supported-orientations\": $$emitString($$join(QMAKE_SUPPORTED_ORIENTATIONS, ",")),"
FILE_CONTENT += " \"application-binary\": \"$$absolute_path($$DESTDIR, $$OUT_PWD)/$$TARGET\""
FILE_CONTENT += " \"application-binary\": $$emitString($$absolute_path($$DESTDIR, $$OUT_PWD)/$$TARGET)"
FILE_CONTENT += "}"
isEmpty(ANDROID_DEPLOYMENT_SETTINGS_FILE): ANDROID_DEPLOYMENT_SETTINGS_FILE = $$OUT_PWD/android-$$TARGET-deployment-settings.json